mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Stop moderation elements from appearing on other moderators messages
Fix #496
This commit is contained in:
parent
2746f88e49
commit
dd0d6a0f88
8 changed files with 37 additions and 3 deletions
|
@ -187,6 +187,11 @@ bool Channel::isMod() const
|
|||
return false;
|
||||
}
|
||||
|
||||
bool Channel::isBroadcaster() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
std::shared_ptr<Channel> Channel::getEmpty()
|
||||
{
|
||||
static std::shared_ptr<Channel> channel(new Channel("", None));
|
||||
|
|
|
@ -60,6 +60,7 @@ public:
|
|||
virtual bool canSendMessage() const;
|
||||
virtual void sendMessage(const QString &message);
|
||||
virtual bool isMod() const;
|
||||
virtual bool isBroadcaster() const;
|
||||
|
||||
static std::shared_ptr<Channel> getEmpty();
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ struct MessageParseArgs {
|
|||
bool isReceivedWhisper = false;
|
||||
bool isSentWhisper = false;
|
||||
bool trimSubscriberUsername = false;
|
||||
bool isStaffOrBroadcaster = false;
|
||||
};
|
||||
|
||||
} // namespace messages
|
||||
|
|
|
@ -54,6 +54,10 @@ void IrcMessageHandler::addMessage(Communi::IrcMessage *_message, const QString
|
|||
args.trimSubscriberUsername = true;
|
||||
}
|
||||
|
||||
if (chan->isBroadcaster()) {
|
||||
args.isStaffOrBroadcaster = true;
|
||||
}
|
||||
|
||||
TwitchMessageBuilder builder(chan.get(), _message, args, content, isAction);
|
||||
|
||||
if (isSub || !builder.isIgnored()) {
|
||||
|
|
|
@ -182,7 +182,7 @@ void TwitchChannel::setMod(bool value)
|
|||
}
|
||||
}
|
||||
|
||||
bool TwitchChannel::isBroadcaster()
|
||||
bool TwitchChannel::isBroadcaster() const
|
||||
{
|
||||
auto app = getApp();
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ public:
|
|||
|
||||
bool isMod() const override;
|
||||
void setMod(bool value);
|
||||
bool isBroadcaster();
|
||||
bool isBroadcaster() const override;
|
||||
bool hasModRights();
|
||||
|
||||
void addRecentChatter(const std::shared_ptr<messages::Message> &message) final;
|
||||
|
|
|
@ -99,6 +99,10 @@ MessagePtr TwitchMessageBuilder::build()
|
|||
// PARSING
|
||||
this->parseUsername();
|
||||
|
||||
if (this->userName == this->channel->name) {
|
||||
this->senderIsBroadcaster = true;
|
||||
}
|
||||
|
||||
//#ifdef XD
|
||||
// if (this->originalMessage.length() > 100) {
|
||||
// this->message->flags |= Message::Collapsed;
|
||||
|
@ -126,7 +130,25 @@ MessagePtr TwitchMessageBuilder::build()
|
|||
this->emplace<TimestampElement>();
|
||||
}
|
||||
|
||||
this->emplace<TwitchModerationElement>();
|
||||
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) {
|
||||
this->emplace<TwitchModerationElement>();
|
||||
}
|
||||
|
||||
this->appendTwitchBadges();
|
||||
|
||||
|
|
|
@ -50,6 +50,7 @@ private:
|
|||
|
||||
QColor usernameColor;
|
||||
const QString originalMessage;
|
||||
bool senderIsBroadcaster{};
|
||||
|
||||
const bool action = false;
|
||||
|
||||
|
|
Loading…
Reference in a new issue