blob: 7e99c60c9390fe1596b081e76270defc563388fa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
#pragma once
#include "types.hpp"
#include <string>
#include <odhtdb/Signature.hpp>
namespace dchat
{
class User
{
public:
enum class Type
{
OTHER,
ONLINE_REMOTE_USER,
ONLINE_LOCAL_USER,
ONLINE_DISCORD_USER,
OFFLINE,
SYSTEM
};
User(Type type);
virtual ~User(){}
virtual const std::string& getName() const = 0;
virtual bool isOnlineUser() const { return false; }
virtual bool isConnected(i64 timestampUtcSec) const { return true; }
const Type type;
std::string avatarUrl;
};
class OnlineUser : public User
{
public:
OnlineUser(const std::string &name, Type type);
virtual ~OnlineUser(){}
virtual const std::string& getName() const override;
virtual const odhtdb::Signature::PublicKey& getPublicKey() const = 0;
bool isConnected(i64 timestampUtcSec) const override;
bool isOnlineUser() const override { return true; }
std::string name;
u32 pingTimestampSec;
};
class OnlineRemoteUser : public OnlineUser
{
public:
OnlineRemoteUser(const std::string &name, const odhtdb::Signature::PublicKey &publicKey);
virtual const odhtdb::Signature::PublicKey& getPublicKey() const override;
const odhtdb::Signature::PublicKey publicKey;
};
class OnlineLocalUser : public OnlineUser
{
public:
OnlineLocalUser(const std::string &name, const odhtdb::Signature::KeyPair &keyPair);
virtual const odhtdb::Signature::PublicKey& getPublicKey() const override;
const odhtdb::Signature::KeyPair keyPair;
};
class OnlineDiscordUser : public OnlineUser
{
public:
OnlineDiscordUser(const std::string &discordUserName, u64 discordUserId, User *bridgeOwner);
virtual const odhtdb::Signature::PublicKey& getPublicKey() const override;
u64 discordUserId;
User *bridgeOwner;
};
class OfflineUser : public User
{
public:
OfflineUser(const std::string &name);
virtual const std::string& getName() const override;
const std::string name;
};
class SystemUser : public User
{
public:
SystemUser();
virtual const std::string& getName() const override;
};
}
|