[Messages] Add option to ignore private messages from non-buddy users (#6966)

* [Messages] Add option to ignore private messages from non-buddy users

* [Messages] Exclude Moderator/Admin from non-buddy ignore filter

Moderator and Admin messages should not be filtered out when the
'Ignore private messages from non-buddies' setting is enabled, to
ensure that important warnings from server staff reach users.
This commit is contained in:
kongwu 2026-06-10 11:49:29 +08:00 committed by GitHub
parent f72c82d0f9
commit 6d0a423dcf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 30 additions and 3 deletions

View file

@ -22,10 +22,14 @@ MessagesSettingsPage::MessagesSettingsPage()
ignoreUnregUsersMainChat.setChecked(SettingsCache::instance().getIgnoreUnregisteredUsers());
ignoreUnregUserMessages.setChecked(SettingsCache::instance().getIgnoreUnregisteredUserMessages());
ignoreNonBuddyUserMessages.setChecked(SettingsCache::instance().getIgnoreNonBuddyUserMessages());
connect(&ignoreUnregUsersMainChat, &QCheckBox::QT_STATE_CHANGED, &SettingsCache::instance(),
&SettingsCache::setIgnoreUnregisteredUsers);
connect(&ignoreUnregUserMessages, &QCheckBox::QT_STATE_CHANGED, &SettingsCache::instance(),
&SettingsCache::setIgnoreUnregisteredUserMessages);
connect(&ignoreNonBuddyUserMessages, &QCheckBox::QT_STATE_CHANGED, &SettingsCache::instance(),
&SettingsCache::setIgnoreNonBuddyUserMessages);
invertMentionForeground.setChecked(SettingsCache::instance().getChatMentionForeground());
connect(&invertMentionForeground, &QCheckBox::QT_STATE_CHANGED, this, &MessagesSettingsPage::updateTextColor);
@ -62,9 +66,10 @@ MessagesSettingsPage::MessagesSettingsPage()
chatGrid->addWidget(&ignoreUnregUsersMainChat, 2, 0);
chatGrid->addWidget(&hexLabel, 1, 2);
chatGrid->addWidget(&ignoreUnregUserMessages, 3, 0);
chatGrid->addWidget(&messagePopups, 4, 0);
chatGrid->addWidget(&mentionPopups, 5, 0);
chatGrid->addWidget(&roomHistory, 6, 0);
chatGrid->addWidget(&ignoreNonBuddyUserMessages, 4, 0);
chatGrid->addWidget(&messagePopups, 5, 0);
chatGrid->addWidget(&mentionPopups, 6, 0);
chatGrid->addWidget(&roomHistory, 7, 0);
chatGroupBox = new QGroupBox;
chatGroupBox->setLayout(chatGrid);
@ -237,6 +242,7 @@ void MessagesSettingsPage::retranslateUi()
QString("<a href='%1'>%2</a>").arg(WIKI_CUSTOM_SHORTCUTS).arg(tr("How to use in-game message macros")));
ignoreUnregUsersMainChat.setText(tr("Ignore chat room messages sent by unregistered users"));
ignoreUnregUserMessages.setText(tr("Ignore private messages sent by unregistered users"));
ignoreNonBuddyUserMessages.setText(tr("Ignore private messages sent by non-buddy users"));
invertMentionForeground.setText(tr("Invert text color"));
invertHighlightForeground.setText(tr("Invert text color"));
messagePopups.setText(tr("Enable desktop notifications for private messages"));

View file

@ -36,6 +36,7 @@ private:
QCheckBox invertHighlightForeground;
QCheckBox ignoreUnregUsersMainChat;
QCheckBox ignoreUnregUserMessages;
QCheckBox ignoreNonBuddyUserMessages;
QCheckBox messagePopups;
QCheckBox mentionPopups;
QCheckBox roomHistory;

View file

@ -1019,6 +1019,12 @@ void TabSupervisor::processUserMessageEvent(const Event_UserMessage &event)
!userLevel.testFlag(ServerInfo_User::IsRegistered)) {
// Flags are additive, so reg/mod/admin are all IsRegistered
return;
} else if (SettingsCache::instance().getIgnoreNonBuddyUserMessages() &&
!userListManager->isUserBuddy(senderName) && !userLevel.testFlag(ServerInfo_User::IsModerator) &&
!userLevel.testFlag(ServerInfo_User::IsAdmin)) {
// Ignore private messages from non-buddies
// Moderator/Admin messages are exempt to ensure warnings reach users
return;
}
}
tab = addMessageTab(QString::fromStdString(event.sender_name()), false);