MCPcopy Create free account
hub / github.com/chatmail/core / donation_request_maybe

Function donation_request_maybe

src/chat.rs:3086–3109  ·  view source on GitHub ↗
(context: &Context)

Source from the content-addressed store, hash-verified

3084}
3085
3086async fn donation_request_maybe(context: &Context) -> Result<()> {
3087 let secs_between_checks = 30 * 24 * 60 * 60;
3088 let now = time();
3089 let ts = context
3090 .get_config_i64(Config::DonationRequestNextCheck)
3091 .await?;
3092 if ts > now {
3093 return Ok(());
3094 }
3095 let msg_cnt = context.sql.count(
3096 "SELECT COUNT(*) FROM msgs WHERE state>=? AND hidden=0",
3097 (MessageState::OutDelivered,),
3098 );
3099 let ts = if ts == 0 || msg_cnt.await? < 100 {
3100 now.saturating_add(secs_between_checks)
3101 } else {
3102 let mut msg = Message::new_text(stock_str::donation_request(context));
3103 add_device_msg(context, None, Some(&mut msg)).await?;
3104 i64::MAX
3105 };
3106 context
3107 .set_config_internal(Config::DonationRequestNextCheck, Some(&ts.to_string()))
3108 .await
3109}
3110
3111/// Chat message list request options.
3112#[derive(Debug)]

Callers 1

prepare_send_msgFunction · 0.85

Calls 6

timeFunction · 0.85
donation_requestFunction · 0.85
add_device_msgFunction · 0.85
get_config_i64Method · 0.80
countMethod · 0.80
set_config_internalMethod · 0.80

Tested by

no test coverage detected