1 //
2 // Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2021
3 //
4 // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 //
7 #pragma once
8 
9 #include "td/telegram/td_api.h"
10 
11 #include "td/utils/common.h"
12 #include "td/utils/Slice.h"
13 #include "td/utils/Status.h"
14 #include "td/utils/StringBuilder.h"
15 
16 namespace td {
17 
18 class DialogSource {
19   enum class Type : int32 { Membership, MtprotoProxy, PublicServiceAnnouncement };
20   Type type_ = Type::Membership;
21   string psa_type_;
22   string psa_text_;
23 
24   friend bool operator==(const DialogSource &lhs, const DialogSource &rhs);
25 
26   friend bool operator!=(const DialogSource &lhs, const DialogSource &rhs);
27 
28   friend StringBuilder &operator<<(StringBuilder &string_builder, const DialogSource &source);
29 
30  public:
31   static DialogSource mtproto_proxy();
32 
33   static DialogSource public_service_announcement(string psa_type, string psa_text);
34 
35   static Result<DialogSource> unserialize(Slice str);
36 
37   string serialize() const;
38 
39   td_api::object_ptr<td_api::ChatSource> get_chat_source_object() const;
40 };
41 
42 bool operator==(const DialogSource &lhs, const DialogSource &rhs);
43 
44 bool operator!=(const DialogSource &lhs, const DialogSource &rhs);
45 
46 StringBuilder &operator<<(StringBuilder &string_builder, const DialogSource &source);
47 
48 }  // namespace td
49