fix: don't include blocked users in join/part messages (#6181)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user