Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow timeout-related commands to be used in multiple channels #5402

Merged
merged 20 commits into from
Jun 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,6 @@
[submodule "tools/crash-handler"]
path = tools/crash-handler
url = https://github.com/Chatterino/crash-handler
[submodule "lib/expected-lite"]
path = lib/expected-lite
url = https://github.com/martinmoene/expected-lite
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Minor: Add option to customise Moderation buttons with images. (#5369)
- Minor: Colored usernames now update on the fly when changing the "Color @usernames" setting. (#5300)
- Minor: Added `flags.action` filter variable, allowing you to filter on `/me` messages. (#5397)
- Minor: Added the ability for `/ban`, `/timeout`, `/unban`, and `/untimeout` to specify multiple channels to duplicate the action to. Example: `/timeout --channel id:11148817 --channel testaccount_420 forsen 7m game complaining`. (#5402)
- Minor: The size of the emote popup is now saved. (#5415)
- Minor: Added the ability to duplicate tabs. (#5277)
- Minor: Improved error messages for channel update commands. (#5429)
Expand Down
7 changes: 7 additions & 0 deletions benchmarks/src/RecentMessages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "messages/Emote.hpp"
#include "mocks/DisabledStreamerMode.hpp"
#include "mocks/EmptyApplication.hpp"
#include "mocks/LinkResolver.hpp"
#include "mocks/TwitchIrcServer.hpp"
#include "mocks/UserData.hpp"
#include "providers/bttv/BttvEmotes.hpp"
Expand Down Expand Up @@ -99,10 +100,16 @@ class MockApplication : mock::EmptyApplication
return &this->streamerMode;
}

ILinkResolver *getLinkResolver() override
{
return &this->linkResolver;
}

AccountController accounts;
Emotes emotes;
mock::UserDataController userData;
mock::MockTwitchIrcServer twitch;
mock::EmptyLinkResolver linkResolver;
ChatterinoBadges chatterinoBadges;
FfzBadges ffzBadges;
SeventvBadges seventvBadges;
Expand Down
1 change: 1 addition & 0 deletions lib/expected-lite
Submodule expected-lite added at 3634b0
7 changes: 6 additions & 1 deletion mocks/include/mocks/EmptyApplication.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ class EmptyApplication : public IApplication

virtual ~EmptyApplication() = default;

bool isTest() const override
pajlada marked this conversation as resolved.
Show resolved Hide resolved
pajlada marked this conversation as resolved.
Show resolved Hide resolved
{
return true;
}

const Paths &getPaths() override
{
return this->paths_;
Expand Down Expand Up @@ -137,7 +142,7 @@ class EmptyApplication : public IApplication
return nullptr;
}

Logging *getChatLogger() override
ILogging *getChatLogger() override
pajlada marked this conversation as resolved.
Show resolved Hide resolved
pajlada marked this conversation as resolved.
Show resolved Hide resolved
{
assert(!"getChatLogger was called without being initialized");
return nullptr;
Expand Down
32 changes: 32 additions & 0 deletions mocks/include/mocks/LinkResolver.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#pragma once

#include "providers/links/LinkResolver.hpp"

#include <gmock/gmock.h>
pajlada marked this conversation as resolved.
Show resolved Hide resolved
#include <QString>
#include <QStringList>

namespace chatterino::mock {
pajlada marked this conversation as resolved.
Show resolved Hide resolved
pajlada marked this conversation as resolved.
Show resolved Hide resolved
pajlada marked this conversation as resolved.
Show resolved Hide resolved

class LinkResolver : public ILinkResolver
pajlada marked this conversation as resolved.
Show resolved Hide resolved
pajlada marked this conversation as resolved.
Show resolved Hide resolved
pajlada marked this conversation as resolved.
Show resolved Hide resolved
{
public:
LinkResolver() = default;
~LinkResolver() override = default;

MOCK_METHOD(void, resolve, (LinkInfo * info), (override));
pajlada marked this conversation as resolved.
Show resolved Hide resolved
pajlada marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: invalid case style for function 'MOCK_METHOD' [readability-identifier-naming]

Suggested change
MOCK_METHOD(void, resolve, (LinkInfo * info), (override));
mockMethod(void, resolve, (LinkInfo * info), (override));

};

class EmptyLinkResolver : public ILinkResolver
pajlada marked this conversation as resolved.
Show resolved Hide resolved
pajlada marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: class 'EmptyLinkResolver' defines a default destructor but does not define a copy constructor, a copy assignment operator, a move constructor or a move assignment operator [cppcoreguidelines-special-member-functions]

class EmptyLinkResolver : public ILinkResolver
      ^

{
public:
EmptyLinkResolver() = default;
~EmptyLinkResolver() override = default;

void resolve(LinkInfo *info) override
{
//
}
};

} // namespace chatterino::mock
36 changes: 36 additions & 0 deletions mocks/include/mocks/Logging.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#pragma once

#include "singletons/Logging.hpp"

#include <gmock/gmock.h>
pajlada marked this conversation as resolved.
Show resolved Hide resolved
#include <QString>
#include <QStringList>

namespace chatterino::mock {

class Logging : public ILogging
pajlada marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: class 'Logging' defines a default destructor but does not define a copy constructor, a copy assignment operator, a move constructor or a move assignment operator [cppcoreguidelines-special-member-functions]

class Logging : public ILogging
      ^

{
public:
Logging() = default;
~Logging() override = default;

MOCK_METHOD(void, addMessage,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: invalid case style for function 'MOCK_METHOD' [readability-identifier-naming]

Suggested change
MOCK_METHOD(void, addMessage,
mockMethod(void, addMessage,

(const QString &channelName, MessagePtr message,
const QString &platformName),
(override));
};

class EmptyLogging : public ILogging
pajlada marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: class 'EmptyLogging' defines a default destructor but does not define a copy constructor, a copy assignment operator, a move constructor or a move assignment operator [cppcoreguidelines-special-member-functions]

class EmptyLogging : public ILogging
      ^

{
public:
EmptyLogging() = default;
~EmptyLogging() override = default;

void addMessage(const QString &channelName, MessagePtr message,
const QString &platformName) override
{
//
}
};

} // namespace chatterino::mock
23 changes: 23 additions & 0 deletions resources/licenses/expected-lite.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Boost Software License - Version 1.0 - August 17th, 2003

Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:

The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
2 changes: 1 addition & 1 deletion src/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ PubSub *Application::getTwitchPubSub()
return this->twitchPubSub.get();
}

Logging *Application::getChatLogger()
ILogging *Application::getChatLogger()
{
assertInGuiThread();

Expand Down
12 changes: 10 additions & 2 deletions src/Application.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class PluginController;

class Theme;
class WindowManager;
class ILogging;
class Logging;
class Paths;
class Emotes;
Expand Down Expand Up @@ -64,6 +65,8 @@ class IApplication

static IApplication *instance;

virtual bool isTest() const = 0;

virtual const Paths &getPaths() = 0;
virtual const Args &getArgs() = 0;
virtual Theme *getThemes() = 0;
Expand All @@ -80,7 +83,7 @@ class IApplication
virtual ITwitchIrcServer *getTwitch() = 0;
virtual IAbstractIrcServer *getTwitchAbstract() = 0;
virtual PubSub *getTwitchPubSub() = 0;
virtual Logging *getChatLogger() = 0;
virtual ILogging *getChatLogger() = 0;
virtual IChatterinoBadges *getChatterinoBadges() = 0;
virtual FfzBadges *getFfzBadges() = 0;
virtual SeventvBadges *getSeventvBadges() = 0;
Expand Down Expand Up @@ -121,6 +124,11 @@ class Application : public IApplication
Application &operator=(const Application &) = delete;
Application &operator=(Application &&) = delete;

bool isTest() const override
{
return false;
}

/**
* In the interim, before we remove _exit(0); from RunGui.cpp,
* this will destroy things we know can be destroyed
Expand Down Expand Up @@ -191,7 +199,7 @@ class Application : public IApplication
ITwitchIrcServer *getTwitch() override;
IAbstractIrcServer *getTwitchAbstract() override;
PubSub *getTwitchPubSub() override;
Logging *getChatLogger() override;
ILogging *getChatLogger() override;
FfzBadges *getFfzBadges() override;
SeventvBadges *getSeventvBadges() override;
IUserDataController *getUserData() override;
Expand Down
5 changes: 5 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ set(SOURCE_FILES
controllers/commands/builtin/twitch/UpdateChannel.hpp
controllers/commands/builtin/twitch/UpdateColor.cpp
controllers/commands/builtin/twitch/UpdateColor.hpp
controllers/commands/common/ChannelAction.cpp
controllers/commands/common/ChannelAction.hpp
controllers/commands/CommandContext.hpp
controllers/commands/CommandController.cpp
controllers/commands/CommandController.hpp
Expand Down Expand Up @@ -1003,6 +1005,9 @@ target_include_directories(${LIBRARY_PROJECT} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
# semver dependency https://github.com/Neargye/semver
target_include_directories(${LIBRARY_PROJECT} PUBLIC ${CMAKE_SOURCE_DIR}/lib/semver/include)

# expected-lite dependency https://github.com/martinmoene/expected-lite
target_include_directories(${LIBRARY_PROJECT} PUBLIC ${CMAKE_SOURCE_DIR}/lib/expected-lite/include)

# miniaudio dependency https://github.com/mackron/miniaudio
if (USE_SYSTEM_MINIAUDIO)
message(STATUS "Building with system miniaudio")
Expand Down
1 change: 1 addition & 0 deletions src/common/QLogging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Q_LOGGING_CATEGORY(chatterinoArgs, "chatterino.args", logThreshold);
Q_LOGGING_CATEGORY(chatterinoBenchmark, "chatterino.benchmark", logThreshold);
Q_LOGGING_CATEGORY(chatterinoBttv, "chatterino.bttv", logThreshold);
Q_LOGGING_CATEGORY(chatterinoCache, "chatterino.cache", logThreshold);
Q_LOGGING_CATEGORY(chatterinoCommands, "chatterino.commands", logThreshold);
Q_LOGGING_CATEGORY(chatterinoCommon, "chatterino.common", logThreshold);
Q_LOGGING_CATEGORY(chatterinoCrashhandler, "chatterino.crashhandler",
logThreshold);
Expand Down
3 changes: 2 additions & 1 deletion src/common/QLogging.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Q_DECLARE_LOGGING_CATEGORY(chatterinoArgs);
Q_DECLARE_LOGGING_CATEGORY(chatterinoBenchmark);
Q_DECLARE_LOGGING_CATEGORY(chatterinoBttv);
Q_DECLARE_LOGGING_CATEGORY(chatterinoCache);
Q_DECLARE_LOGGING_CATEGORY(chatterinoCommands);
Q_DECLARE_LOGGING_CATEGORY(chatterinoCommon);
Q_DECLARE_LOGGING_CATEGORY(chatterinoCrashhandler);
Q_DECLARE_LOGGING_CATEGORY(chatterinoEmoji);
Expand All @@ -17,6 +18,7 @@ Q_DECLARE_LOGGING_CATEGORY(chatterinoHighlights);
Q_DECLARE_LOGGING_CATEGORY(chatterinoHotkeys);
Q_DECLARE_LOGGING_CATEGORY(chatterinoHTTP);
Q_DECLARE_LOGGING_CATEGORY(chatterinoImage);
Q_DECLARE_LOGGING_CATEGORY(chatterinoImageuploader);
Q_DECLARE_LOGGING_CATEGORY(chatterinoIrc);
Q_DECLARE_LOGGING_CATEGORY(chatterinoIvr);
Q_DECLARE_LOGGING_CATEGORY(chatterinoLiveupdates);
Expand All @@ -26,7 +28,6 @@ Q_DECLARE_LOGGING_CATEGORY(chatterinoMessage);
Q_DECLARE_LOGGING_CATEGORY(chatterinoNativeMessage);
Q_DECLARE_LOGGING_CATEGORY(chatterinoNetwork);
Q_DECLARE_LOGGING_CATEGORY(chatterinoNotification);
Q_DECLARE_LOGGING_CATEGORY(chatterinoImageuploader);
Q_DECLARE_LOGGING_CATEGORY(chatterinoPubSub);
Q_DECLARE_LOGGING_CATEGORY(chatterinoRecentMessages);
Q_DECLARE_LOGGING_CATEGORY(chatterinoSettings);
Expand Down
Loading
Loading