Debian Codegraph @

mtxclient/include/mtx/events/presence.hpp

raw symbols SCIP
1 #pragma once
2
3 /// @file
4 /// @brief An ephemeral event describing the presence of a user.
5
6 #if __has_include(<nlohmann/json_fwd.hpp>)
7 #include <nlohmann/json_fwd.hpp>
8 #else
9 #include <nlohmann/json.hpp>
10 #endif
11
12 #include <string>
13 #include <string_view>
14
15 namespace mtx {
16 //! Presence specific types.
17 namespace presence {
18 //! The current presence state.
19 enum PresenceState
20 {
21 online, //!< The user is online.
22 offline, //!< The user is offline.
23 unavailable, //!< The user is online, but currently not available.
24 };
25
26 std::string
27 to_string(PresenceState state);
28 PresenceState
29 from_string(std::string_view str);
30 }
31
32 namespace events {
33 namespace presence {
34 //! The `m.presence` ephemeral event.
35 struct Presence
36 {
37 std::string avatar_url; //! The current avatar URL for this user, if any.
38 std::string displayname; //! The current display name for this user, if any.
39 uint64_t
40 last_active_ago; //! The last time since this used performed some action, in milliseconds.
41 mtx::presence::PresenceState presence; //! Required. The presence state for this user. One
42 //! of: ["online", "offline", "unavailable"]
43 bool currently_active; //! Whether the user is currently active
44 std::string status_msg; //! An optional description to accompany the presence.
45
46 friend void from_json(const nlohmann::json &obj, Presence &presence);
47 friend void to_json(nlohmann::json &obj, const Presence &presence);
48 };
49 }
50 }
51 }