File tree Expand file tree Collapse file tree 2 files changed +40
-2
lines changed
deltachat-rpc-client/tests Expand file tree Collapse file tree 2 files changed +40
-2
lines changed Original file line number Diff line number Diff line change @@ -730,3 +730,20 @@ def test_no_old_msg_is_fresh(acfactory):
730
730
assert ev .chat_id == first_msg .get_snapshot ().chat_id
731
731
assert ac1 .create_chat (ac2 ).get_fresh_message_count () == 0
732
732
assert len (list (ac1 .get_fresh_messages ())) == 0
733
+
734
+
735
+ def test_rename_synchronization (acfactory ):
736
+ """Test synchronization of contact renaming."""
737
+ alice , bob = acfactory .get_online_accounts (2 )
738
+ alice2 = alice .clone ()
739
+ alice2 .bring_online ()
740
+
741
+ bob .set_config ("displayname" , "Bob" )
742
+ bob .create_chat (alice ).send_text ("Hello!" )
743
+ alice_msg = alice .wait_for_incoming_msg ().get_snapshot ()
744
+ alice2_msg = alice2 .wait_for_incoming_msg ().get_snapshot ()
745
+
746
+ assert alice2_msg .sender .get_snapshot ().display_name == "Bob"
747
+ alice_msg .sender .set_name ("Bobby" )
748
+ alice2 .wait_for_event (EventType .CONTACTS_CHANGED )
749
+ assert alice2_msg .sender .get_snapshot ().display_name == "Bobby"
Original file line number Diff line number Diff line change @@ -102,7 +102,7 @@ impl ContactId {
102
102
/// for this contact will switch to the
103
103
/// contact's authorized name.
104
104
pub async fn set_name ( self , context : & Context , name : & str ) -> Result < ( ) > {
105
- context
105
+ let addr = context
106
106
. sql
107
107
. transaction ( |transaction| {
108
108
let is_changed = transaction. execute (
@@ -111,10 +111,31 @@ impl ContactId {
111
111
) ? > 0 ;
112
112
if is_changed {
113
113
update_chat_names ( context, transaction, self ) ?;
114
+ let addr = transaction. query_row (
115
+ "SELECT addr FROM contacts WHERE id=?" ,
116
+ ( self , ) ,
117
+ |row| {
118
+ let addr: String = row. get ( 0 ) ?;
119
+ Ok ( addr)
120
+ } ,
121
+ ) ?;
122
+ Ok ( Some ( addr) )
123
+ } else {
124
+ Ok ( None )
114
125
}
115
- Ok ( ( ) )
116
126
} )
117
127
. await ?;
128
+
129
+ if let Some ( addr) = addr {
130
+ chat:: sync (
131
+ context,
132
+ chat:: SyncId :: ContactAddr ( addr. to_string ( ) ) ,
133
+ chat:: SyncAction :: Rename ( name. to_string ( ) ) ,
134
+ )
135
+ . await
136
+ . log_err ( context)
137
+ . ok ( ) ;
138
+ }
118
139
Ok ( ( ) )
119
140
}
120
141
You can’t perform that action at this time.
0 commit comments