@@ -3896,8 +3896,8 @@ static void notif_folder_modified(IDB_ITEM *pidb,
38963896 mlog (LV_ERR, " E-2423: ENOMEM" );
38973897}
38983898
3899- static void notif_msg_modified (IDB_ITEM *pidb,
3900- uint64_t folder_id , uint64_t message_id) try
3899+ static void notif_msg_modified (IDB_ITEM *pidb, uint64_t folder_id,
3900+ const std::string &folder_name , uint64_t message_id) try
39013901{
39023902 TPROPVAL_ARRAY propvals;
39033903 static constexpr proptag_t tmp_proptags[] = {
@@ -3929,6 +3929,12 @@ static void notif_msg_modified(IDB_ITEM *pidb,
39293929 qstr += " , forwarded=1" ;
39303930 qstr += " WHERE message_id=" + std::to_string (message_id);
39313931 gx_sql_exec (pidb->psqlite , qstr.c_str ());
3932+ qstr = " SELECT uid FROM messages WHERE message_id=" + std::to_string (message_id);
3933+ auto stm = gx_sql_prep (pidb->psqlite , qstr.c_str ());
3934+ if (stm != nullptr && stm.step () == SQLITE_ROW)
3935+ system_services_broadcast_event (fmt::format (" MESSAGE-UFLAG {} {} {}" ,
3936+ pidb->username , base64_encode (folder_name),
3937+ stm.col_uint64 (0 )).c_str ());
39323938 return ;
39333939 }
39343940 auto ts = propvals.get <const uint64_t >(PR_LAST_MODIFICATION_TIME);
@@ -3960,6 +3966,7 @@ static void notif_handler(const char *dir,
39603966 if (pidb == nullptr || pidb->sub_id != notify_id)
39613967 return ;
39623968 uint64_t parent_id = 0 , folder_id = 0 , message_id = 0 ;
3969+
39633970 switch (pdb_notify->type ) {
39643971 case db_notify_type::new_mail: {
39653972 auto n = static_cast <const DB_NOTIFY_NEW_MAIL *>(pdb_notify->pdata );
@@ -4016,7 +4023,6 @@ static void notif_handler(const char *dir,
40164023 auto n = static_cast <const DB_NOTIFY_MESSAGE_MODIFIED *>(pdb_notify->pdata );
40174024 message_id = n->message_id ;
40184025 folder_id = n->folder_id ;
4019- notif_msg_modified (pidb.get (), folder_id, message_id);
40204026 break ;
40214027 }
40224028 case db_notify_type::folder_moved: {
@@ -4063,17 +4069,25 @@ static void notif_handler(const char *dir,
40634069 break ;
40644070 }
40654071
4066- /* Broadcast a FOLDER-TOUCH event */
4072+ std::string folder_name;
40674073 if (folder_id != 0 ) {
4068- auto qstr = fmt::format ( " SELECT name FROM folders WHERE folder_id={} " , folder_id);
4074+ auto qstr = " SELECT name FROM folders WHERE folder_id=" + std::to_string ( folder_id);
40694075 auto stm = gx_sql_prep (pidb->psqlite , qstr.c_str ());
4070- if (stm == nullptr || stm.step () != SQLITE_ROW)
4071- return ;
4072- std::string name = znul (stm.col_text (0 ));
4073- stm.finalize ();
4074- qstr = fmt::format (" FOLDER-TOUCH {} {}" , pidb->username , base64_encode (name));
4075- system_services_broadcast_event (qstr.c_str ());
4076+ if (stm != nullptr && stm.step () == SQLITE_ROW)
4077+ folder_name = znul (stm.col_text (0 ));
40764078 }
4079+
4080+ switch (pdb_notify->type ) {
4081+ case db_notify_type::message_modified:
4082+ notif_msg_modified (pidb.get (), folder_id, folder_name, message_id);
4083+ break ;
4084+ default :
4085+ break ;
4086+ }
4087+
4088+ /* Broadcast a FOLDER-TOUCH event */
4089+ auto qstr = fmt::format (" FOLDER-TOUCH {} {}" , pidb->username , base64_encode (folder_name));
4090+ system_services_broadcast_event (qstr.c_str ());
40774091} catch (const std::bad_alloc &) {
40784092 mlog (LV_ERR, " E-2346: ENOMEM" );
40794093}
0 commit comments