@@ -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 ( ( ) )
0 commit comments