Skip to content

Commit

Permalink
Interim update to working hack
Browse files Browse the repository at this point in the history
  • Loading branch information
Danielle committed Nov 9, 2021
1 parent fea637c commit 254dd78
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions libdiscord.c
Original file line number Diff line number Diff line change
Expand Up @@ -4653,7 +4653,6 @@ discord_got_read_states(DiscordAccount *da, JsonNode *node, gpointer user_data)

const gchar *channel = json_object_get_string_member(state, "id");
guint64 last_id = discord_get_room_last_id(da, to_int(channel));
//guint64 remote_last_id = to_int(json_object_get_string_member(state, "last_message_id"));
gchar *last_id_s = from_int(last_id);
gint mentions = json_object_get_int_member(state, "mention_count");

Expand All @@ -4670,10 +4669,11 @@ discord_got_read_states(DiscordAccount *da, JsonNode *node, gpointer user_data)
dchannel = discord_get_channel_global_int(da, to_int(channel));
}
if (dchannel) {
if (dchannel->muted)
return;
remote_last_id = dchannel->last_message_id;
} else {
// There could possibly be race cases here with incoming messages, but
// we don't have the channel object, so there's not much we can do
remote_last_id = to_int(json_object_get_string_member(state, "last_message_id"));
purple_debug_warning("discord", "Got read state for uninited channel with id %s\n", channel);
}

Expand All @@ -4682,8 +4682,13 @@ discord_got_read_states(DiscordAccount *da, JsonNode *node, gpointer user_data)
if ((last_id < remote_last_id && discord_treat_room_as_small(da, to_int(channel), head_count)) ||
(mentions && purple_account_get_bool(da->account, "open-chat-on-mention", TRUE))) {

//discord_get_history(da, channel, last_id_s, mentions * 2);
discord_join_chat_by_id(da, to_int(channel));
//discord_join_chat_by_id(da, to_int(channel));

// Above *should* work, but because obtaining the channel object is
// spotty, we can't check for muted channels, thus this hack was born
gchar *remote_last_id_s = from_int(remote_last_id-1);
discord_get_history(da, channel, remote_last_id_s, 5);
g_free(remote_last_id_s);

} else if (mentions) {
purple_debug_misc("discord", "%d unhandled mentions in channel %s\n", mentions, dchannel->name);
Expand Down

0 comments on commit 254dd78

Please sign in to comment.