summaryrefslogtreecommitdiff
path: root/discord/activity.cpp
blob: b7285a94ad6021f49f89c97245edfea2ec6c04b2 (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
93
94
95
96
97
98
99
100
101
#include "activity.hpp"

void from_json(const nlohmann::json &j, ActivityTimestamps &m) {
    JS_O("start", m.Start);
    JS_O("end", m.End);
}

void to_json(nlohmann::json &j, const ActivityTimestamps &m) {
    JS_IF("start", m.Start);
    JS_IF("end", m.End);
}

void from_json(const nlohmann::json &j, ActivityEmoji &m) {
    JS_D("name", m.Name);
    JS_O("id", m.ID);
    JS_O("animated", m.IsAnimated);
}

void to_json(nlohmann::json &j, const ActivityEmoji &m) {
    j["name"] = m.Name;
    if (m.ID.has_value())
        j["id"] = *m.ID;
    if (m.IsAnimated.has_value())
        j["animated"] = *m.IsAnimated;
}

void from_json(const nlohmann::json &j, ActivityParty &m) {
    JS_O("id", m.ID);
    JS_O("size", m.Size);
}

void to_json(nlohmann::json &j, const ActivityParty &m) {
    JS_IF("id", m.ID);
    JS_IF("size", m.Size);
}

void from_json(const nlohmann::json &j, ActivityAssets &m) {
    JS_O("large_image", m.LargeImage);
    JS_O("large_text", m.LargeText);
    JS_O("small_image", m.SmallImage);
    JS_O("small_text", m.SmallText);
}

void to_json(nlohmann::json &j, const ActivityAssets &m) {
    JS_IF("large_image", m.LargeImage);
    JS_IF("large_text", m.LargeText);
    JS_IF("small_image", m.SmallImage);
    JS_IF("small_text", m.SmallText);
}

void from_json(const nlohmann::json &j, ActivitySecrets &m) {
    JS_O("join", m.Join);
    JS_O("spectate", m.Spectate);
    JS_O("match", m.Match);
}

void to_json(nlohmann::json &j, const ActivitySecrets &m) {
    JS_IF("join", m.Join);
    JS_IF("spectate", m.Spectate);
    JS_IF("match", m.Match);
}

void from_json(const nlohmann::json &j, Activity &m) {
    JS_D("name", m.Name);
    JS_D("type", m.Type);
    JS_ON("url", m.URL);
    JS_D("created_at", m.CreatedAt);
    JS_O("timestamps", m.Timestamps);
    JS_O("application_id", m.ApplicationID);
    JS_ON("details", m.Details);
    JS_ON("state", m.State);
    JS_ON("emoji", m.Emoji);
    JS_ON("party", m.Party);
    JS_O("assets", m.Assets);
    JS_O("secrets", m.Secrets);
    JS_O("instance", m.IsInstance);
    JS_O("flags", m.Flags);
}

void to_json(nlohmann::json &j, const Activity &m) {
    if (m.Type == ActivityType::Custom) {
        j["name"] = "Custom Status";
        j["state"] = m.Name;
    } else {
        j["name"] = m.Name;
        JS_IF("state", m.State);
    }

    j["type"] = m.Type;
    JS_IF("url", m.URL);
    JS_IF("created_at", m.CreatedAt);
    JS_IF("timestamps", m.Timestamps);
    JS_IF("application_id", m.ApplicationID);
    JS_IF("details", m.Details);
    JS_IF("emoji", m.Emoji);
    JS_IF("party", m.Party);
    JS_IF("assets", m.Assets);
    JS_IF("secrets", m.Secrets);
    JS_IF("instance", m.IsInstance);
    JS_IF("flags", m.Flags);
}