2017-06-07 10:09:24 +02:00
|
|
|
#pragma once
|
2017-04-12 17:46:44 +02:00
|
|
|
|
2018-08-11 17:35:46 +02:00
|
|
|
#include "common/Atomic.hpp"
|
2018-08-02 14:23:27 +02:00
|
|
|
#include "common/UniqueAccess.hpp"
|
2018-06-26 14:09:39 +02:00
|
|
|
#include "controllers/accounts/Account.hpp"
|
2018-08-02 14:23:27 +02:00
|
|
|
#include "messages/Emote.hpp"
|
2024-09-01 11:22:54 +02:00
|
|
|
#include "providers/twitch/TwitchEmotes.hpp"
|
2023-07-23 13:26:12 +02:00
|
|
|
#include "providers/twitch/TwitchUser.hpp"
|
|
|
|
#include "util/CancellationToken.hpp"
|
2021-07-11 11:12:49 +02:00
|
|
|
#include "util/QStringHash.hpp"
|
2018-05-12 20:34:13 +02:00
|
|
|
|
2024-09-01 11:22:54 +02:00
|
|
|
#include <boost/unordered/unordered_flat_map_fwd.hpp>
|
|
|
|
#include <pajlada/signals.hpp>
|
2018-02-04 16:33:46 +01:00
|
|
|
#include <QColor>
|
2021-06-13 13:49:59 +02:00
|
|
|
#include <QElapsedTimer>
|
2023-07-01 14:01:47 +02:00
|
|
|
#include <QObject>
|
2017-04-12 17:46:44 +02:00
|
|
|
#include <QString>
|
Sort and force grouping of includes (#4172)
This change enforces strict include grouping using IncludeCategories
In addition to adding this to the .clang-format file and applying it in the tests/src and src directories, I also did the following small changes:
In ChatterSet.hpp, I changed lrucache to a <>include
In Irc2.hpp, I change common/SignalVector.hpp to a "project-include"
In AttachedWindow.cpp, NativeMessaging.cpp, WindowsHelper.hpp, BaseWindow.cpp, and StreamerMode.cpp, I disabled clang-format for the windows-includes
In WindowDescriptors.hpp, I added the missing vector include. It was previously not needed because the include was handled by another file that was previously included first.
clang-format minimum version has been bumped, so Ubuntu version used in the check-formatting job has been bumped to 22.04 (which is the latest LTS)
2022-11-27 19:32:53 +01:00
|
|
|
#include <rapidjson/document.h>
|
2017-04-12 17:46:44 +02:00
|
|
|
|
2018-06-27 02:16:30 +02:00
|
|
|
#include <functional>
|
|
|
|
#include <mutex>
|
2023-07-23 13:26:12 +02:00
|
|
|
#include <unordered_set>
|
2018-05-06 12:52:47 +02:00
|
|
|
|
2017-04-14 17:52:22 +02:00
|
|
|
namespace chatterino {
|
2018-05-13 17:53:24 +02:00
|
|
|
|
2022-12-31 15:41:01 +01:00
|
|
|
class Channel;
|
|
|
|
using ChannelPtr = std::shared_ptr<Channel>;
|
|
|
|
|
2018-06-26 17:06:17 +02:00
|
|
|
class TwitchAccount : public Account
|
2017-04-12 17:46:44 +02:00
|
|
|
{
|
|
|
|
public:
|
2018-07-06 19:23:47 +02:00
|
|
|
TwitchAccount(const QString &username, const QString &oauthToken_,
|
|
|
|
const QString &oauthClient_, const QString &_userID);
|
2024-09-01 11:22:54 +02:00
|
|
|
~TwitchAccount() override;
|
|
|
|
TwitchAccount(const TwitchAccount &) = delete;
|
|
|
|
TwitchAccount(TwitchAccount &&) = delete;
|
|
|
|
TwitchAccount &operator=(const TwitchAccount &) = delete;
|
|
|
|
TwitchAccount &operator=(TwitchAccount &&) = delete;
|
2017-04-12 17:46:44 +02:00
|
|
|
|
2023-10-25 18:13:48 +02:00
|
|
|
QString toString() const override;
|
2018-05-06 12:52:47 +02:00
|
|
|
|
2018-02-05 15:11:50 +01:00
|
|
|
const QString &getUserName() const;
|
2017-04-12 17:46:44 +02:00
|
|
|
const QString &getOAuthToken() const;
|
|
|
|
const QString &getOAuthClient() const;
|
2017-09-23 19:23:10 +02:00
|
|
|
const QString &getUserId() const;
|
2017-04-12 17:46:44 +02:00
|
|
|
|
2023-07-29 11:49:44 +02:00
|
|
|
/**
|
|
|
|
* The Seventv user-id of the current user.
|
|
|
|
* Empty if there's no associated Seventv user with this twitch user.
|
|
|
|
*/
|
|
|
|
const QString &getSeventvUserID() const;
|
|
|
|
|
2018-08-11 17:35:46 +02:00
|
|
|
QColor color();
|
|
|
|
void setColor(QColor color);
|
|
|
|
|
2017-12-26 11:59:26 +01:00
|
|
|
// Attempts to update the users OAuth Client ID
|
|
|
|
// Returns true if the value has changed, otherwise false
|
|
|
|
bool setOAuthClient(const QString &newClientID);
|
|
|
|
|
|
|
|
// Attempts to update the users OAuth Token
|
|
|
|
// Returns true if the value has changed, otherwise false
|
|
|
|
bool setOAuthToken(const QString &newOAuthToken);
|
2017-12-19 15:09:54 +01:00
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
bool isAnon() const;
|
|
|
|
|
2021-02-14 14:01:13 +01:00
|
|
|
void loadBlocks();
|
2023-07-23 13:26:12 +02:00
|
|
|
void blockUser(const QString &userId, const QObject *caller,
|
2023-07-01 14:01:47 +02:00
|
|
|
std::function<void()> onSuccess,
|
2021-02-14 14:01:13 +01:00
|
|
|
std::function<void()> onFailure);
|
2023-07-23 13:26:12 +02:00
|
|
|
void unblockUser(const QString &userId, const QObject *caller,
|
2023-07-01 14:01:47 +02:00
|
|
|
std::function<void()> onSuccess,
|
2021-02-14 14:01:13 +01:00
|
|
|
std::function<void()> onFailure);
|
2018-08-06 21:17:03 +02:00
|
|
|
|
2024-10-13 12:38:10 +02:00
|
|
|
void blockUserLocally(const QString &userID);
|
|
|
|
|
2023-07-23 13:26:12 +02:00
|
|
|
[[nodiscard]] const std::unordered_set<TwitchUser> &blocks() const;
|
|
|
|
[[nodiscard]] const std::unordered_set<QString> &blockedUserIds() const;
|
2018-05-12 20:34:13 +02:00
|
|
|
|
2019-01-20 14:45:59 +01:00
|
|
|
// Automod actions
|
2021-05-14 13:14:43 +02:00
|
|
|
void autoModAllow(const QString msgID, ChannelPtr channel);
|
|
|
|
void autoModDeny(const QString msgID, ChannelPtr channel);
|
2019-01-20 14:45:59 +01:00
|
|
|
|
2023-07-29 11:49:44 +02:00
|
|
|
void loadSeventvUserID();
|
|
|
|
|
2024-09-01 11:22:54 +02:00
|
|
|
/// Returns true if the account has access to the given emote set
|
|
|
|
bool hasEmoteSet(const EmoteSetId &id) const;
|
|
|
|
|
2024-10-13 12:38:10 +02:00
|
|
|
/// Returns a map of emote sets the account has access to
|
2024-09-01 11:22:54 +02:00
|
|
|
///
|
|
|
|
/// Key being the emote set ID, and contents being information about the emote set
|
|
|
|
/// and the emotes contained in the emote set
|
|
|
|
SharedAccessGuard<std::shared_ptr<const TwitchEmoteSetMap>>
|
|
|
|
accessEmoteSets() const;
|
|
|
|
|
2024-10-13 12:38:10 +02:00
|
|
|
/// Returns a map of emotes the account has access to
|
2024-09-01 11:22:54 +02:00
|
|
|
SharedAccessGuard<std::shared_ptr<const EmoteMap>> accessEmotes() const;
|
|
|
|
|
2024-10-13 12:38:10 +02:00
|
|
|
/// Sets the emotes this account has access to
|
|
|
|
///
|
|
|
|
/// This should only be used in tests.
|
|
|
|
void setEmotes(std::shared_ptr<const EmoteMap> emotes);
|
|
|
|
|
2024-09-01 11:22:54 +02:00
|
|
|
/// Return the emote by emote name if the account has access to the emote
|
|
|
|
std::optional<EmotePtr> twitchEmote(const EmoteName &name) const;
|
|
|
|
|
|
|
|
/// Once emotes are reloaded, TwitchAccountManager::emotesReloaded is
|
|
|
|
/// invoked with @a caller and an optional error.
|
|
|
|
void reloadEmotes(void *caller = nullptr);
|
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
private:
|
2018-07-06 19:23:47 +02:00
|
|
|
QString oauthClient_;
|
|
|
|
QString oauthToken_;
|
|
|
|
QString userName_;
|
|
|
|
QString userId_;
|
|
|
|
const bool isAnon_;
|
2018-08-11 17:35:46 +02:00
|
|
|
Atomic<QColor> color_;
|
2018-07-06 19:23:47 +02:00
|
|
|
|
2021-06-20 00:11:06 +02:00
|
|
|
QStringList userstateEmoteSets_;
|
2023-07-23 13:26:12 +02:00
|
|
|
|
|
|
|
ScopedCancellationToken blockToken_;
|
|
|
|
std::unordered_set<TwitchUser> ignores_;
|
|
|
|
std::unordered_set<QString> ignoresUserIds_;
|
2018-08-02 14:23:27 +02:00
|
|
|
|
2024-09-01 11:22:54 +02:00
|
|
|
ScopedCancellationToken emoteToken_;
|
|
|
|
UniqueAccess<std::shared_ptr<const TwitchEmoteSetMap>> emoteSets_;
|
|
|
|
UniqueAccess<std::shared_ptr<const EmoteMap>> emotes_;
|
2023-07-29 11:49:44 +02:00
|
|
|
|
|
|
|
QString seventvUserID_;
|
2017-04-12 17:46:44 +02:00
|
|
|
};
|
2018-03-31 13:44:15 +02:00
|
|
|
|
2017-05-27 17:45:40 +02:00
|
|
|
} // namespace chatterino
|