1043f9f803
* refactor: remove unnecessary includes in headers * fix: formatting * chore: changelog * fix: scrollbar * fix: suggestions and old appbase remains * fix: suggestion * fix: missing Qt forward declarations * fix: another qt include * fix: includes for precompiled-headers=off * Add missing `<memory>` includes * Add missing `#pragma once` * Fix tests Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
67 lines
2.0 KiB
C++
67 lines
2.0 KiB
C++
#include "controllers/ignores/IgnoreController.hpp"
|
|
|
|
#include "Application.hpp"
|
|
#include "common/QLogging.hpp"
|
|
#include "controllers/accounts/AccountController.hpp"
|
|
#include "controllers/ignores/IgnorePhrase.hpp"
|
|
#include "providers/twitch/TwitchAccount.hpp"
|
|
#include "singletons/Settings.hpp"
|
|
|
|
namespace chatterino {
|
|
|
|
bool isIgnoredMessage(IgnoredMessageParameters &¶ms)
|
|
{
|
|
if (!params.message.isEmpty())
|
|
{
|
|
// TODO(pajlada): Do we need to check if the phrase is valid first?
|
|
auto phrases = getCSettings().ignoredMessages.readOnly();
|
|
for (const auto &phrase : *phrases)
|
|
{
|
|
if (phrase.isBlock() && phrase.isMatch(params.message))
|
|
{
|
|
qCDebug(chatterinoMessage)
|
|
<< "Blocking message because it contains ignored phrase"
|
|
<< phrase.getPattern();
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (!params.twitchUserID.isEmpty() &&
|
|
getSettings()->enableTwitchBlockedUsers)
|
|
{
|
|
auto sourceUserID = params.twitchUserID;
|
|
|
|
auto blocks =
|
|
getApp()->accounts->twitch.getCurrent()->accessBlockedUserIds();
|
|
|
|
if (auto it = blocks->find(sourceUserID); it != blocks->end())
|
|
{
|
|
switch (static_cast<ShowIgnoredUsersMessages>(
|
|
getSettings()->showBlockedUsersMessages.getValue()))
|
|
{
|
|
case ShowIgnoredUsersMessages::IfModerator:
|
|
if (params.isMod || params.isBroadcaster)
|
|
{
|
|
return false;
|
|
}
|
|
break;
|
|
case ShowIgnoredUsersMessages::IfBroadcaster:
|
|
if (params.isBroadcaster)
|
|
{
|
|
return false;
|
|
}
|
|
break;
|
|
case ShowIgnoredUsersMessages::Never:
|
|
break;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
} // namespace chatterino
|