mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Add extra context to messages that are added to channels, allowing the logging controller to take more responsibility in what messages to log (#5499)
Co-auhtored-by: James Upjohn <jupjohn@jammeh.co.nz>
This commit is contained in:
parent
49de421bd8
commit
973b7a3bdd
26 changed files with 163 additions and 139 deletions
|
@ -26,6 +26,7 @@
|
|||
- Bugfix: Fixed message history occasionally not loading after a sleep. (#5457)
|
||||
- Bugfix: Fixed a crash when tab completing while having an invalid plugin loaded. (#5401)
|
||||
- Bugfix: Fixed windows on Windows not saving correctly when snapping them to the edges. (#5478)
|
||||
- Bugfix: Fixed user info card popups adding duplicate line to log files. (#5499)
|
||||
- Bugfix: Fixed `/clearmessages` not working with more than one window. (#5489)
|
||||
- Bugfix: Fixed splits staying paused after unfocusing Chatterino in certain configurations. (#5504)
|
||||
- Dev: Update Windows build from Qt 6.5.0 to Qt 6.7.1. (#5420)
|
||||
|
|
|
@ -664,7 +664,7 @@ void Application::initPubSub()
|
|||
postToThread([chan, action] {
|
||||
MessageBuilder msg(action);
|
||||
msg->flags.set(MessageFlag::PubSub);
|
||||
chan->addMessage(msg.release());
|
||||
chan->addMessage(msg.release(), MessageContext::Original);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -703,7 +703,7 @@ void Application::initPubSub()
|
|||
}
|
||||
if (!replaced)
|
||||
{
|
||||
chan->addMessage(msg);
|
||||
chan->addMessage(msg, MessageContext::Original);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -720,7 +720,7 @@ void Application::initPubSub()
|
|||
auto msg = MessageBuilder(action).release();
|
||||
|
||||
postToThread([chan, msg] {
|
||||
chan->addMessage(msg);
|
||||
chan->addMessage(msg, MessageContext::Original);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -770,8 +770,10 @@ void Application::initPubSub()
|
|||
TwitchMessageBuilder::makeLowTrustUserMessage(
|
||||
action, twitchChannel->getName(),
|
||||
twitchChannel.get());
|
||||
twitchChannel->addMessage(p.first);
|
||||
twitchChannel->addMessage(p.second);
|
||||
twitchChannel->addMessage(p.first,
|
||||
MessageContext::Original);
|
||||
twitchChannel->addMessage(p.second,
|
||||
MessageContext::Original);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -809,7 +811,7 @@ void Application::initPubSub()
|
|||
postToThread([chan, action] {
|
||||
auto msg =
|
||||
TwitchMessageBuilder::makeLowTrustUpdateMessage(action);
|
||||
chan->addMessage(msg);
|
||||
chan->addMessage(msg, MessageContext::Original);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -891,28 +893,32 @@ void Application::initPubSub()
|
|||
const auto p =
|
||||
TwitchMessageBuilder::makeAutomodMessage(
|
||||
action, chan->getName());
|
||||
chan->addMessage(p.first);
|
||||
chan->addMessage(p.second);
|
||||
chan->addMessage(p.first, MessageContext::Original);
|
||||
chan->addMessage(p.second,
|
||||
MessageContext::Original);
|
||||
|
||||
getIApp()
|
||||
->getTwitch()
|
||||
->getAutomodChannel()
|
||||
->addMessage(p.first);
|
||||
->addMessage(p.first, MessageContext::Original);
|
||||
getIApp()
|
||||
->getTwitch()
|
||||
->getAutomodChannel()
|
||||
->addMessage(p.second);
|
||||
->addMessage(p.second,
|
||||
MessageContext::Original);
|
||||
|
||||
if (getSettings()->showAutomodInMentions)
|
||||
{
|
||||
getIApp()
|
||||
->getTwitch()
|
||||
->getMentionsChannel()
|
||||
->addMessage(p.first);
|
||||
->addMessage(p.first,
|
||||
MessageContext::Original);
|
||||
getIApp()
|
||||
->getTwitch()
|
||||
->getMentionsChannel()
|
||||
->addMessage(p.second);
|
||||
->addMessage(p.second,
|
||||
MessageContext::Original);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -939,8 +945,8 @@ void Application::initPubSub()
|
|||
postToThread([chan, action] {
|
||||
const auto p = TwitchMessageBuilder::makeAutomodMessage(
|
||||
action, chan->getName());
|
||||
chan->addMessage(p.first);
|
||||
chan->addMessage(p.second);
|
||||
chan->addMessage(p.first, MessageContext::Original);
|
||||
chan->addMessage(p.second, MessageContext::Original);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -961,7 +967,7 @@ void Application::initPubSub()
|
|||
auto msg = MessageBuilder(action).release();
|
||||
|
||||
postToThread([chan, msg] {
|
||||
chan->addMessage(msg);
|
||||
chan->addMessage(msg, MessageContext::Original);
|
||||
});
|
||||
chan->deleteMessage(msg->id);
|
||||
});
|
||||
|
@ -978,7 +984,7 @@ void Application::initPubSub()
|
|||
postToThread([chan, action] {
|
||||
const auto p =
|
||||
TwitchMessageBuilder::makeAutomodInfoMessage(action);
|
||||
chan->addMessage(p);
|
||||
chan->addMessage(p, MessageContext::Original);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -32,6 +32,12 @@ Channel::Channel(const QString &name, Type type)
|
|||
, messages_(getSettings()->scrollbackSplitLimit)
|
||||
, type_(type)
|
||||
{
|
||||
if (this->isTwitchChannel())
|
||||
{
|
||||
this->platform_ = "twitch";
|
||||
}
|
||||
|
||||
// Irc platform is set through IrcChannel2 ctor
|
||||
}
|
||||
|
||||
Channel::~Channel()
|
||||
|
@ -79,37 +85,24 @@ LimitedQueueSnapshot<MessagePtr> Channel::getMessageSnapshot()
|
|||
return this->messages_.getSnapshot();
|
||||
}
|
||||
|
||||
void Channel::addMessage(MessagePtr message,
|
||||
void Channel::addMessage(MessagePtr message, MessageContext context,
|
||||
std::optional<MessageFlags> overridingFlags)
|
||||
{
|
||||
MessagePtr deleted;
|
||||
|
||||
if (!overridingFlags || !overridingFlags->has(MessageFlag::DoNotLog))
|
||||
if (context == MessageContext::Original)
|
||||
{
|
||||
QString channelPlatform("other");
|
||||
if (this->type_ == Type::Irc)
|
||||
// Only log original messages
|
||||
auto isDoNotLogSet =
|
||||
(overridingFlags && overridingFlags->has(MessageFlag::DoNotLog)) ||
|
||||
message->flags.has(MessageFlag::DoNotLog);
|
||||
|
||||
if (!isDoNotLogSet)
|
||||
{
|
||||
auto *irc = dynamic_cast<IrcChannel *>(this);
|
||||
if (irc != nullptr)
|
||||
{
|
||||
auto *ircServer = irc->server();
|
||||
if (ircServer != nullptr)
|
||||
{
|
||||
channelPlatform = QString("irc-%1").arg(
|
||||
irc->server()->userFriendlyIdentifier());
|
||||
}
|
||||
else
|
||||
{
|
||||
channelPlatform = "irc-unknown";
|
||||
}
|
||||
}
|
||||
// Only log messages where the `DoNotLog` flag is not set
|
||||
getIApp()->getChatLogger()->addMessage(this->name_, message,
|
||||
this->platform_);
|
||||
}
|
||||
else if (this->isTwitchChannel())
|
||||
{
|
||||
channelPlatform = "twitch";
|
||||
}
|
||||
getIApp()->getChatLogger()->addMessage(this->name_, message,
|
||||
channelPlatform);
|
||||
}
|
||||
|
||||
if (this->messages_.pushBack(message, deleted))
|
||||
|
@ -123,7 +116,7 @@ void Channel::addMessage(MessagePtr message,
|
|||
void Channel::addSystemMessage(const QString &contents)
|
||||
{
|
||||
auto msg = makeSystemMessage(contents);
|
||||
this->addMessage(msg);
|
||||
this->addMessage(msg, MessageContext::Original);
|
||||
}
|
||||
|
||||
void Channel::addOrReplaceTimeout(MessagePtr message)
|
||||
|
@ -134,7 +127,7 @@ void Channel::addOrReplaceTimeout(MessagePtr message)
|
|||
this->replaceMessage(msg, replacement);
|
||||
},
|
||||
[this](auto msg) {
|
||||
this->addMessage(msg);
|
||||
this->addMessage(msg, MessageContext::Original);
|
||||
},
|
||||
true);
|
||||
|
||||
|
|
|
@ -28,6 +28,14 @@ enum class TimeoutStackStyle : int {
|
|||
Default = DontStackBeyondUserMessage,
|
||||
};
|
||||
|
||||
/// Context of the message being added to a channel
|
||||
enum class MessageContext {
|
||||
/// This message is the original
|
||||
Original,
|
||||
/// This message is a repost of a message that has already been added in a channel
|
||||
Repost,
|
||||
};
|
||||
|
||||
class Channel : public std::enable_shared_from_this<Channel>
|
||||
{
|
||||
public:
|
||||
|
@ -79,7 +87,7 @@ public:
|
|||
// overridingFlags can be filled in with flags that should be used instead
|
||||
// of the message's flags. This is useful in case a flag is specific to a
|
||||
// type of split
|
||||
void addMessage(MessagePtr message,
|
||||
void addMessage(MessagePtr message, MessageContext context,
|
||||
std::optional<MessageFlags> overridingFlags = std::nullopt);
|
||||
void addMessagesAtStart(const std::vector<MessagePtr> &messages_);
|
||||
|
||||
|
@ -120,6 +128,7 @@ public:
|
|||
protected:
|
||||
virtual void onConnected();
|
||||
virtual void messageRemovedFromStart(const MessagePtr &msg);
|
||||
QString platform_{"other"};
|
||||
|
||||
private:
|
||||
const QString name_;
|
||||
|
|
|
@ -43,7 +43,8 @@ void ChannelChatters::addJoinedUser(const QString &user)
|
|||
TwitchMessageBuilder::listOfUsersSystemMessage(
|
||||
"Users joined:", *joinedUsers, &this->channel_, &builder);
|
||||
builder->flags.set(MessageFlag::Collapsed);
|
||||
this->channel_.addMessage(builder.release());
|
||||
this->channel_.addMessage(builder.release(),
|
||||
MessageContext::Original);
|
||||
|
||||
joinedUsers->clear();
|
||||
this->joinedUsersMergeQueued_ = false;
|
||||
|
@ -68,7 +69,8 @@ void ChannelChatters::addPartedUser(const QString &user)
|
|||
TwitchMessageBuilder::listOfUsersSystemMessage(
|
||||
"Users parted:", *partedUsers, &this->channel_, &builder);
|
||||
builder->flags.set(MessageFlag::Collapsed);
|
||||
this->channel_.addMessage(builder.release());
|
||||
this->channel_.addMessage(builder.release(),
|
||||
MessageContext::Original);
|
||||
|
||||
partedUsers->clear();
|
||||
this->partedUsersMergeQueued_ = false;
|
||||
|
|
|
@ -90,7 +90,7 @@ QString listEnvironmentVariables(const CommandContext &ctx)
|
|||
builder.emplace<TimestampElement>(QTime::currentTime());
|
||||
builder.emplace<TextElement>(str, MessageElementFlag::Text,
|
||||
MessageColor::System);
|
||||
channel->addMessage(builder.release());
|
||||
channel->addMessage(builder.release(), MessageContext::Original);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
|
|
@ -129,7 +129,7 @@ QString testChatters(const CommandContext &ctx)
|
|||
TwitchMessageBuilder::listOfUsersSystemMessage(
|
||||
prefix, entries, twitchChannel, &builder);
|
||||
|
||||
channel->addMessage(builder.release());
|
||||
channel->addMessage(builder.release(), MessageContext::Original);
|
||||
},
|
||||
[channel{ctx.channel}](auto error, auto message) {
|
||||
auto errorMessage = formatChattersError(error, message);
|
||||
|
|
|
@ -81,7 +81,7 @@ QString getModerators(const CommandContext &ctx)
|
|||
TwitchMessageBuilder::listOfUsersSystemMessage(
|
||||
"The moderators of this channel are", result, twitchChannel,
|
||||
&builder);
|
||||
channel->addMessage(builder.release());
|
||||
channel->addMessage(builder.release(), MessageContext::Original);
|
||||
},
|
||||
[channel{ctx.channel}](auto error, auto message) {
|
||||
auto errorMessage = formatModsError(error, message);
|
||||
|
|
|
@ -110,7 +110,7 @@ QString getVIPs(const CommandContext &ctx)
|
|||
TwitchMessageBuilder::listOfUsersSystemMessage(
|
||||
messagePrefix, vipList, twitchChannel, &builder);
|
||||
|
||||
channel->addMessage(builder.release());
|
||||
channel->addMessage(builder.release(), MessageContext::Original);
|
||||
},
|
||||
[channel{ctx.channel}](auto error, auto message) {
|
||||
auto errorMessage = formatGetVIPsError(error, message);
|
||||
|
|
|
@ -177,18 +177,16 @@ bool appendWhisperMessageWordsLocally(const QStringList &words)
|
|||
b->flags.set(MessageFlag::Whisper);
|
||||
auto messagexD = b.release();
|
||||
|
||||
getIApp()->getTwitch()->getWhispersChannel()->addMessage(messagexD);
|
||||
|
||||
auto overrideFlags = std::optional<MessageFlags>(messagexD->flags);
|
||||
overrideFlags->set(MessageFlag::DoNotLog);
|
||||
getIApp()->getTwitch()->getWhispersChannel()->addMessage(
|
||||
messagexD, MessageContext::Original);
|
||||
|
||||
if (getSettings()->inlineWhispers &&
|
||||
!(getSettings()->streamerModeSuppressInlineWhispers &&
|
||||
getIApp()->getStreamerMode()->isEnabled()))
|
||||
{
|
||||
app->getTwitchAbstract()->forEachChannel(
|
||||
[&messagexD, overrideFlags](ChannelPtr _channel) {
|
||||
_channel->addMessage(messagexD, overrideFlags);
|
||||
[&messagexD](ChannelPtr _channel) {
|
||||
_channel->addMessage(messagexD, MessageContext::Repost);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -202,7 +202,8 @@ void NotificationController::checkStream(bool live, QString channelName)
|
|||
}
|
||||
MessageBuilder builder;
|
||||
TwitchMessageBuilder::liveMessage(channelName, &builder);
|
||||
getIApp()->getTwitch()->getLiveChannel()->addMessage(builder.release());
|
||||
getIApp()->getTwitch()->getLiveChannel()->addMessage(
|
||||
builder.release(), MessageContext::Original);
|
||||
|
||||
// Indicate that we have pushed notifications for this stream
|
||||
fakeTwitchChannels.push_back(channelName);
|
||||
|
|
|
@ -380,8 +380,8 @@ QString PluginController::tryExecPluginCommand(const QString &commandName,
|
|||
auto res = lua_pcall(L, 1, 0, 0);
|
||||
if (res != LUA_OK)
|
||||
{
|
||||
ctx.channel->addMessage(makeSystemMessage(
|
||||
"Lua error: " + lua::humanErrorText(L, res)));
|
||||
ctx.channel->addSystemMessage("Lua error: " +
|
||||
lua::humanErrorText(L, res));
|
||||
return "";
|
||||
}
|
||||
return "";
|
||||
|
|
|
@ -200,7 +200,7 @@ int ChannelRef::add_system_message(lua_State *L)
|
|||
}
|
||||
ChannelPtr that = ChannelRef::getOrError(L);
|
||||
text = text.replace('\n', ' ');
|
||||
that->addMessage(makeSystemMessage(text));
|
||||
that->addSystemMessage(text);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -156,7 +156,7 @@ void AbstractIrcServer::addGlobalSystemMessage(const QString &messageText)
|
|||
continue;
|
||||
}
|
||||
|
||||
chan->addMessage(message);
|
||||
chan->addMessage(message, MessageContext::Original);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -329,7 +329,7 @@ void AbstractIrcServer::onReadConnected(IrcConnection *connection)
|
|||
}
|
||||
else
|
||||
{
|
||||
chan->addMessage(connectedMsg);
|
||||
chan->addMessage(connectedMsg, MessageContext::Original);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -357,7 +357,7 @@ void AbstractIrcServer::onDisconnected()
|
|||
continue;
|
||||
}
|
||||
|
||||
chan->addMessage(disconnectedMsg);
|
||||
chan->addMessage(disconnectedMsg, MessageContext::Original);
|
||||
|
||||
if (auto *channel = dynamic_cast<TwitchChannel *>(chan.get()))
|
||||
{
|
||||
|
|
|
@ -17,6 +17,16 @@ IrcChannel::IrcChannel(const QString &name, IrcServer *server)
|
|||
, ChannelChatters(*static_cast<Channel *>(this))
|
||||
, server_(server)
|
||||
{
|
||||
auto *ircServer = this->server();
|
||||
if (ircServer != nullptr)
|
||||
{
|
||||
this->platform_ =
|
||||
QString("irc-%1").arg(ircServer->userFriendlyIdentifier());
|
||||
}
|
||||
else
|
||||
{
|
||||
this->platform_ = "irc-unknown";
|
||||
}
|
||||
}
|
||||
|
||||
void IrcChannel::sendMessage(const QString &message)
|
||||
|
@ -70,7 +80,7 @@ void IrcChannel::sendMessage(const QString &message)
|
|||
builder.message().messageText = message;
|
||||
builder.message().searchText = username + ": " + message;
|
||||
|
||||
this->addMessage(builder.release());
|
||||
this->addMessage(builder.release(), MessageContext::Original);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -79,7 +89,7 @@ void IrcChannel::sendMessage(const QString &message)
|
|||
}
|
||||
}
|
||||
|
||||
IrcServer *IrcChannel::server()
|
||||
IrcServer *IrcChannel::server() const
|
||||
{
|
||||
assertInGuiThread();
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ public:
|
|||
void sendMessage(const QString &message) override;
|
||||
|
||||
// server may be nullptr
|
||||
IrcServer *server();
|
||||
IrcServer *server() const;
|
||||
|
||||
// Channel methods
|
||||
bool canReconnect() const override;
|
||||
|
|
|
@ -111,7 +111,8 @@ void IrcServer::initializeConnectionSignals(IrcConnection *connection,
|
|||
{
|
||||
if (auto shared = weak.lock())
|
||||
{
|
||||
shared->addMessage(msg);
|
||||
shared->addMessage(msg,
|
||||
MessageContext::Original);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -218,7 +219,7 @@ void IrcServer::privateMessageReceived(Communi::IrcPrivateMessage *message)
|
|||
{
|
||||
if (auto shared = weak.lock())
|
||||
{
|
||||
shared->addMessage(msg);
|
||||
shared->addMessage(msg, MessageContext::Original);
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
@ -236,7 +237,7 @@ void IrcServer::privateMessageReceived(Communi::IrcPrivateMessage *message)
|
|||
{
|
||||
auto msg = builder.build();
|
||||
|
||||
channel->addMessage(msg);
|
||||
channel->addMessage(msg, MessageContext::Original);
|
||||
builder.triggerHighlights();
|
||||
const auto highlighted = msg->flags.has(MessageFlag::Highlighted);
|
||||
const auto showInMentions =
|
||||
|
@ -244,7 +245,8 @@ void IrcServer::privateMessageReceived(Communi::IrcPrivateMessage *message)
|
|||
|
||||
if (highlighted && showInMentions)
|
||||
{
|
||||
getIApp()->getTwitch()->getMentionsChannel()->addMessage(msg);
|
||||
getIApp()->getTwitch()->getMentionsChannel()->addMessage(
|
||||
msg, MessageContext::Original);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -332,7 +334,7 @@ void IrcServer::readConnectionMessageReceived(Communi::IrcMessage *message)
|
|||
{
|
||||
if (auto shared = weak.lock())
|
||||
{
|
||||
shared->addMessage(msg);
|
||||
shared->addMessage(msg, MessageContext::Original);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -366,7 +368,7 @@ void IrcServer::sendWhisper(const QString &target, const QString &message)
|
|||
{
|
||||
if (auto shared = weak.lock())
|
||||
{
|
||||
shared->addMessage(msg);
|
||||
shared->addMessage(msg, MessageContext::Original);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -721,7 +721,7 @@ void IrcMessageHandler::handlePrivMessage(Communi::IrcPrivateMessage *message,
|
|||
auto ptr = TwitchMessageBuilder::buildHypeChatMessage(message);
|
||||
if (ptr)
|
||||
{
|
||||
chan->addMessage(ptr);
|
||||
chan->addMessage(ptr, MessageContext::Original);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -812,7 +812,8 @@ void IrcMessageHandler::handleClearChatMessage(Communi::IrcMessage *message)
|
|||
if (clearChat.disableAllMessages)
|
||||
{
|
||||
chan->disableAllMessages();
|
||||
chan->addMessage(std::move(clearChat.message));
|
||||
chan->addMessage(std::move(clearChat.message),
|
||||
MessageContext::Original);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -868,7 +869,7 @@ void IrcMessageHandler::handleClearMessageMessage(Communi::IrcMessage *message)
|
|||
{
|
||||
MessageBuilder builder;
|
||||
TwitchMessageBuilder::deletionMessage(msg, &builder);
|
||||
chan->addMessage(builder.release());
|
||||
chan->addMessage(builder.release(), MessageContext::Original);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -966,10 +967,11 @@ void IrcMessageHandler::handleWhisperMessage(Communi::IrcMessage *ircMessage)
|
|||
|
||||
if (message->flags.has(MessageFlag::ShowInMentions))
|
||||
{
|
||||
getIApp()->getTwitch()->getMentionsChannel()->addMessage(message);
|
||||
getIApp()->getTwitch()->getMentionsChannel()->addMessage(
|
||||
message, MessageContext::Original);
|
||||
}
|
||||
|
||||
c->addMessage(message);
|
||||
c->addMessage(message, MessageContext::Original);
|
||||
|
||||
auto overrideFlags = std::optional<MessageFlags>(message->flags);
|
||||
overrideFlags->set(MessageFlag::DoNotTriggerNotification);
|
||||
|
@ -981,7 +983,8 @@ void IrcMessageHandler::handleWhisperMessage(Communi::IrcMessage *ircMessage)
|
|||
{
|
||||
getIApp()->getTwitchAbstract()->forEachChannel(
|
||||
[&message, overrideFlags](ChannelPtr channel) {
|
||||
channel->addMessage(message, overrideFlags);
|
||||
channel->addMessage(message, MessageContext::Repost,
|
||||
overrideFlags);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1098,7 +1101,7 @@ void IrcMessageHandler::handleUserNoticeMessage(
|
|||
|
||||
if (!chan->isEmpty())
|
||||
{
|
||||
chan->addMessage(newMessage);
|
||||
chan->addMessage(newMessage, MessageContext::Original);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1117,7 +1120,7 @@ void IrcMessageHandler::handleNoticeMessage(Communi::IrcNoticeMessage *message)
|
|||
// channels
|
||||
getIApp()->getTwitch()->forEachChannelAndSpecialChannels(
|
||||
[msg](const auto &c) {
|
||||
c->addMessage(msg);
|
||||
c->addMessage(msg, MessageContext::Original);
|
||||
});
|
||||
|
||||
return;
|
||||
|
@ -1167,7 +1170,7 @@ void IrcMessageHandler::handleNoticeMessage(Communi::IrcNoticeMessage *message)
|
|||
MessageBuilder builder;
|
||||
TwitchMessageBuilder::hostingSystemMessage(hostedChannelName,
|
||||
&builder, hostOn);
|
||||
channel->addMessage(builder.release());
|
||||
channel->addMessage(builder.release(), MessageContext::Original);
|
||||
}
|
||||
else if (tags == "room_mods" || tags == "vips_success")
|
||||
{
|
||||
|
@ -1196,11 +1199,11 @@ void IrcMessageHandler::handleNoticeMessage(Communi::IrcNoticeMessage *message)
|
|||
users.sort(Qt::CaseInsensitive);
|
||||
TwitchMessageBuilder::listOfUsersSystemMessage(msgParts.at(0),
|
||||
users, tc, &builder);
|
||||
channel->addMessage(builder.release());
|
||||
channel->addMessage(builder.release(), MessageContext::Original);
|
||||
}
|
||||
else
|
||||
{
|
||||
channel->addMessage(msg);
|
||||
channel->addMessage(msg, MessageContext::Original);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1249,7 +1252,8 @@ void IrcMessageHandler::handlePartMessage(Communi::IrcMessage *message)
|
|||
|
||||
if (message->nick() == selfAccountName)
|
||||
{
|
||||
channel->addMessage(generateBannedMessage(false));
|
||||
channel->addMessage(generateBannedMessage(false),
|
||||
MessageContext::Original);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1460,10 +1464,11 @@ void IrcMessageHandler::addMessage(Communi::IrcMessage *message,
|
|||
|
||||
if (highlighted && showInMentions)
|
||||
{
|
||||
server.getMentionsChannel()->addMessage(msg);
|
||||
server.getMentionsChannel()->addMessage(msg,
|
||||
MessageContext::Original);
|
||||
}
|
||||
|
||||
chan->addMessage(msg);
|
||||
chan->addMessage(msg, MessageContext::Original);
|
||||
if (auto *chatters = dynamic_cast<ChannelChatters *>(chan.get()))
|
||||
{
|
||||
chatters->addRecentChatter(msg->displayName);
|
||||
|
|
|
@ -161,7 +161,7 @@ TwitchChannel::TwitchChannel(const QString &name)
|
|||
TwitchMessageBuilder::liveSystemMessage(this->getDisplayName(),
|
||||
&builder);
|
||||
builder.message().id = this->roomId();
|
||||
this->addMessage(builder.release());
|
||||
this->addMessage(builder.release(), MessageContext::Original);
|
||||
|
||||
// Message in /live channel
|
||||
MessageBuilder builder2;
|
||||
|
@ -169,7 +169,7 @@ TwitchChannel::TwitchChannel(const QString &name)
|
|||
&builder2);
|
||||
builder2.message().id = this->roomId();
|
||||
getIApp()->getTwitch()->getLiveChannel()->addMessage(
|
||||
builder2.release());
|
||||
builder2.release(), MessageContext::Original);
|
||||
|
||||
// Notify on all channels with a ping sound
|
||||
if (getSettings()->notificationOnAnyChannel &&
|
||||
|
@ -187,7 +187,7 @@ TwitchChannel::TwitchChannel(const QString &name)
|
|||
MessageBuilder builder;
|
||||
TwitchMessageBuilder::offlineSystemMessage(this->getDisplayName(),
|
||||
&builder);
|
||||
this->addMessage(builder.release());
|
||||
this->addMessage(builder.release(), MessageContext::Original);
|
||||
|
||||
// "delete" old 'CHANNEL is live' message
|
||||
LimitedQueueSnapshot<MessagePtr> snapshot =
|
||||
|
@ -395,7 +395,7 @@ void TwitchChannel::addChannelPointReward(const ChannelPointReward &reward)
|
|||
MessageBuilder builder;
|
||||
TwitchMessageBuilder::appendChannelPointRewardMessage(
|
||||
reward, &builder, this->isMod(), this->isBroadcaster());
|
||||
this->addMessage(builder.release());
|
||||
this->addMessage(builder.release(), MessageContext::Original);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -566,7 +566,7 @@ void TwitchChannel::showLoginMessage()
|
|||
linkColor)
|
||||
->setLink(accountsLink);
|
||||
|
||||
this->addMessage(builder.release());
|
||||
this->addMessage(builder.release(), MessageContext::Original);
|
||||
}
|
||||
|
||||
void TwitchChannel::roomIdChanged()
|
||||
|
@ -925,7 +925,7 @@ void TwitchChannel::updateBttvEmote(
|
|||
auto builder = MessageBuilder(liveUpdatesUpdateEmoteMessage, "BTTV",
|
||||
QString() /* actor */, newEmote->name.string,
|
||||
oldEmote->name.string);
|
||||
this->addMessage(builder.release());
|
||||
this->addMessage(builder.release(), MessageContext::Original);
|
||||
}
|
||||
|
||||
void TwitchChannel::removeBttvEmote(
|
||||
|
@ -964,7 +964,7 @@ void TwitchChannel::updateSeventvEmote(
|
|||
auto builder =
|
||||
MessageBuilder(liveUpdatesUpdateEmoteMessage, "7TV", dispatch.actorName,
|
||||
dispatch.emoteName, dispatch.oldEmoteName);
|
||||
this->addMessage(builder.release());
|
||||
this->addMessage(builder.release(), MessageContext::Original);
|
||||
}
|
||||
|
||||
void TwitchChannel::removeSeventvEmote(
|
||||
|
@ -1002,7 +1002,8 @@ void TwitchChannel::updateSeventvUser(
|
|||
auto builder =
|
||||
MessageBuilder(liveUpdatesUpdateEmoteSetMessage, "7TV",
|
||||
dispatch.actorName, name);
|
||||
this->addMessage(builder.release());
|
||||
this->addMessage(builder.release(),
|
||||
MessageContext::Original);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
@ -1085,7 +1086,7 @@ void TwitchChannel::addOrReplaceLiveUpdatesAddRemove(bool isEmoteAdd,
|
|||
this->lastLiveUpdateEmotePlatform_ = platform;
|
||||
this->lastLiveUpdateMessage_ = msg;
|
||||
this->lastLiveUpdateEmoteActor_ = actor;
|
||||
this->addMessage(msg);
|
||||
this->addMessage(msg, MessageContext::Original);
|
||||
}
|
||||
|
||||
bool TwitchChannel::tryReplaceLastLiveUpdateAddOrRemove(
|
||||
|
@ -1650,7 +1651,7 @@ void TwitchChannel::createClip()
|
|||
MessageColor::Link)
|
||||
->setLink(Link(Link::Url, clip.editUrl));
|
||||
|
||||
this->addMessage(builder.release());
|
||||
this->addMessage(builder.release(), MessageContext::Original);
|
||||
},
|
||||
// failureCallback
|
||||
[this](auto error) {
|
||||
|
@ -1699,7 +1700,7 @@ void TwitchChannel::createClip()
|
|||
builder.message().messageText = text;
|
||||
builder.message().searchText = text;
|
||||
|
||||
this->addMessage(builder.release());
|
||||
this->addMessage(builder.release(), MessageContext::Original);
|
||||
},
|
||||
// finallyCallback - this will always execute, so clip creation won't ever be stuck
|
||||
[this] {
|
||||
|
|
|
@ -239,7 +239,7 @@ void ImageUploader::handleSuccessfulUpload(const NetworkResult &result,
|
|||
auto timeToUpload = this->uploadQueue_.size() * (UPLOAD_DELAY / 1000 + 1);
|
||||
MessageBuilder builder(imageUploaderResultMessage, link, deletionLink,
|
||||
this->uploadQueue_.size(), timeToUpload);
|
||||
channel->addMessage(builder.release());
|
||||
channel->addMessage(builder.release(), MessageContext::Original);
|
||||
if (this->uploadQueue_.empty())
|
||||
{
|
||||
this->uploadMutex_.unlock();
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "singletons/Logging.hpp"
|
||||
|
||||
#include "messages/Message.hpp"
|
||||
#include "singletons/helper/LoggingChannel.hpp"
|
||||
#include "singletons/Paths.hpp"
|
||||
#include "singletons/Settings.hpp"
|
||||
|
|
|
@ -145,7 +145,7 @@ void addTwitchEmoteSets(
|
|||
auto currentChannelPair = mapOfSets[currentChannelName];
|
||||
for (const auto &message : currentChannelPair.second)
|
||||
{
|
||||
subChannel.addMessage(message);
|
||||
subChannel.addMessage(message, MessageContext::Original);
|
||||
}
|
||||
mapOfSets.remove(currentChannelName);
|
||||
|
||||
|
@ -154,7 +154,7 @@ void addTwitchEmoteSets(
|
|||
auto &channel = pair.first ? globalChannel : subChannel;
|
||||
for (const auto &message : pair.second)
|
||||
{
|
||||
channel.addMessage(message);
|
||||
channel.addMessage(message, MessageContext::Original);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -162,14 +162,16 @@ void addTwitchEmoteSets(
|
|||
void addEmotes(Channel &channel, const EmoteMap &map, const QString &title,
|
||||
const MessageElementFlag &emoteFlag)
|
||||
{
|
||||
channel.addMessage(makeTitleMessage(title));
|
||||
channel.addMessage(makeEmoteMessage(map, emoteFlag));
|
||||
channel.addMessage(makeTitleMessage(title), MessageContext::Original);
|
||||
channel.addMessage(makeEmoteMessage(map, emoteFlag),
|
||||
MessageContext::Original);
|
||||
}
|
||||
|
||||
void loadEmojis(ChannelView &view, const std::vector<EmojiPtr> &emojiMap)
|
||||
{
|
||||
ChannelPtr emojiChannel(new Channel("", Channel::Type::None));
|
||||
emojiChannel->addMessage(makeEmojiMessage(emojiMap));
|
||||
emojiChannel->addMessage(makeEmojiMessage(emojiMap),
|
||||
MessageContext::Original);
|
||||
|
||||
view.setChannel(emojiChannel);
|
||||
}
|
||||
|
@ -177,8 +179,8 @@ void loadEmojis(ChannelView &view, const std::vector<EmojiPtr> &emojiMap)
|
|||
void loadEmojis(Channel &channel, const std::vector<EmojiPtr> &emojiMap,
|
||||
const QString &title)
|
||||
{
|
||||
channel.addMessage(makeTitleMessage(title));
|
||||
channel.addMessage(makeEmojiMessage(emojiMap));
|
||||
channel.addMessage(makeTitleMessage(title), MessageContext::Original);
|
||||
channel.addMessage(makeEmojiMessage(emojiMap), MessageContext::Original);
|
||||
}
|
||||
|
||||
// Create an emote
|
||||
|
@ -454,7 +456,7 @@ void EmotePopup::loadChannel(ChannelPtr channel)
|
|||
builder.emplace<TextElement>("no subscription emotes available",
|
||||
MessageElementFlag::Text,
|
||||
MessageColor::System);
|
||||
subChannel->addMessage(builder.release());
|
||||
subChannel->addMessage(builder.release(), MessageContext::Original);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -244,7 +244,8 @@ void ReplyThreadPopup::addMessagesFromThread()
|
|||
std::optional<MessageFlags>(this->thread_->root()->flags);
|
||||
rootOverrideFlags->set(MessageFlag::DoNotLog);
|
||||
|
||||
this->virtualChannel_->addMessage(this->thread_->root(), rootOverrideFlags);
|
||||
this->virtualChannel_->addMessage(
|
||||
this->thread_->root(), MessageContext::Repost, rootOverrideFlags);
|
||||
for (const auto &msgRef : this->thread_->replies())
|
||||
{
|
||||
if (auto msg = msgRef.lock())
|
||||
|
@ -252,24 +253,26 @@ void ReplyThreadPopup::addMessagesFromThread()
|
|||
auto overrideFlags = std::optional<MessageFlags>(msg->flags);
|
||||
overrideFlags->set(MessageFlag::DoNotLog);
|
||||
|
||||
this->virtualChannel_->addMessage(msg, overrideFlags);
|
||||
this->virtualChannel_->addMessage(msg, MessageContext::Repost,
|
||||
overrideFlags);
|
||||
}
|
||||
}
|
||||
|
||||
this->messageConnection_ =
|
||||
std::make_unique<pajlada::Signals::ScopedConnection>(
|
||||
sourceChannel->messageAppended.connect([this](MessagePtr &message,
|
||||
auto) {
|
||||
if (message->replyThread == this->thread_)
|
||||
{
|
||||
auto overrideFlags =
|
||||
std::optional<MessageFlags>(message->flags);
|
||||
overrideFlags->set(MessageFlag::DoNotLog);
|
||||
sourceChannel->messageAppended.connect(
|
||||
[this](MessagePtr &message, auto) {
|
||||
if (message->replyThread == this->thread_)
|
||||
{
|
||||
auto overrideFlags =
|
||||
std::optional<MessageFlags>(message->flags);
|
||||
overrideFlags->set(MessageFlag::DoNotLog);
|
||||
|
||||
// same reply thread, add message
|
||||
this->virtualChannel_->addMessage(message, overrideFlags);
|
||||
}
|
||||
}));
|
||||
// same reply thread, add message
|
||||
this->virtualChannel_->addMessage(
|
||||
message, MessageContext::Repost, overrideFlags);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
void ReplyThreadPopup::updateInputUI()
|
||||
|
|
|
@ -112,12 +112,9 @@ namespace {
|
|||
{
|
||||
MessagePtr message = snapshot[i];
|
||||
|
||||
auto overrideFlags = std::optional<MessageFlags>(message->flags);
|
||||
overrideFlags->set(MessageFlag::DoNotLog);
|
||||
|
||||
if (checkMessageUserName(userName, message))
|
||||
{
|
||||
channelPtr->addMessage(message, overrideFlags);
|
||||
channelPtr->addMessage(message, MessageContext::Repost);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -787,7 +784,7 @@ void UserInfoPopup::updateLatestMessages()
|
|||
{
|
||||
// display message in ChannelView
|
||||
this->ui_.latestMessages->channel()->addMessage(
|
||||
message);
|
||||
message, MessageContext::Repost);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -925,26 +925,17 @@ void ChannelView::setChannel(const ChannelPtr &underlyingChannel)
|
|||
{
|
||||
if (this->channel_->lastDate_ != QDate::currentDate())
|
||||
{
|
||||
// Day change message
|
||||
this->channel_->lastDate_ = QDate::currentDate();
|
||||
auto msg = makeSystemMessage(
|
||||
QLocale().toString(QDate::currentDate(),
|
||||
QLocale::LongFormat),
|
||||
QTime(0, 0));
|
||||
this->channel_->addMessage(msg);
|
||||
msg->flags.set(MessageFlag::DoNotLog);
|
||||
this->channel_->addMessage(msg, MessageContext::Original);
|
||||
}
|
||||
// When the message was received in the underlyingChannel,
|
||||
// logging will be handled. Prevent duplications.
|
||||
if (overridingFlags)
|
||||
{
|
||||
overridingFlags->set(MessageFlag::DoNotLog);
|
||||
}
|
||||
else
|
||||
{
|
||||
overridingFlags = MessageFlags(message->flags);
|
||||
overridingFlags->set(MessageFlag::DoNotLog);
|
||||
}
|
||||
|
||||
this->channel_->addMessage(message, overridingFlags);
|
||||
this->channel_->addMessage(message, MessageContext::Repost,
|
||||
overridingFlags);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1010,7 +1001,9 @@ void ChannelView::setChannel(const ChannelPtr &underlyingChannel)
|
|||
}
|
||||
|
||||
this->messages_.pushBack(messageLayout);
|
||||
this->channel_->addMessage(msg);
|
||||
|
||||
this->channel_->addMessage(msg, MessageContext::Repost);
|
||||
|
||||
nMessagesAdded++;
|
||||
if (this->showScrollbarHighlights())
|
||||
{
|
||||
|
|
|
@ -55,7 +55,7 @@ ChannelPtr SearchPopup::filter(const QString &text, const QString &channelName,
|
|||
auto overrideFlags = std::optional<MessageFlags>(message->flags);
|
||||
overrideFlags->set(MessageFlag::DoNotLog);
|
||||
|
||||
channel->addMessage(message, overrideFlags);
|
||||
channel->addMessage(message, MessageContext::Repost, overrideFlags);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue