fix: don't include blocked users in join/part messages (#6181)
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
- Bugfix: Fixed the emote popup erroneously logging messages to the `Other` directory. (#6165)
|
||||
- Bugfix: Handle <kbd>CMD</kbd> + <kbd>BACKSPACE</kbd> behavior explicitly in main chat dialog input for macOS. (#6111)
|
||||
- Bugfix: Fixed a small typo in the settings page. (#6134)
|
||||
- Bugfix: Fixed blocked users showing up in "Users joined:" and "Users parted:" messages. (#6181)
|
||||
- Bugfix: Fixed an issue where Splits could get lost by dragging it onto your Recycle Bin. (#6147)
|
||||
- Bugfix: Fixed some Twitch commands not getting tab-completed correctly. (#6143)
|
||||
- Bugfix: Fixed shared chat badges displaying pixelated when Chatterino is scaled too much. (#6146)
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
#include "common/ChannelChatters.hpp"
|
||||
|
||||
#include "common/Channel.hpp"
|
||||
#include "messages/Message.hpp"
|
||||
#include "controllers/ignores/IgnoreController.hpp"
|
||||
#include "debug/AssertInGuiThread.hpp"
|
||||
#include "messages/MessageBuilder.hpp"
|
||||
#include "providers/twitch/TwitchAccount.hpp"
|
||||
|
||||
#include <QColor>
|
||||
|
||||
@@ -25,10 +27,21 @@ void ChannelChatters::addRecentChatter(const QString &user)
|
||||
chatters->addRecentChatter(user);
|
||||
}
|
||||
|
||||
void ChannelChatters::addJoinedUser(const QString &user)
|
||||
void ChannelChatters::addJoinedUser(const QString &user, bool isMod,
|
||||
bool isBroadcaster)
|
||||
{
|
||||
auto joinedUsers = this->joinedUsers_.access();
|
||||
joinedUsers->append(user);
|
||||
assertInGuiThread();
|
||||
|
||||
if (isIgnoredMessage(IgnoredMessageParameters{
|
||||
.twitchUserLogin = user,
|
||||
.isMod = isMod,
|
||||
.isBroadcaster = isBroadcaster,
|
||||
}))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this->joinedUsers_.access()->append(user);
|
||||
|
||||
if (!this->joinedUsersMergeQueued_)
|
||||
{
|
||||
@@ -50,10 +63,21 @@ void ChannelChatters::addJoinedUser(const QString &user)
|
||||
}
|
||||
}
|
||||
|
||||
void ChannelChatters::addPartedUser(const QString &user)
|
||||
void ChannelChatters::addPartedUser(const QString &user, bool isMod,
|
||||
bool isBroadcaster)
|
||||
{
|
||||
auto partedUsers = this->partedUsers_.access();
|
||||
partedUsers->append(user);
|
||||
assertInGuiThread();
|
||||
|
||||
if (isIgnoredMessage(IgnoredMessageParameters{
|
||||
.twitchUserLogin = user,
|
||||
.isMod = isMod,
|
||||
.isBroadcaster = isBroadcaster,
|
||||
}))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this->partedUsers_.access()->append(user);
|
||||
|
||||
if (!this->partedUsersMergeQueued_)
|
||||
{
|
||||
|
||||
@@ -22,8 +22,8 @@ public:
|
||||
SharedAccessGuard<const ChatterSet> accessChatters() const;
|
||||
|
||||
void addRecentChatter(const QString &user);
|
||||
void addJoinedUser(const QString &user);
|
||||
void addPartedUser(const QString &user);
|
||||
void addJoinedUser(const QString &user, bool isMod, bool isBroadcaster);
|
||||
void addPartedUser(const QString &user, bool isMod, bool isBroadcaster);
|
||||
const QColor getUserColor(const QString &user);
|
||||
void setUserColor(const QString &user, const QColor &color);
|
||||
void updateOnlineChatters(const std::unordered_set<QString> &usernames);
|
||||
|
||||
@@ -53,7 +53,7 @@ QString blockUser(const CommandContext &ctx)
|
||||
[currentUser, channel{ctx.channel},
|
||||
target](const HelixUser &targetUser) {
|
||||
getApp()->getAccounts()->twitch.getCurrent()->blockUser(
|
||||
targetUser.id, nullptr,
|
||||
targetUser.id, targetUser.login, nullptr,
|
||||
[channel, target, targetUser] {
|
||||
channel->addSystemMessage(
|
||||
QString("You successfully blocked user %1")
|
||||
@@ -125,7 +125,7 @@ QString unblockUser(const CommandContext &ctx)
|
||||
target,
|
||||
[currentUser, channel{ctx.channel}, target](const auto &targetUser) {
|
||||
getApp()->getAccounts()->twitch.getCurrent()->unblockUser(
|
||||
targetUser.id, nullptr,
|
||||
targetUser.id, targetUser.login, nullptr,
|
||||
[channel, target, targetUser] {
|
||||
channel->addSystemMessage(
|
||||
QString("You successfully unblocked user %1")
|
||||
|
||||
@@ -149,16 +149,27 @@ bool isIgnoredMessage(IgnoredMessageParameters &¶ms)
|
||||
}
|
||||
}
|
||||
|
||||
if (!params.twitchUserID.isEmpty() &&
|
||||
getSettings()->enableTwitchBlockedUsers)
|
||||
if (getSettings()->enableTwitchBlockedUsers)
|
||||
{
|
||||
auto sourceUserID = params.twitchUserID;
|
||||
bool isBlocked = false;
|
||||
|
||||
if (!params.twitchUserID.isEmpty())
|
||||
{
|
||||
isBlocked = getApp()
|
||||
->getAccounts()
|
||||
->twitch.getCurrent()
|
||||
->blockedUserIds()
|
||||
.contains(params.twitchUserID);
|
||||
}
|
||||
else if (!params.twitchUserLogin.isEmpty())
|
||||
{
|
||||
isBlocked = getApp()
|
||||
->getAccounts()
|
||||
->twitch.getCurrent()
|
||||
->blockedUserLogins()
|
||||
.contains(params.twitchUserLogin);
|
||||
}
|
||||
|
||||
bool isBlocked = getApp()
|
||||
->getAccounts()
|
||||
->twitch.getCurrent()
|
||||
->blockedUserIds()
|
||||
.contains(sourceUserID);
|
||||
if (isBlocked)
|
||||
{
|
||||
switch (static_cast<ShowIgnoredUsersMessages>(
|
||||
|
||||
@@ -15,6 +15,7 @@ struct IgnoredMessageParameters {
|
||||
QString message;
|
||||
|
||||
QString twitchUserID;
|
||||
QString twitchUserLogin;
|
||||
bool isMod;
|
||||
bool isBroadcaster;
|
||||
};
|
||||
|
||||
@@ -934,7 +934,8 @@ void IrcMessageHandler::handleJoinMessage(Communi::IrcMessage *message)
|
||||
}
|
||||
else if (getSettings()->showJoins.getValue())
|
||||
{
|
||||
twitchChannel->addJoinedUser(message->nick());
|
||||
twitchChannel->addJoinedUser(message->nick(), twitchChannel->isMod(),
|
||||
twitchChannel->isBroadcaster());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -954,7 +955,8 @@ void IrcMessageHandler::handlePartMessage(Communi::IrcMessage *message)
|
||||
if (message->nick() != selfAccountName &&
|
||||
getSettings()->showParts.getValue())
|
||||
{
|
||||
twitchChannel->addPartedUser(message->nick());
|
||||
twitchChannel->addPartedUser(message->nick(), twitchChannel->isMod(),
|
||||
twitchChannel->isBroadcaster());
|
||||
}
|
||||
|
||||
if (message->nick() == selfAccountName)
|
||||
|
||||
@@ -117,6 +117,7 @@ void TwitchAccount::loadBlocks()
|
||||
this->blockToken_ = token;
|
||||
this->ignores_.clear();
|
||||
this->ignoresUserIds_.clear();
|
||||
this->ignoresUserLogins_.clear();
|
||||
|
||||
getHelix()->loadBlocks(
|
||||
getApp()->getAccounts()->twitch.getCurrent()->userId_,
|
||||
@@ -129,6 +130,7 @@ void TwitchAccount::loadBlocks()
|
||||
blockedUser.fromHelixBlock(block);
|
||||
this->ignores_.insert(blockedUser);
|
||||
this->ignoresUserIds_.insert(blockedUser.id);
|
||||
this->ignoresUserLogins_.insert(blockedUser.name);
|
||||
}
|
||||
},
|
||||
[](auto error) {
|
||||
@@ -138,51 +140,60 @@ void TwitchAccount::loadBlocks()
|
||||
std::move(token));
|
||||
}
|
||||
|
||||
void TwitchAccount::blockUser(const QString &userId, const QObject *caller,
|
||||
void TwitchAccount::blockUser(const QString &userId, const QString &userLogin,
|
||||
const QObject *caller,
|
||||
std::function<void()> onSuccess,
|
||||
std::function<void()> onFailure)
|
||||
{
|
||||
getHelix()->blockUser(
|
||||
userId, caller,
|
||||
[this, userId, onSuccess = std::move(onSuccess)] {
|
||||
[this, userId, userLogin, onSuccess = std::move(onSuccess)] {
|
||||
assertInGuiThread();
|
||||
|
||||
TwitchUser blockedUser;
|
||||
blockedUser.id = userId;
|
||||
blockedUser.name = userLogin;
|
||||
this->ignores_.insert(blockedUser);
|
||||
this->ignoresUserIds_.insert(blockedUser.id);
|
||||
this->ignoresUserLogins_.insert(blockedUser.name);
|
||||
onSuccess();
|
||||
},
|
||||
std::move(onFailure));
|
||||
}
|
||||
|
||||
void TwitchAccount::unblockUser(const QString &userId, const QObject *caller,
|
||||
void TwitchAccount::unblockUser(const QString &userId, const QString &userLogin,
|
||||
const QObject *caller,
|
||||
std::function<void()> onSuccess,
|
||||
std::function<void()> onFailure)
|
||||
{
|
||||
getHelix()->unblockUser(
|
||||
userId, caller,
|
||||
[this, userId, onSuccess = std::move(onSuccess)] {
|
||||
[this, userId, userLogin, onSuccess = std::move(onSuccess)] {
|
||||
assertInGuiThread();
|
||||
|
||||
TwitchUser ignoredUser;
|
||||
ignoredUser.id = userId;
|
||||
ignoredUser.name = userLogin;
|
||||
this->ignores_.erase(ignoredUser);
|
||||
this->ignoresUserIds_.erase(ignoredUser.id);
|
||||
this->ignoresUserLogins_.erase(ignoredUser.name);
|
||||
onSuccess();
|
||||
},
|
||||
std::move(onFailure));
|
||||
}
|
||||
|
||||
void TwitchAccount::blockUserLocally(const QString &userID)
|
||||
void TwitchAccount::blockUserLocally(const QString &userID,
|
||||
const QString &userLogin)
|
||||
{
|
||||
assertInGuiThread();
|
||||
assert(getApp()->isTest());
|
||||
|
||||
TwitchUser blockedUser;
|
||||
blockedUser.id = userID;
|
||||
blockedUser.name = userLogin;
|
||||
this->ignores_.insert(blockedUser);
|
||||
this->ignoresUserIds_.insert(blockedUser.id);
|
||||
this->ignoresUserLogins_.insert(blockedUser.name);
|
||||
}
|
||||
|
||||
const std::unordered_set<TwitchUser> &TwitchAccount::blocks() const
|
||||
@@ -197,6 +208,12 @@ const std::unordered_set<QString> &TwitchAccount::blockedUserIds() const
|
||||
return this->ignoresUserIds_;
|
||||
}
|
||||
|
||||
const std::unordered_set<QString> &TwitchAccount::blockedUserLogins() const
|
||||
{
|
||||
assertInGuiThread();
|
||||
return this->ignoresUserLogins_;
|
||||
}
|
||||
|
||||
// AutoModActions
|
||||
void TwitchAccount::autoModAllow(const QString msgID, ChannelPtr channel)
|
||||
{
|
||||
|
||||
@@ -64,17 +64,18 @@ public:
|
||||
bool isAnon() const;
|
||||
|
||||
void loadBlocks();
|
||||
void blockUser(const QString &userId, const QObject *caller,
|
||||
std::function<void()> onSuccess,
|
||||
void blockUser(const QString &userId, const QString &userLogin,
|
||||
const QObject *caller, std::function<void()> onSuccess,
|
||||
std::function<void()> onFailure);
|
||||
void unblockUser(const QString &userId, const QObject *caller,
|
||||
std::function<void()> onSuccess,
|
||||
void unblockUser(const QString &userId, const QString &userLogin,
|
||||
const QObject *caller, std::function<void()> onSuccess,
|
||||
std::function<void()> onFailure);
|
||||
|
||||
void blockUserLocally(const QString &userID);
|
||||
void blockUserLocally(const QString &userID, const QString &userLogin);
|
||||
|
||||
[[nodiscard]] const std::unordered_set<TwitchUser> &blocks() const;
|
||||
[[nodiscard]] const std::unordered_set<QString> &blockedUserIds() const;
|
||||
[[nodiscard]] const std::unordered_set<QString> &blockedUserLogins() const;
|
||||
|
||||
// Automod actions
|
||||
void autoModAllow(const QString msgID, ChannelPtr channel);
|
||||
@@ -120,6 +121,7 @@ private:
|
||||
ScopedCancellationToken blockToken_;
|
||||
std::unordered_set<TwitchUser> ignores_;
|
||||
std::unordered_set<QString> ignoresUserIds_;
|
||||
std::unordered_set<QString> ignoresUserLogins_;
|
||||
|
||||
ScopedCancellationToken emoteToken_;
|
||||
UniqueAccess<std::shared_ptr<const TwitchEmoteSetMap>> emoteSets_;
|
||||
|
||||
@@ -15,9 +15,15 @@ struct HelixBlock;
|
||||
struct HelixUser;
|
||||
|
||||
struct TwitchUser {
|
||||
/// The Twitch User ID (e.g. `117166826`)
|
||||
QString id;
|
||||
|
||||
/// The Twitch User Login (e.g. `testaccount_420`)
|
||||
mutable QString name;
|
||||
|
||||
// The Twitch User Display Name (e.g. `테스트계정420`)
|
||||
mutable QString displayName;
|
||||
|
||||
mutable QString profilePictureUrl;
|
||||
|
||||
void update(const TwitchUser &other) const
|
||||
|
||||
@@ -661,7 +661,7 @@ void UserInfoPopup::installEvents()
|
||||
this->ui_.block->setEnabled(false);
|
||||
|
||||
getApp()->getAccounts()->twitch.getCurrent()->unblockUser(
|
||||
this->userId_, this,
|
||||
this->userId_, this->userName_, this,
|
||||
[this, reenableBlockCheckbox, currentUser] {
|
||||
this->channel_->addSystemMessage(
|
||||
QString("You successfully unblocked user %1")
|
||||
@@ -702,7 +702,7 @@ void UserInfoPopup::installEvents()
|
||||
}
|
||||
|
||||
getApp()->getAccounts()->twitch.getCurrent()->blockUser(
|
||||
this->userId_, this,
|
||||
this->userId_, this->userName_, this,
|
||||
[this, reenableBlockCheckbox, currentUser] {
|
||||
this->channel_->addSystemMessage(
|
||||
QString("You successfully blocked user %1")
|
||||
|
||||
@@ -469,7 +469,7 @@ public:
|
||||
|
||||
this->mockApplication->getAccounts()
|
||||
->twitch.getCurrent()
|
||||
->blockUserLocally(u"12345"_s);
|
||||
->blockUserLocally(u"12345"_s, u"blocked"_s);
|
||||
|
||||
auto makeBadge = [](QStringView platform) {
|
||||
return std::make_shared<Emote>(Emote{
|
||||
|
||||
Reference in New Issue
Block a user