fix webhook messages not using right username + avatar (fixes #209)

This commit is contained in:
ouwou committed 2023-08-28 21:47:04 -04:00
1 parent 9724023758
commit 36f2ec0996
10 files changed
+164 -16

No files matched your search

+15 -1
View File
@@ -67,8 +67,22 @@ void ChatList::ProcessNewMessage(const Message &data, bool prepend) {
if (last_row != nullptr) {
const uint64_t diff = std::max(data.ID, last_row->NewestID) - std::min(data.ID, last_row->NewestID);
if (last_row->UserID == data.Author.ID && (prepend || (diff < SnowflakeSplitDifference * Snowflake::SecondsInterval)))
if (last_row->UserID == data.Author.ID && (prepend || (diff < SnowflakeSplitDifference * Snowflake::SecondsInterval))) {
should_attach = true;
}
// Separate webhooks if the usernames or avatar URLs are different
if (data.IsWebhook() && last_row->UserID == data.Author.ID) {
const auto last_message = discord.GetMessage(last_row->NewestID);
if (last_message.has_value() && last_message->IsWebhook()) {
const auto last_webhook_data = last_message->GetWebhookData();
const auto next_webhook_data = data.GetWebhookData();
if (last_webhook_data.has_value() && next_webhook_data.has_value()) {
if (last_webhook_data->Username != next_webhook_data->Username || last_webhook_data->Avatar != next_webhook_data->Avatar) {
should_attach = false;
}
}
}
}
}
}