From 06f30543730c372226c398c11b3de0213d711d13 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Wed, 8 Aug 2018 23:17:10 +0200 Subject: Add support for discord --- include/Channel.hpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'include/Channel.hpp') diff --git a/include/Channel.hpp b/include/Channel.hpp index af6cbf2..663b163 100644 --- a/include/Channel.hpp +++ b/include/Channel.hpp @@ -5,7 +5,10 @@ #include "User.hpp" #include "Channel.hpp" #include "types.hpp" +#include "Suggestions.hpp" +#include "../bridge/DiscordService.hpp" #include +#include #include #include #include @@ -28,7 +31,9 @@ namespace dchat DELETE_MESSAGE, NICKNAME_CHANGE, CHANGE_AVATAR, - CHANGE_CHANNEL_NAME + CHANGE_CHANNEL_NAME, + + ADD_DISCORD_MESSAGE }; class Channel @@ -44,7 +49,7 @@ namespace dchat MessageBoard& getMessageBoard(); const std::string& getName() const; - const std::vector getUsers() const; + const std::vector& getUsers() const; OnlineUser* getUserByPublicKey(const odhtdb::Signature::PublicKey &publicKey); const odhtdb::DatabaseNode& getNodeInfo() const; Message* getLatestMessage(); @@ -52,8 +57,10 @@ namespace dchat // If timestamp is 0, then current time is used void addLocalMessage(const std::string &msg, User *owner, u64 timestampSeconds = 0); void addLocalMessage(const std::string &msg, User *owner, u64 timestampSeconds, const odhtdb::Hash &id); + void addLocalDiscordMessage(const std::string &discordUserName, u64 discordUserId, const std::string &msg, User *owner, u64 timestampSeconds, const odhtdb::Hash &id); void addSystemMessage(const std::string &msg, bool plainText = true); void addMessage(const std::string &msg); + void addDiscordMessage(const std::string &discordUserName, u64 discordUserId, const std::string &msg); void deleteLocalMessage(const odhtdb::Hash &id, const odhtdb::Signature::PublicKey &requestedByUser); void deleteMessage(const odhtdb::Hash &id, const odhtdb::Signature::PublicKey &requestedByUser); @@ -64,6 +71,9 @@ namespace dchat void setAvatar(const std::string &newAvatarUrl); void setNameLocally(const std::string &name); void setName(const std::string &name); + + // Returns -1 on failure + int getUserLowestPermissionLevel(OnlineUser *user) const; void processEvent(const sf::Event &event, Cache &cache); void draw(sf::RenderWindow &window, Cache &cache); @@ -71,6 +81,9 @@ namespace dchat void update(); // Returns 0 if we are offline u32 getSyncedTimestampUtcInSec(); + + const std::vector& getBridgeServices() const; + DiscordService* getDiscordService(); static void setCurrent(Channel *channel); static Channel* getCurrent(); @@ -82,12 +95,16 @@ namespace dchat std::string name; MessageBoard messageBoard; Chatbar chatbar; + Suggestions suggestions; User *localUser; SystemUser systemUser; std::vector users; + std::unordered_map discordUserById; odhtdb::Signature::MapPublicKey publicKeyOnlineUsersMap; dht::InfoHash pingKey; std::future pingListener; sf::Clock pingTimer; + + std::vector bridgeServices; }; } -- cgit v1.2.3