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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Channel::isBroadcaster() const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
std::shared_ptr<Channel> Channel::getEmpty()
|
std::shared_ptr<Channel> Channel::getEmpty()
|
||||||
{
|
{
|
||||||
static std::shared_ptr<Channel> channel(new Channel("", None));
|
static std::shared_ptr<Channel> channel(new Channel("", None));
|
||||||
|
|
|
@ -60,6 +60,7 @@ public:
|
||||||
virtual bool canSendMessage() const;
|
virtual bool canSendMessage() const;
|
||||||
virtual void sendMessage(const QString &message);
|
virtual void sendMessage(const QString &message);
|
||||||
virtual bool isMod() const;
|
virtual bool isMod() const;
|
||||||
|
virtual bool isBroadcaster() const;
|
||||||
|
|
||||||
static std::shared_ptr<Channel> getEmpty();
|
static std::shared_ptr<Channel> getEmpty();
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ struct MessageParseArgs {
|
||||||
bool isReceivedWhisper = false;
|
bool isReceivedWhisper = false;
|
||||||
bool isSentWhisper = false;
|
bool isSentWhisper = false;
|
||||||
bool trimSubscriberUsername = false;
|
bool trimSubscriberUsername = false;
|
||||||
|
bool isStaffOrBroadcaster = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace messages
|
} // namespace messages
|
||||||
|
|
|
@ -54,6 +54,10 @@ void IrcMessageHandler::addMessage(Communi::IrcMessage *_message, const QString
|
||||||
args.trimSubscriberUsername = true;
|
args.trimSubscriberUsername = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (chan->isBroadcaster()) {
|
||||||
|
args.isStaffOrBroadcaster = true;
|
||||||
|
}
|
||||||
|
|
||||||
TwitchMessageBuilder builder(chan.get(), _message, args, content, isAction);
|
TwitchMessageBuilder builder(chan.get(), _message, args, content, isAction);
|
||||||
|
|
||||||
if (isSub || !builder.isIgnored()) {
|
if (isSub || !builder.isIgnored()) {
|
||||||
|
|
|
@ -182,7 +182,7 @@ void TwitchChannel::setMod(bool value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TwitchChannel::isBroadcaster()
|
bool TwitchChannel::isBroadcaster() const
|
||||||
{
|
{
|
||||||
auto app = getApp();
|
auto app = getApp();
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ public:
|
||||||
|
|
||||||
bool isMod() const override;
|
bool isMod() const override;
|
||||||
void setMod(bool value);
|
void setMod(bool value);
|
||||||
bool isBroadcaster();
|
bool isBroadcaster() const override;
|
||||||
bool hasModRights();
|
bool hasModRights();
|
||||||
|
|
||||||
void addRecentChatter(const std::shared_ptr<messages::Message> &message) final;
|
void addRecentChatter(const std::shared_ptr<messages::Message> &message) final;
|
||||||
|
|
|
@ -99,6 +99,10 @@ MessagePtr TwitchMessageBuilder::build()
|
||||||
// PARSING
|
// PARSING
|
||||||
this->parseUsername();
|
this->parseUsername();
|
||||||
|
|
||||||
|
if (this->userName == this->channel->name) {
|
||||||
|
this->senderIsBroadcaster = true;
|
||||||
|
}
|
||||||
|
|
||||||
//#ifdef XD
|
//#ifdef XD
|
||||||
// if (this->originalMessage.length() > 100) {
|
// if (this->originalMessage.length() > 100) {
|
||||||
// this->message->flags |= Message::Collapsed;
|
// this->message->flags |= Message::Collapsed;
|
||||||
|
@ -126,7 +130,25 @@ MessagePtr TwitchMessageBuilder::build()
|
||||||
this->emplace<TimestampElement>();
|
this->emplace<TimestampElement>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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->emplace<TwitchModerationElement>();
|
||||||
|
}
|
||||||
|
|
||||||
this->appendTwitchBadges();
|
this->appendTwitchBadges();
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,7 @@ private:
|
||||||
|
|
||||||
QColor usernameColor;
|
QColor usernameColor;
|
||||||
const QString originalMessage;
|
const QString originalMessage;
|
||||||
|
bool senderIsBroadcaster{};
|
||||||
|
|
||||||
const bool action = false;
|
const bool action = false;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue