about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2020-03-09 12:22:36 +0100
committerMichael Vetter <jubalh@iodoru.org>2020-03-09 12:22:36 +0100
commit56836fb72db2a72c0f16d909d7a4ee6f104aedaa (patch)
treea36c8e76117fdb3d069f262f9f7d01c058d49edc
parent3d7e6fae7cda1d7c871f384c1b94d7c0cb8c9ea7 (diff)
downloadprofani-tty-56836fb72db2a72c0f16d909d7a4ee6f104aedaa.tar.gz
Use correct MUC message timestamp
win_println_incoming_muc_msg() always used the current time. Now let's
use whatever is sent int he message struct (from the delay stanza or
the current time that we set now once the message is received).

No playing with the time upon display anymore.
-rw-r--r--src/ui/window.c6
-rw-r--r--src/xmpp/message.c7
2 files changed, 8 insertions, 5 deletions
diff --git a/src/ui/window.c b/src/ui/window.c
index 4f1d4f05..324871da 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -1152,19 +1152,15 @@ win_print_them(ProfWin *window, theme_item_t theme_item, const char *const show_
 void
 win_println_incoming_muc_msg(ProfWin *window, char *show_char, int flags, const ProfMessage *const message)
 {
-    //TODO: we always use current timestamp here. instead of the message->timestamp one if available. i think somewhere else we check whether it exists first.
-    GDateTime *timestamp = g_date_time_new_now_local();
-
     if (prefs_get_boolean(PREF_CORRECTION_ALLOW) && message->replace_id) {
         _win_correct(window, message->plain, message->id, message->replace_id);
     } else {
-        _win_printf(window, show_char, 0, timestamp, flags | NO_ME, THEME_TEXT_THEM, message->jid->resourcepart, message->id, "%s", message->plain);
+        _win_printf(window, show_char, 0, message->timestamp, flags | NO_ME, THEME_TEXT_THEM, message->jid->resourcepart, message->id, "%s", message->plain);
     }
 //    buffer_append(window->layout->buffer, show_char, 0, timestamp, flags | NO_ME, THEME_TEXT_THEM, them, message, NULL, NULL);
  //   _win_print_internal(window, show_char, 0, timestamp, flags | NO_ME, THEME_TEXT_THEM, them, message, NULL);
 
     inp_nonblocking(TRUE);
-    g_date_time_unref(timestamp);
 }
 
 void
diff --git a/src/xmpp/message.c b/src/xmpp/message.c
index dee41baa..d9159e81 100644
--- a/src/xmpp/message.c
+++ b/src/xmpp/message.c
@@ -882,6 +882,13 @@ _handle_groupchat(xmpp_stanza_t *const stanza)
     // we want to display the oldest delay
     message->timestamp = stanza_get_oldest_delay(stanza);
 
+    // now this has nothing to do with MUC history
+    // it's just setting the time to the received time so upon displaying we can use this time
+    // for example in win_println_incoming_muc_msg()
+    if (!message->timestamp) {
+        message->timestamp = g_date_time_new_now_local();
+    }
+
     if (is_muc_history) {
         sv_ev_room_history(message);
     } else {