Skip to content

Commit 544212d

Browse files
committed
Reviews
1 parent 72c8c7b commit 544212d

File tree

4 files changed

+23
-18
lines changed

4 files changed

+23
-18
lines changed

deltachat-jsonrpc/src/api.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -594,9 +594,9 @@ impl CommandApi {
594594
/// Unpublished transports are not advertised to contacts,
595595
/// and self-sent messages are not sent there,
596596
/// so that we don't cause extra messages to the corresponding inbox,
597-
/// but can still receive messages from contacts who don't know the new relay addresses yet.
597+
/// but can still receive messages from contacts who don't know our new transport addresses yet.
598598
///
599-
/// The default is true, but when updating,
599+
/// The default is false, but when the user updates from a version that didn't have this flag,
600600
/// existing secondary transports are set to unpublished,
601601
/// so that an existing transport address doesn't suddenly get spammed with a lot of messages.
602602
async fn set_transport_unpublished(

src/config.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,8 +1003,9 @@ impl Context {
10031003
self.sql
10041004
.query_map_vec(
10051005
"SELECT addr FROM transports
1006-
WHERE is_published=1
1007-
AND addr NOT IN (SELECT value FROM config WHERE keyname='configured_addr')",
1006+
WHERE is_published
1007+
AND addr NOT IN (SELECT value FROM config WHERE keyname='configured_addr')
1008+
ORDER BY add_timestamp DESC",
10081009
(),
10091010
|row| {
10101011
let addr: String = row.get(0)?;

src/configure.rs

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -275,30 +275,34 @@ impl Context {
275275
/// Unpublished transports are not advertised to contacts,
276276
/// and self-sent messages are not sent there,
277277
/// so that we don't cause extra messages to the corresponding inbox,
278-
/// but can still receive messages from contacts who don't know the new relay addresses yet.
278+
/// but can still receive messages from contacts who don't know our new transport addresses yet.
279279
///
280-
/// The default is true, but when updating,
280+
/// The default is false, but when the user updates from a version that didn't have this flag,
281281
/// existing secondary transports are set to unpublished,
282282
/// so that an existing transport address doesn't suddenly get spammed with a lot of messages.
283283
pub async fn set_transport_unpublished(&self, addr: &str, unpublished: bool) -> Result<()> {
284284
// We need to update the timestamp so that the key's timestamp changes
285285
// and is recognized as newer by our peers
286286
self.sql
287287
.transaction(|trans| {
288-
let primary_addr: String = trans.query_row(
289-
"SELECT value FROM config WHERE keyname='configured_addr'",
290-
(),
291-
|row| row.get(0),
292-
)?;
288+
let primary_addr: String = trans
289+
.query_row(
290+
"SELECT value FROM config WHERE keyname='configured_addr'",
291+
(),
292+
|row| row.get(0),
293+
)
294+
.context("Select primary address")?;
293295
if primary_addr == addr && unpublished {
294296
bail!("Can't set primary relay as unpublished");
295297
}
296-
trans.execute(
297-
"UPDATE transports SET is_published=?, add_timestamp=? WHERE addr=?",
298-
(!unpublished, time(), addr),
299-
)?;
298+
trans
299+
.execute(
300+
"UPDATE transports SET is_published=?, add_timestamp=? WHERE addr=? AND is_published!=?1",
301+
(!unpublished, time(), addr),
302+
)
303+
.context("Update transports")?;
300304
Ok(())
301-
})
305+
})h
302306
.await?;
303307
send_sync_transports(self).await?;
304308
Ok(())

src/sql/migrations.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2347,8 +2347,8 @@ ALTER TABLE contacts ADD COLUMN name_normalized TEXT;
23472347
// Unpublished transports are not advertised to contacts,
23482348
// and self-sent messages are not sent there,
23492349
// so that we don't cause extra messages to the corresponding inbox,
2350-
// but can still receive messages from contacts who don't know the new relay addresses yet.
2351-
// The default is true, but when updating,
2350+
// but can still receive messages from contacts who don't know our new transport addresses yet.
2351+
// The default is true, but when when the user updates the app,
23522352
// existing secondary transports are set to unpublished,
23532353
// so that an existing transport address doesn't suddenly get spammed with a lot of messages.
23542354
inc_and_check(&mut migration_version, 149)?;

0 commit comments

Comments
 (0)