Rewrite logic for when to show moderation buttons next to messages (#2800)
Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
@@ -184,29 +184,7 @@ MessagePtr TwitchMessageBuilder::build()
|
||||
this->emplace<TimestampElement>(
|
||||
calculateMessageTimestamp(this->ircMessage));
|
||||
|
||||
bool addModerationElement = true;
|
||||
if (this->senderIsBroadcaster)
|
||||
{
|
||||
addModerationElement = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
bool hasUserType = this->tags.contains("user-type");
|
||||
if (hasUserType)
|
||||
{
|
||||
QString userType = this->tags.value("user-type").toString();
|
||||
|
||||
if (userType == "mod")
|
||||
{
|
||||
if (!args.isStaffOrBroadcaster)
|
||||
{
|
||||
addModerationElement = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (addModerationElement)
|
||||
if (this->shouldAddModerationElements())
|
||||
{
|
||||
this->emplace<TwitchModerationElement>();
|
||||
}
|
||||
@@ -1230,6 +1208,24 @@ Outcome TwitchMessageBuilder::tryParseCheermote(const QString &string)
|
||||
return Success;
|
||||
}
|
||||
|
||||
bool TwitchMessageBuilder::shouldAddModerationElements() const
|
||||
{
|
||||
if (this->senderIsBroadcaster)
|
||||
{
|
||||
// You cannot timeout the broadcaster
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this->tags.value("user-type").toString() == "mod" &&
|
||||
!this->args.isStaffOrBroadcaster)
|
||||
{
|
||||
// You cannot timeout moderators UNLESS you are Twitch Staff or the broadcaster of the channel
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void TwitchMessageBuilder::appendChannelPointRewardMessage(
|
||||
const ChannelPointReward &reward, MessageBuilder *builder, bool isMod,
|
||||
bool isBroadcaster)
|
||||
|
||||
@@ -90,6 +90,8 @@ private:
|
||||
void appendFfzBadges();
|
||||
Outcome tryParseCheermote(const QString &string);
|
||||
|
||||
bool shouldAddModerationElements() const;
|
||||
|
||||
QString roomID_;
|
||||
bool hasBits_ = false;
|
||||
QString bits;
|
||||
|
||||
Reference in New Issue
Block a user