Compare commits

..

1 commit

Author SHA1 Message Date
nerix adea07250f
Merge e537fca186 into 90211cca55 2024-10-27 13:24:37 +00:00
5 changed files with 24 additions and 27 deletions

View file

@ -98,8 +98,7 @@ public:
/// Removes all messages from this channel and invokes #messagesCleared /// Removes all messages from this channel and invokes #messagesCleared
void clearMessages(); void clearMessages();
[[deprecated("Use findMessageByID instead")]] MessagePtr findMessage( MessagePtr findMessage(QString messageID);
QString messageID);
MessagePtr findMessageByID(QStringView messageID) final; MessagePtr findMessageByID(QStringView messageID) final;
bool hasMessages() const; bool hasMessages() const;

View file

@ -5,7 +5,6 @@
#include "messages/MessageFlag.hpp" #include "messages/MessageFlag.hpp"
#include <memory> #include <memory>
#include <optional>
class QStringView; class QStringView;
class QTime; class QTime;

View file

@ -369,8 +369,8 @@ void IrcMessageHandler::parsePrivMessageInto(
} }
addMessage(message, sink, channel, addMessage(message, sink, channel,
unescapeZeroWidthJoiner(message->content()), unescapeZeroWidthJoiner(message->content()), false,
*getApp()->getTwitch(), false, message->isAction()); message->isAction());
if (message->tags().contains(u"pinned-chat-paid-amount"_s)) if (message->tags().contains(u"pinned-chat-paid-amount"_s))
{ {
@ -675,8 +675,7 @@ void IrcMessageHandler::parseUserNoticeMessageInto(Communi::IrcMessage *message,
// Messages are not required, so they might be empty // Messages are not required, so they might be empty
if (!content.isEmpty()) if (!content.isEmpty())
{ {
addMessage(message, sink, channel, content, *getApp()->getTwitch(), addMessage(message, sink, channel, content, true, false);
true, false);
} }
} }
@ -956,12 +955,11 @@ void IrcMessageHandler::handlePartMessage(Communi::IrcMessage *message)
} }
void IrcMessageHandler::addMessage(Communi::IrcMessage *message, void IrcMessageHandler::addMessage(Communi::IrcMessage *message,
MessageSink &sink, TwitchChannel *chan, MessageSink &sink, TwitchChannel *channel,
const QString &originalContent, const QString &originalContent, bool isSub,
ITwitchIrcServer &twitch, bool isSub,
bool isAction) bool isAction)
{ {
assert(chan); assert(channel);
MessageParseArgs args; MessageParseArgs args;
if (isSub) if (isSub)
@ -970,7 +968,7 @@ void IrcMessageHandler::addMessage(Communi::IrcMessage *message,
args.trimSubscriberUsername = true; args.trimSubscriberUsername = true;
} }
if (chan->isBroadcaster()) if (channel->isBroadcaster())
{ {
args.isStaffOrBroadcaster = true; args.isStaffOrBroadcaster = true;
} }
@ -994,13 +992,13 @@ void IrcMessageHandler::addMessage(Communi::IrcMessage *message,
if (!rewardId.isEmpty() && if (!rewardId.isEmpty() &&
sink.sinkTraits().has( sink.sinkTraits().has(
MessageSinkTrait::RequiresKnownChannelPointReward) && MessageSinkTrait::RequiresKnownChannelPointReward) &&
!chan->isChannelPointRewardKnown(rewardId)) !channel->isChannelPointRewardKnown(rewardId))
{ {
// Need to wait for pubsub reward notification // Need to wait for pubsub reward notification
qCDebug(chatterinoTwitch) << "TwitchChannel reward added ADD " qCDebug(chatterinoTwitch) << "TwitchChannel reward added ADD "
"callback since reward is not known:" "callback since reward is not known:"
<< rewardId; << rewardId;
chan->addQueuedRedemption(rewardId, originalContent, message); channel->addQueuedRedemption(rewardId, originalContent, message);
return; return;
} }
args.channelPointRewardId = rewardId; args.channelPointRewardId = rewardId;
@ -1014,9 +1012,9 @@ void IrcMessageHandler::addMessage(Communi::IrcMessage *message,
it != tags.end()) it != tags.end())
{ {
const QString replyID = it.value().toString(); const QString replyID = it.value().toString();
auto threadIt = chan->threads().find(replyID); auto threadIt = channel->threads().find(replyID);
std::shared_ptr<MessageThread> rootThread; std::shared_ptr<MessageThread> rootThread;
if (threadIt != chan->threads().end() && !threadIt->second.expired()) if (threadIt != channel->threads().end() && !threadIt->second.expired())
{ {
// Thread already exists (has a reply) // Thread already exists (has a reply)
auto thread = threadIt->second.lock(); auto thread = threadIt->second.lock();
@ -1037,7 +1035,7 @@ void IrcMessageHandler::addMessage(Communi::IrcMessage *message,
replyCtx.thread = newThread; replyCtx.thread = newThread;
rootThread = newThread; rootThread = newThread;
// Store weak reference to thread in channel // Store weak reference to thread in channel
chan->addReplyThread(newThread); channel->addReplyThread(newThread);
} }
} }
@ -1054,8 +1052,8 @@ void IrcMessageHandler::addMessage(Communi::IrcMessage *message,
} }
else else
{ {
auto parentThreadIt = chan->threads().find(parentID); auto parentThreadIt = channel->threads().find(parentID);
if (parentThreadIt != chan->threads().end()) if (parentThreadIt != channel->threads().end())
{ {
auto thread = parentThreadIt->second.lock(); auto thread = parentThreadIt->second.lock();
if (thread) if (thread)
@ -1077,7 +1075,7 @@ void IrcMessageHandler::addMessage(Communi::IrcMessage *message,
args.allowIgnore = !isSub; args.allowIgnore = !isSub;
auto [msg, alert] = MessageBuilder::makeIrcMessage( auto [msg, alert] = MessageBuilder::makeIrcMessage(
chan, message, args, content, messageOffset, replyCtx.thread, channel, message, args, content, messageOffset, replyCtx.thread,
replyCtx.parent); replyCtx.parent);
if (msg) if (msg)
@ -1094,7 +1092,7 @@ void IrcMessageHandler::addMessage(Communi::IrcMessage *message,
(!getSettings()->hideSimilar && (!getSettings()->hideSimilar &&
getSettings()->shownSimilarTriggerHighlights)) getSettings()->shownSimilarTriggerHighlights))
{ {
MessageBuilder::triggerHighlights(chan, alert); MessageBuilder::triggerHighlights(channel, alert);
} }
const auto highlighted = msg->flags.has(MessageFlag::Highlighted); const auto highlighted = msg->flags.has(MessageFlag::Highlighted);
@ -1103,12 +1101,12 @@ void IrcMessageHandler::addMessage(Communi::IrcMessage *message,
if (highlighted && showInMentions && if (highlighted && showInMentions &&
sink.sinkTraits().has(MessageSinkTrait::AddMentionsToGlobalChannel)) sink.sinkTraits().has(MessageSinkTrait::AddMentionsToGlobalChannel))
{ {
twitch.getMentionsChannel()->addMessage(msg, getApp()->getTwitch()->getMentionsChannel()->addMessage(
MessageContext::Original); msg, MessageContext::Original);
} }
sink.addMessage(msg, MessageContext::Original); sink.addMessage(msg, MessageContext::Original);
chan->addRecentChatter(msg->displayName); channel->addRecentChatter(msg->displayName);
} }
} }

View file

@ -60,8 +60,9 @@ public:
void handlePartMessage(Communi::IrcMessage *message); void handlePartMessage(Communi::IrcMessage *message);
static void addMessage(Communi::IrcMessage *message, MessageSink &sink, static void addMessage(Communi::IrcMessage *message, MessageSink &sink,
TwitchChannel *chan, const QString &originalContent, TwitchChannel *channel,
ITwitchIrcServer &twitch, bool isSub, bool isAction); const QString &originalContent, bool isSub,
bool isAction);
private: private:
static float similarity(const MessagePtr &msg, static float similarity(const MessagePtr &msg,

View file

@ -453,7 +453,7 @@ void TwitchChannel::addChannelPointReward(const ChannelPointReward &reward)
{ {
IrcMessageHandler::instance().addMessage( IrcMessageHandler::instance().addMessage(
msg.message.get(), *this, this, msg.originalContent, msg.message.get(), *this, this, msg.originalContent,
*server, false, false); false, false);
return true; return true;
} }
return false; return false;