summaryrefslogtreecommitdiff
path: root/src/message.h
blob: 22da0fdcaa217e82aedb250d62586d1fa1ffe8a3 (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
#pragma once

#include <erebos/identity.h>
#include <erebos/message.h>
#include <erebos/storage.h>
#include <erebos/time.h>

#include <chrono>
#include <mutex>
#include <vector>

namespace chrono = std::chrono;
using chrono::system_clock;
using std::mutex;
using std::optional;
using std::string;
using std::vector;

namespace erebos {

struct DirectMessageData
{
	static DirectMessageData load(const Ref &);
	Ref store(const Storage &) const;

	vector<Stored<DirectMessageData>> prev;
	optional<Identity> from;
	optional<ZonedTime> time;
	optional<string> text;
};

struct DirectMessage::Priv
{
	Stored<DirectMessageData> data;
};

struct DirectMessageThread::Priv
{
	const Identity peer;
	const vector<Stored<DirectMessageData>> head;
};

struct DirectMessageThread::Iterator::Priv
{
	optional<DirectMessage> current;
	vector<Stored<DirectMessageData>> next;
};

struct DirectMessageState
{
	static DirectMessageState load(const Ref &);
	Ref store(const Storage &) const;

	vector<Stored<DirectMessageState>> prev;
	optional<Identity> peer;

	vector<Stored<DirectMessageData>> ready {};
	vector<Stored<DirectMessageData>> sent {};
	vector<Stored<DirectMessageData>> received {};
	vector<Stored<DirectMessageData>> seen {};
};

}