Skip to content

Commit

Permalink
fix double escaped username in message headers (#239, fixes #236)
Browse files Browse the repository at this point in the history
  • Loading branch information
ouwou committed Oct 21, 2023
1 parent 5e244e5 commit 893c9b5
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 10 deletions.
10 changes: 1 addition & 9 deletions src/components/chatmessage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1057,10 +1057,9 @@ void ChatMessageHeader::UpdateName() {
const auto chan = discord.GetChannel(ChannelID);
bool is_guild = chan.has_value() && chan->GuildID.has_value();
if (is_guild) {
const auto member = discord.GetMember(UserID, *chan->GuildID);
const auto role_id = discord.GetMemberHoistedRole(*chan->GuildID, UserID, true);
const auto role = discord.GetRole(role_id);
const auto name = GetEscapedDisplayName(*user, member);
const auto name = user->GetDisplayNameEscaped(*chan->GuildID);

std::string md;
if (role.has_value())
Expand Down Expand Up @@ -1090,13 +1089,6 @@ void ChatMessageHeader::AttachUserMenuHandler(Gtk::Widget &widget) {
});
}

Glib::ustring ChatMessageHeader::GetEscapedDisplayName(const UserData &user, const std::optional<GuildMember> &member) {
if (member.has_value() && !member->Nickname.empty())
return Glib::Markup::escape_text(member->Nickname);
else
return Glib::Markup::escape_text(user.GetDisplayNameEscaped());
}

bool ChatMessageHeader::on_author_button_press(GdkEventButton *ev) {
if (ev->button == GDK_BUTTON_PRIMARY && (ev->state & GDK_SHIFT_MASK)) {
m_signal_action_insert_mention.emit();
Expand Down
1 change: 0 additions & 1 deletion src/components/chatmessage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ class ChatMessageHeader : public Gtk::ListBoxRow {

protected:
void AttachUserMenuHandler(Gtk::Widget &widget);
static Glib::ustring GetEscapedDisplayName(const UserData &user, const std::optional<GuildMember> &member);

bool on_author_button_press(GdkEventButton *ev);

Expand Down

0 comments on commit 893c9b5

Please sign in to comment.