Skip to content

Commit 56d79ef

Browse files
committed
r10s's review
1 parent 93a621a commit 56d79ef

File tree

4 files changed

+17
-12
lines changed

4 files changed

+17
-12
lines changed

deltachat-ffi/deltachat.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7601,6 +7601,9 @@ 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)
7605+
#define DC_STR_DONATION_REQUEST 193
7606+
76047607
/// "Contact". Deprecated, currently unused.
76057608
#define DC_STR_CONTACT 200
76067609

src/chat.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3231,32 +3231,34 @@ 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 period_check = 14 * 24 * 60 * 60;
3235-
let period_msg = 60 * 24 * 60 * 60;
3234+
let secs_between_checks = 14 * 24 * 60 * 60;
3235+
let secs_between_requests = 60 * 24 * 60 * 60;
32363236
let now = time();
3237-
let ts = context.get_config_i64(Config::DonationRequestTs).await?;
3237+
let ts = context
3238+
.get_config_i64(Config::DonationRequestNextCheck)
3239+
.await?;
32383240
let ts_new = if ts <= now {
32393241
let msg_cnt = context
32403242
.sql
32413243
.count(
3242-
"SELECT COUNT(*) FROM msgs WHERE state>=? AND hidden=0 AND param GLOB \"*c=*\"",
3244+
"SELECT COUNT(*) FROM msgs WHERE state>=? AND hidden=0",
32433245
(MessageState::OutDelivered,),
32443246
)
32453247
.await?;
3246-
if msg_cnt < 10 {
3248+
if msg_cnt < 50 {
32473249
// New users go here, so they won't get the message immediately.
3248-
now.saturating_add(period_check)
3250+
now.saturating_add(secs_between_checks)
32493251
} else {
32503252
let mut msg = Message::new_text(stock_str::donation_request(context).await);
32513253
add_device_msg(context, None, Some(&mut msg)).await?;
3252-
now.saturating_add(period_msg)
3254+
now.saturating_add(secs_between_requests)
32533255
}
32543256
} else {
3255-
cmp::min(ts, now.saturating_add(period_msg))
3257+
cmp::min(ts, now.saturating_add(secs_between_requests))
32563258
};
32573259
if ts_new != ts {
32583260
context
3259-
.set_config_internal(Config::DonationRequestTs, Some(&ts_new.to_string()))
3261+
.set_config_internal(Config::DonationRequestNextCheck, Some(&ts_new.to_string()))
32603262
.await?;
32613263
}
32623264
Ok(())

src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ pub enum Config {
370370
DisableIdle,
371371

372372
/// Timestamp of the next check for donation request need.
373-
DonationRequestTs,
373+
DonationRequestNextCheck,
374374

375375
/// Defines the max. size (in bytes) of messages downloaded automatically.
376376
/// 0 = no limit.

src/context.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,8 +1033,8 @@ impl Context {
10331033
.to_string(),
10341034
);
10351035
res.insert(
1036-
"donation_request_ts",
1037-
self.get_config_i64(Config::DonationRequestTs)
1036+
"donation_request_next_check",
1037+
self.get_config_i64(Config::DonationRequestNextCheck)
10381038
.await?
10391039
.to_string(),
10401040
);

0 commit comments

Comments
 (0)