Skip to content

Commit cc2d59c

Browse files
committed
r10s's comments
1 parent 28f817d commit cc2d59c

File tree

3 files changed

+20
-29
lines changed

3 files changed

+20
-29
lines changed

deltachat-ffi/deltachat.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7601,7 +7601,7 @@ void dc_event_unref(dc_event_t* event);
76017601
/// Used as info message.
76027602
#define DC_STR_SECUREJOIN_TAKES_LONGER 192
76037603

7604-
/// "❤️ Seems you're using Delta Chat!"… (donation request device message)
7604+
/// "❤️ Seems you're enjoying Delta Chat!"… (donation request device message)
76057605
#define DC_STR_DONATION_REQUEST 193
76067606

76077607
/// "Contact". Deprecated, currently unused.

src/chat.rs

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3231,37 +3231,28 @@ pub async fn send_videochat_invitation(context: &Context, chat_id: ChatId) -> Re
32313231
}
32323232

32333233
async fn donation_request_maybe(context: &Context) -> Result<()> {
3234-
let secs_between_checks = 14 * 24 * 60 * 60;
3235-
let secs_between_requests = 60 * 24 * 60 * 60;
3234+
let secs_between_checks = 30 * 24 * 60 * 60;
32363235
let now = time();
32373236
let ts = context
32383237
.get_config_i64(Config::DonationRequestNextCheck)
32393238
.await?;
3240-
let ts_new = if ts <= now {
3241-
let msg_cnt = context
3242-
.sql
3243-
.count(
3244-
"SELECT COUNT(*) FROM msgs WHERE state>=? AND hidden=0",
3245-
(MessageState::OutDelivered,),
3246-
)
3247-
.await?;
3248-
if msg_cnt < 50 {
3249-
// New users go here, so they won't get the message immediately.
3250-
now.saturating_add(secs_between_checks)
3251-
} else {
3252-
let mut msg = Message::new_text(stock_str::donation_request(context).await);
3253-
add_device_msg(context, None, Some(&mut msg)).await?;
3254-
now.saturating_add(secs_between_requests)
3255-
}
3239+
if ts > now {
3240+
return Ok(());
3241+
}
3242+
let msg_cnt = context.sql.count(
3243+
"SELECT COUNT(*) FROM msgs WHERE state>=? AND hidden=0",
3244+
(MessageState::OutDelivered,),
3245+
);
3246+
let ts = if ts == 0 || msg_cnt.await? < 100 {
3247+
now.saturating_add(secs_between_checks)
32563248
} else {
3257-
cmp::min(ts, now.saturating_add(secs_between_requests))
3249+
let mut msg = Message::new_text(stock_str::donation_request(context).await);
3250+
add_device_msg(context, None, Some(&mut msg)).await?;
3251+
i64::MAX
32583252
};
3259-
if ts_new != ts {
3260-
context
3261-
.set_config_internal(Config::DonationRequestNextCheck, Some(&ts_new.to_string()))
3262-
.await?;
3263-
}
3264-
Ok(())
3253+
context
3254+
.set_config_internal(Config::DonationRequestNextCheck, Some(&ts.to_string()))
3255+
.await
32653256
}
32663257

32673258
/// Chat message list request options.

src/stock_str.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -434,11 +434,11 @@ pub enum StockMessage {
434434
))]
435435
SecurejoinTakesLonger = 192,
436436

437-
#[strum(props(fallback = "❤️ Seems you're using Delta Chat!
437+
#[strum(props(fallback = "❤️ Seems you're enjoying Delta Chat!
438438
439439
Please consider donating to help that Delta Chat stays free for everyone.
440440
441-
While Delta Chat is free to use and open source, development costs time and developers need money.
441+
While Delta Chat is free to use and open source, development costs money.
442442
Help keeping us to keep Delta Chat independent and make it more awesome in the future.
443443
444444
https://delta.chat/donate"))]
@@ -839,7 +839,7 @@ pub(crate) async fn securejoin_takes_longer(context: &Context) -> String {
839839
translated(context, StockMessage::SecurejoinTakesLonger).await
840840
}
841841

842-
/// Stock string: `❤️ Seems you're using Delta Chat!`…
842+
/// Stock string: `❤️ Seems you're enjoying Delta Chat!`…
843843
pub(crate) async fn donation_request(context: &Context) -> String {
844844
translated(context, StockMessage::DonationRequest).await
845845
}

0 commit comments

Comments
 (0)