Debian Codegraph @

mtxclient/include/mtx/events/nheko_extensions/event_expiry.hpp

raw symbols SCIP
1 #pragma once
2
3 /// @file
4 /// @brief A nheko specific event in account data used to delete events meeting certain criteria
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 namespace mtx {
13 namespace events {
14 namespace account_data {
15 //! Custom nheko specific event types
16 namespace nheko_extensions {
17 //! Custom event to delete certain events automatically (e.g. after a certain time). Can be
18 //! configured globally or per room.
19 struct EventExpiry
20 {
21 //! If state events should be protected from deletion. Defaults to false, however the latest
22 //! state event of a specific (event_type,state_key) is always protected.
23 bool exclude_state_events = false;
24
25 //! When to delete old events. Set to 0 or remove to not delete events based on time.
26 //! Uses the origin_server_ts so keep your clocks in sync. Too small of an expiration timeout
27 //! might be annoying.
28 std::uint64_t expire_after_ms = 0;
29
30 //! Protect recent N messages from deletion, even if other criteria match.
31 //! By default no messages are protected (but you need to configure a criteria to match anything
32 //! anyway). This can be used to be less disruptive in recent conversations.
33 std::uint64_t protect_latest = 0;
34
35 //! Deletes anything but the latest N messages. Set to 0 to disable (because keeping no messages
36 //! makes no sense, since then you would just send nothing). If this is lower than
37 //! `protect_latest`, it will effectively default to that (but will be disabled when set to 0).
38 //! Clients might run deletions only on a certain interval.
39 std::uint64_t keep_only_latest = 0;
40
41 friend void from_json(const nlohmann::json &obj, EventExpiry &content);
42 friend void to_json(nlohmann::json &obj, const EventExpiry &content);
43 };
44 }
45 } // namespace account_data
46 } // namespace events
47 } // namespace mtx