mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
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:
parent
75458a1a25
commit
d5ecba3d30
2 changed files with 21 additions and 23 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue