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