Stop moderation elements from appearing on other moderators messages

Fix #496
This commit is contained in:
Rasmus Karlsson 2018-06-22 21:19:52 +00:00
parent 2746f88e49
commit dd0d6a0f88
8 changed files with 37 additions and 3 deletions

View file

@ -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));

View file

@ -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();

View file

@ -8,6 +8,7 @@ struct MessageParseArgs {
bool isReceivedWhisper = false;
bool isSentWhisper = false;
bool trimSubscriberUsername = false;
bool isStaffOrBroadcaster = false;
};
} // namespace messages

View file

@ -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()) {

View file

@ -182,7 +182,7 @@ void TwitchChannel::setMod(bool value)
}
}
bool TwitchChannel::isBroadcaster()
bool TwitchChannel::isBroadcaster() const
{
auto app = getApp();

View file

@ -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;

View file

@ -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();

View file

@ -50,6 +50,7 @@ private:
QColor usernameColor;
const QString originalMessage;
bool senderIsBroadcaster{};
const bool action = false;