diff options
author | Daniel Kamil Kozar <dkk089@gmail.com> | 2017-07-20 15:38:31 +0300 |
---|---|---|
committer | Daniel Kamil Kozar <dkk089@gmail.com> | 2017-07-20 15:46:35 +0300 |
commit | 6f69a9e85c73792c6f98e7a223bef37124e7a6a1 (patch) | |
tree | becd579aaf57d303421b5d8d20d788aa15ed4aea | |
parent | 2ea69c79db8d74797a8178d70b41302cf46802d0 (diff) |
Store the last message timestamp of group chats
When re-joining a previously joined chat, skypeweb requests the full message
history from the Skype server. This leads to re-displaying messages that are
already present in the conversation logs stored on the disk, if logging is
enabled.
This commit stores the last message timestamp of all group chats for which a
message has been received. Using the "global" last message timestamp is not
possible, since messages in a given group chat might have appeared between
leaving and re-joining.
-rw-r--r-- | skypeweb/skypeweb_messages.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/skypeweb/skypeweb_messages.c b/skypeweb/skypeweb_messages.c index 3d60fef..27f331a 100644 --- a/skypeweb/skypeweb_messages.c +++ b/skypeweb/skypeweb_messages.c @@ -22,6 +22,12 @@ #include "skypeweb_contacts.h"
#include "skypeweb_login.h"
+static GString* make_last_timestamp_setting(const gchar *convname) {
+ GString *rv = g_string_new(NULL);
+ g_string_printf(rv, "%s_last_message_timestamp", convname);
+ return rv;
+}
+
static gboolean
skypeweb_is_user_self(SkypeWebAccount *sa, const gchar *username) {
if (!username || *username == 0) {
@@ -161,6 +167,10 @@ process_message_resource(SkypeWebAccount *sa, JsonObject *resource) skypeweb_get_conversation_history(sa, chatname);
skypeweb_get_thread_users(sa, chatname);
}
+ GString *chat_last_timestamp = make_last_timestamp_setting(convname);
+ purple_account_set_int(sa->account, chat_last_timestamp->str, composetimestamp);
+ g_string_free(chat_last_timestamp, TRUE);
+
conv = PURPLE_CONVERSATION(chatconv);
if (g_str_equal(messagetype, "Control/Typing")) {
@@ -890,7 +900,9 @@ skypeweb_get_conversation_history_since(SkypeWebAccount *sa, const gchar *convna void
skypeweb_get_conversation_history(SkypeWebAccount *sa, const gchar *convname)
{
- skypeweb_get_conversation_history_since(sa, convname, 0);
+ GString *timestamp_key = make_last_timestamp_setting(convname);
+ skypeweb_get_conversation_history_since(sa, convname, purple_account_get_int(sa->account, timestamp_key->str, 0));
+ g_string_free(timestamp_key, TRUE);
}
static void
|