blob: 94ff0550ba38d120064afedf8114a7a70fef42c7 (
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
|
//
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2026
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#include "td/telegram/ReactionNotificationsFrom.h"
namespace td {
ReactionNotificationsFrom::ReactionNotificationsFrom(
td_api::object_ptr<td_api::ReactionNotificationSource> &¬ification_source) {
if (notification_source == nullptr) {
type_ = Type::None;
return;
}
switch (notification_source->get_id()) {
case td_api::reactionNotificationSourceNone::ID:
type_ = Type::None;
break;
case td_api::reactionNotificationSourceContacts::ID:
type_ = Type::Contacts;
break;
case td_api::reactionNotificationSourceAll::ID:
type_ = Type::All;
break;
default:
UNREACHABLE();
}
}
ReactionNotificationsFrom::ReactionNotificationsFrom(
telegram_api::object_ptr<telegram_api::ReactionNotificationsFrom> &¬ifications_from) {
if (notifications_from == nullptr) {
type_ = Type::None;
return;
}
switch (notifications_from->get_id()) {
case telegram_api::reactionNotificationsFromContacts::ID:
type_ = Type::Contacts;
break;
case telegram_api::reactionNotificationsFromAll::ID:
type_ = Type::All;
break;
default:
UNREACHABLE();
}
}
td_api::object_ptr<td_api::ReactionNotificationSource>
ReactionNotificationsFrom::get_reaction_notification_source_object() const {
switch (type_) {
case Type::None:
return td_api::make_object<td_api::reactionNotificationSourceNone>();
case Type::Contacts:
return td_api::make_object<td_api::reactionNotificationSourceContacts>();
case Type::All:
return td_api::make_object<td_api::reactionNotificationSourceAll>();
default:
UNREACHABLE();
return nullptr;
}
}
telegram_api::object_ptr<telegram_api::ReactionNotificationsFrom>
ReactionNotificationsFrom::get_input_reaction_notifications_from() const {
switch (type_) {
case Type::None:
return nullptr;
case Type::Contacts:
return telegram_api::make_object<telegram_api::reactionNotificationsFromContacts>();
case Type::All:
return telegram_api::make_object<telegram_api::reactionNotificationsFromAll>();
default:
UNREACHABLE();
return nullptr;
}
}
bool operator==(const ReactionNotificationsFrom &lhs, const ReactionNotificationsFrom &rhs) {
return lhs.type_ == rhs.type_;
}
StringBuilder &operator<<(StringBuilder &string_builder, const ReactionNotificationsFrom ¬ifications_from) {
switch (notifications_from.type_) {
case ReactionNotificationsFrom::Type::None:
return string_builder << "disabled";
case ReactionNotificationsFrom::Type::Contacts:
return string_builder << "contacts";
case ReactionNotificationsFrom::Type::All:
return string_builder << "all";
default:
UNREACHABLE();
return string_builder;
}
}
} // namespace td
|