Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into chatterino7
Browse files Browse the repository at this point in the history
  • Loading branch information
Nerixyz committed Nov 9, 2024
2 parents 7c3f930 + fc8d27b commit 2664230
Show file tree
Hide file tree
Showing 44 changed files with 548 additions and 207 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/clang-tidy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:

- name: clang-tidy review
timeout-minutes: 20
uses: ZedThree/clang-tidy-review@v0.19.0
uses: ZedThree/clang-tidy-review@v0.20.0
with:
build_dir: build-clang-tidy
config_file: ".clang-tidy"
Expand All @@ -63,4 +63,4 @@ jobs:
libxkbcommon-x11-0, libxcb-xkb-dev, libxcb-cursor0
- name: clang-tidy-review upload
uses: ZedThree/clang-tidy-review/upload@v0.19.0
uses: ZedThree/clang-tidy-review/upload@v0.20.0
2 changes: 1 addition & 1 deletion .github/workflows/post-clang-tidy-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
if: ${{ github.event.workflow_run.conclusion == 'success' }}

steps:
- uses: ZedThree/clang-tidy-review/post@v0.19.0
- uses: ZedThree/clang-tidy-review/post@v0.20.0
with:
lgtm_comment_body: ""
num_comments_as_exitcode: false
1 change: 1 addition & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
[submodule "lib/lua/src"]
path = lib/lua/src
url = https://github.com/lua/lua
branch = v5.4
[submodule "lib/kimageformats"]
path = lib/kimageformats
url = https://github.com/KDE/kimageformats
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,14 @@
- Minor: Moderators can now see which mods start and cancel raids. (#5563)
- Minor: The emote popup now reloads when Twitch emotes are reloaded. (#5580)
- Minor: Added `--login <username>` CLI argument to specify which account to start logged in as. (#5626)
- Minor: When blocking a channel, Chatterino will now warn you about that action. (#5615)
- Minor: Indicate when subscriptions and resubscriptions are for multiple months. (#5642)
- Minor: Added a setting to control whether or not to show "Blocked Term" automod messages. (#5690)
- Minor: Proxy URL information is now included in the `/debug-env` command. (#5648)
- Minor: Make raid entry message usernames clickable. (#5651)
- Minor: Tabs unhighlight when their content is read in other tabs. (#5649)
- Minor: Made usernames in bits and sub messages clickable. (#5686)
- Minor: Mentions of FrankerFaceZ and BetterTTV in settings are standardized as such. (#5698)
- Bugfix: Fixed tab move animation occasionally failing to start after closing a tab. (#5426, #5612)
- Bugfix: If a network request errors with 200 OK, Qt's error code is now reported instead of the HTTP status. (#5378)
- Bugfix: Fixed restricted users usernames not being clickable. (#5405)
Expand All @@ -55,6 +59,7 @@
- Bugfix: Fixed event emotes not showing up in autocomplete and popups. (#5239, #5580, #5582, #5632)
- Bugfix: Fixed tab visibility being controllable in the emote popup. (#5530)
- Bugfix: Fixed account switch not being saved if no other settings were changed. (#5558)
- Bugfix: Fixed a crash that could occur when handling the quick switcher popup really quickly. (#5687)
- Bugfix: Fixed 7TV badges being inadvertently animated. (#5674)
- Bugfix: Fixed some tooltips not being readable. (#5578)
- Bugfix: Fixed log files being locked longer than needed. (#5592)
Expand All @@ -65,6 +70,7 @@
- Bugfix: Fixed emotes starting with ":" not tab-completing. (#5603)
- Bugfix: Fixed 7TV emotes messing with Qt's HTML. (#5677)
- Bugfix: Fixed incorrect messages getting replaced visually. (#5683)
- Bugfix: Fixed rendering of multi-line selection that starts at a trailing space. (#5691)
- Dev: Update Windows build from Qt 6.5.0 to Qt 6.7.1. (#5420)
- Dev: Update vcpkg build Qt from 6.5.0 to 6.7.0, boost from 1.83.0 to 1.85.0, openssl from 3.1.3 to 3.3.0. (#5422)
- Dev: Unsingletonize `ISoundController`. (#5462)
Expand Down Expand Up @@ -113,11 +119,14 @@
- Dev: `GIFTimer` is no longer initialized in tests. (#5608)
- Dev: Emojis now use flags instead of a set of strings for capabilities. (#5616)
- Dev: Move plugins to Sol2. (#5622, #5682)
- Dev: Clarified our Lua dependency's version. (#5693)
- Dev: Specified qtkeychain dependency version. (#5695, #5697)
- Dev: Refactored static `MessageBuilder` helpers to standalone functions. (#5652)
- Dev: Decoupled reply parsing from `MessageBuilder`. (#5660, #5668)
- Dev: Refactored IRC message building. (#5663)
- Dev: Fixed some compiler warnings. (#5672)
- Dev: Unified parsing of historic and live IRC messages. (#5678)
- Dev: 7TV's `entitlement.reset` is now explicitly ignored. (#5685)

## 2.5.1

Expand Down
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,19 @@ if (BUILD_WITH_QTKEYCHAIN)
message(FATAL_ERROR "Submodules probably not loaded, unable to find lib/qtkeychain/CMakeLists.txt")
endif()

set(_prev_testing ${BUILD_TESTING})
set(BUILD_TESTING Off)
add_subdirectory("${QTKEYCHAIN_ROOT_LIB_FOLDER}" EXCLUDE_FROM_ALL)
set(BUILD_TESTING ${_prev_testing})

if (NOT TARGET qt${MAJOR_QT_VERSION}keychain)
message(FATAL_ERROR "qt${MAJOR_QT_VERSION}keychain target was not created :@")
endif()
if (MSVC AND "${MAJOR_QT_VERSION}" STREQUAL "5")
target_compile_definitions(qt5keychain PRIVATE UNICODE)
target_compile_options(qt5keychain PRIVATE /utf-8)
set_target_properties(qt5keychain PROPERTIES CXX_STANDARD 17)
endif()
endif()
endif()

Expand Down
2 changes: 1 addition & 1 deletion mocks/include/mocks/Helix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ class Helix : public IHelix
// get followed channel
MOCK_METHOD(
void, getFollowedChannel,
(QString userID, QString broadcasterID,
(QString userID, QString broadcasterID, const QObject *caller,
ResultCallback<std::optional<HelixFollowedChannel>> successCallback,
FailureCallback<QString> failureCallback),
(override));
Expand Down
7 changes: 7 additions & 0 deletions src/common/ChatterinoSetting.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
#include <QSize>
#include <QString>

#include <memory>
#include <string>
#include <type_traits>

namespace chatterino {

void _registerSetting(std::weak_ptr<pajlada::Settings::SettingData> setting);
Expand Down Expand Up @@ -148,6 +152,9 @@ struct IsChatterinoSettingT : std::false_type {
template <typename T>
struct IsChatterinoSettingT<ChatterinoSetting<T>> : std::true_type {
};
template <typename T>
struct IsChatterinoSettingT<EnumStringSetting<T>> : std::true_type {
};

template <typename T>
concept IsChatterinoSetting = IsChatterinoSettingT<T>::value;
Expand Down
2 changes: 1 addition & 1 deletion src/common/Credentials.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
# include "qt5keychain/keychain.h"
# endif
# else
# include "keychain.h"
# include <qtkeychain/keychain.h>
# endif
#endif

Expand Down
110 changes: 93 additions & 17 deletions src/messages/MessageBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "providers/twitch/api/Helix.hpp"
#include "providers/twitch/ChannelPointReward.hpp"
#include "providers/twitch/PubSubActions.hpp"
#include "providers/twitch/pubsubmessages/AutoMod.hpp"
#include "providers/twitch/TwitchAccount.hpp"
#include "providers/twitch/TwitchBadge.hpp"
#include "providers/twitch/TwitchBadges.hpp"
Expand Down Expand Up @@ -76,6 +77,8 @@ const QRegularExpression mentionRegex("^@" + regexHelpString);
// if findAllUsernames setting is enabled, matches strings like in the examples above, but without @ symbol at the beginning
const QRegularExpression allUsernamesMentionRegex("^" + regexHelpString);

const QRegularExpression SPACE_REGEX("\\s");

const QSet<QString> zeroWidthEmotes{
"SoSnowy", "IceCold", "SantaHat", "TopHat",
"ReinDeer", "CandyCane", "cvMask", "cvHazmat",
Expand Down Expand Up @@ -524,7 +527,7 @@ MessageBuilder::MessageBuilder(SystemMessageTag, const QString &text,
// check system message for links
// (e.g. needed for sub ticket message in sub only mode)
const QStringList textFragments =
text.split(QRegularExpression("\\s"), Qt::SkipEmptyParts);
text.split(SPACE_REGEX, Qt::SkipEmptyParts);
for (const auto &word : textFragments)
{
auto link = linkparser::parse(word);
Expand All @@ -543,33 +546,100 @@ MessageBuilder::MessageBuilder(SystemMessageTag, const QString &text,
this->message().searchText = text;
}

MessageBuilder::MessageBuilder(RaidEntryMessageTag, const QString &text,
const QString &loginName,
const QString &displayName,
const MessageColor &userColor, const QTime &time)
: MessageBuilder()
MessagePtrMut MessageBuilder::makeSystemMessageWithUser(
const QString &text, const QString &loginName, const QString &displayName,
const MessageColor &userColor, const QTime &time)
{
this->emplace<TimestampElement>(time);
MessageBuilder builder;
builder.emplace<TimestampElement>(time);

const QStringList textFragments =
text.split(QRegularExpression("\\s"), Qt::SkipEmptyParts);
const auto textFragments = text.split(SPACE_REGEX, Qt::SkipEmptyParts);
for (const auto &word : textFragments)
{
if (word == displayName)
{
this->emplace<MentionElement>(displayName, loginName,
MessageColor::System, userColor);
builder.emplace<MentionElement>(displayName, loginName,
MessageColor::System, userColor);
continue;
}

this->emplace<TextElement>(word, MessageElementFlag::Text,
MessageColor::System);
builder.emplace<TextElement>(word, MessageElementFlag::Text,
MessageColor::System);
}

this->message().flags.set(MessageFlag::System);
this->message().flags.set(MessageFlag::DoNotTriggerNotification);
this->message().messageText = text;
this->message().searchText = text;
builder->flags.set(MessageFlag::System);
builder->flags.set(MessageFlag::DoNotTriggerNotification);
builder->messageText = text;
builder->searchText = text;

return builder.release();
}

MessagePtrMut MessageBuilder::makeSubgiftMessage(const QString &text,
const QVariantMap &tags,
const QTime &time)
{
MessageBuilder builder;
builder.emplace<TimestampElement>(time);

auto gifterLogin = tags.value("login").toString();
auto gifterDisplayName = tags.value("display-name").toString();
if (gifterDisplayName.isEmpty())
{
gifterDisplayName = gifterLogin;
}
MessageColor gifterColor = MessageColor::System;
if (auto colorTag = tags.value("color").value<QColor>(); colorTag.isValid())
{
gifterColor = MessageColor(colorTag);
}

auto recipientLogin =
tags.value("msg-param-recipient-user-name").toString();
if (recipientLogin.isEmpty())
{
recipientLogin = tags.value("msg-param-recipient-name").toString();
}
auto recipientDisplayName =
tags.value("msg-param-recipient-display-name").toString();
if (recipientDisplayName.isEmpty())
{
recipientDisplayName = recipientLogin;
}

const auto textFragments = text.split(SPACE_REGEX, Qt::SkipEmptyParts);
for (const auto &word : textFragments)
{
if (word == gifterDisplayName)
{
builder.emplace<MentionElement>(gifterDisplayName, gifterLogin,
MessageColor::System, gifterColor);
continue;
}
if (word.endsWith('!') &&
word.size() == recipientDisplayName.size() + 1 &&
word.startsWith(recipientDisplayName))
{
builder
.emplace<MentionElement>(recipientDisplayName, recipientLogin,
MessageColor::System,
MessageColor::System)
->setTrailingSpace(false);
builder.emplace<TextElement>(u"!"_s, MessageElementFlag::Text,
MessageColor::System);
continue;
}

builder.emplace<TextElement>(word, MessageElementFlag::Text,
MessageColor::System);
}

builder->flags.set(MessageFlag::System);
builder->flags.set(MessageFlag::DoNotTriggerNotification);
builder->messageText = text;
builder->searchText = text;

return builder.release();
}

MessageBuilder::MessageBuilder(TimeoutMessageTag, const QString &timeoutUser,
Expand Down Expand Up @@ -1580,6 +1650,12 @@ std::pair<MessagePtr, MessagePtr> MessageBuilder::makeAutomodMessage(
{
MessageBuilder builder, builder2;

if (action.reasonCode == PubSubAutoModQueueMessage::Reason::BlockedTerm)
{
builder.message().flags.set(MessageFlag::AutoModBlockedTerm);
builder2.message().flags.set(MessageFlag::AutoModBlockedTerm);
}

//
// Builder for AutoMod message with explanation
builder.message().id = "automod_" + action.msgID;
Expand Down
15 changes: 9 additions & 6 deletions src/messages/MessageBuilder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ namespace linkparser {

struct SystemMessageTag {
};
struct RaidEntryMessageTag {
};
struct TimeoutMessageTag {
};
struct LiveUpdatesUpdateEmoteMessageTag {
Expand All @@ -69,7 +67,6 @@ struct ImageUploaderResultTag {

// NOLINTBEGIN(readability-identifier-naming)
const SystemMessageTag systemMessage{};
const RaidEntryMessageTag raidEntryMessage{};
const TimeoutMessageTag timeoutMessage{};
const LiveUpdatesUpdateEmoteMessageTag liveUpdatesUpdateEmoteMessage{};
const LiveUpdatesRemoveEmoteMessageTag liveUpdatesRemoveEmoteMessage{};
Expand Down Expand Up @@ -109,9 +106,6 @@ class MessageBuilder

MessageBuilder(SystemMessageTag, const QString &text,
const QTime &time = QTime::currentTime());
MessageBuilder(RaidEntryMessageTag, const QString &text,
const QString &loginName, const QString &displayName,
const MessageColor &userColor, const QTime &time);
MessageBuilder(TimeoutMessageTag, const QString &timeoutUser,
const QString &sourceUser, const QString &systemMessageText,
int times, const QTime &time = QTime::currentTime());
Expand Down Expand Up @@ -255,6 +249,15 @@ class MessageBuilder
const std::shared_ptr<MessageThread> &thread = {},
const MessagePtr &parent = {});

static MessagePtrMut makeSystemMessageWithUser(
const QString &text, const QString &loginName,
const QString &displayName, const MessageColor &userColor,
const QTime &time);

static MessagePtrMut makeSubgiftMessage(const QString &text,
const QVariantMap &tags,
const QTime &time);

private:
struct TextState {
TwitchChannel *twitchChannel = nullptr;
Expand Down
2 changes: 2 additions & 0 deletions src/messages/MessageFlag.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ enum class MessageFlag : std::int64_t {
Action = (1LL << 36),
/// The message is sent in a different source channel as part of a Shared Chat session
SharedMessage = (1LL << 37),
/// AutoMod message that showed up due to containing a blocked term in the channel
AutoModBlockedTerm = (1LL << 38),
};
using MessageFlags = FlagsEnum<MessageFlag>;

Expand Down
15 changes: 15 additions & 0 deletions src/messages/layouts/MessageLayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ void MessageLayout::actuallyLayout(const MessageLayoutContext &ctx)

bool hideModerated = getSettings()->hideModerated;
bool hideModerationActions = getSettings()->hideModerationActions;
bool hideBlockedTermAutomodMessages =
getSettings()->showBlockedTermAutomodMessages.getEnum() ==
ShowModerationState::Never;
bool hideSimilar = getSettings()->hideSimilar;
bool hideReplies = !ctx.flags.has(MessageElementFlag::RepliedMessage);

Expand All @@ -154,9 +157,21 @@ void MessageLayout::actuallyLayout(const MessageLayoutContext &ctx)
continue;
}

if (hideBlockedTermAutomodMessages &&
this->message_->flags.has(MessageFlag::AutoModBlockedTerm))
{
// NOTE: This hides the message but it will make the message re-appear if moderation message hiding is no longer active, and the layout is re-laid-out.
// This is only the case for the moderation messages that don't get filtered during creation.
// We should decide which is the correct method & apply that everywhere
continue;
}

if (this->message_->flags.has(MessageFlag::Timeout) ||
this->message_->flags.has(MessageFlag::Untimeout))
{
// NOTE: This hides the message but it will make the message re-appear if moderation message hiding is no longer active, and the layout is re-laid-out.
// This is only the case for the moderation messages that don't get filtered during creation.
// We should decide which is the correct method & apply that everywhere
if (hideModerationActions ||
(getSettings()->streamerModeHideModActions &&
getApp()->getStreamerMode()->isEnabled()))
Expand Down
Loading

0 comments on commit 2664230

Please sign in to comment.