libkazv
inbound-group-session.hpp
Go to the documentation of this file.
1 /*
2  * This file is part of libkazv.
3  * SPDX-FileCopyrightText: 2021 Tusooa Zhu <tusooa@kazv.moe>
4  * SPDX-License-Identifier: AGPL-3.0-or-later
5  */
6 
7 #pragma once
8 #include <libkazv-config.hpp>
9 
10 #include <memory>
11 
12 #include <maybe.hpp>
13 #include <event.hpp>
14 
15 #include "crypto-util.hpp"
16 
17 namespace Kazv
18 {
19  struct InboundGroupSessionPrivate;
20 
22  {
23  public:
24  struct ImportTag {};
25  explicit InboundGroupSession();
26  explicit InboundGroupSession(std::string sessionKey, std::string ed25519Key);
27 
33 
34  MaybeString decrypt(std::string message, std::string eventId, Timestamp originServerTs);
35 
36  bool valid() const;
37 
45  bool isImported() const;
46 
47  std::string ed25519Key() const;
48 
55  bool merge(InboundGroupSession &that);
56 
64  std::string toExportFormat() const;
65 
66  private:
67  friend void to_json(nlohmann::json &j, const InboundGroupSession &s);
68  friend void from_json(const nlohmann::json &j, InboundGroupSession &s);
69  std::unique_ptr<InboundGroupSessionPrivate> m_d;
70  };
71 }
Definition: inbound-group-session.hpp:22
std::string toExportFormat() const
Export the session to session-export format.
Definition: inbound-group-session.cpp:188
MaybeString decrypt(std::string message, std::string eventId, Timestamp originServerTs)
Definition: inbound-group-session.cpp:132
InboundGroupSession & operator=(const InboundGroupSession &that)
Definition: inbound-group-session.cpp:110
InboundGroupSession()
Definition: inbound-group-session.cpp:88
bool valid() const
Definition: inbound-group-session.cpp:122
bool isImported() const
Check whether this session is imported (from the session-export format).
Definition: inbound-group-session.cpp:127
bool merge(InboundGroupSession &that)
Try to merge this session with another session.
Definition: inbound-group-session.cpp:167
std::string ed25519Key() const
Definition: inbound-group-session.cpp:162
friend void from_json(const nlohmann::json &j, InboundGroupSession &s)
Definition: inbound-group-session.cpp:208
friend void to_json(nlohmann::json &j, const InboundGroupSession &s)
Definition: inbound-group-session.cpp:195
Definition: maybe.hpp:25
Definition: location.hpp:10
nlohmann::json json
Definition: jsonwrap.hpp:20
std::int_fast64_t Timestamp
Definition: event.hpp:18
Definition: inbound-group-session.hpp:24