blob: d0a5dd4f11606884c95e186c3aee2b5e90d1b0b9 (
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
|
//
// 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/EmailVerification.h"
#include "td/telegram/misc.h"
namespace td {
EmailVerification::EmailVerification(td_api::object_ptr<td_api::EmailAddressAuthentication> &&code) {
if (code == nullptr) {
return;
}
switch (code->get_id()) {
case td_api::emailAddressAuthenticationCode::ID:
type_ = Type::Code;
code_ = static_cast<const td_api::emailAddressAuthenticationCode *>(code.get())->code_;
break;
case td_api::emailAddressAuthenticationAppleId::ID:
type_ = Type::Apple;
code_ = static_cast<const td_api::emailAddressAuthenticationAppleId *>(code.get())->token_;
break;
case td_api::emailAddressAuthenticationGoogleId::ID:
type_ = Type::Google;
code_ = static_cast<const td_api::emailAddressAuthenticationGoogleId *>(code.get())->token_;
break;
default:
UNREACHABLE();
break;
}
if (!clean_input_string(code_)) {
*this = {};
}
}
telegram_api::object_ptr<telegram_api::EmailVerification> EmailVerification::get_input_email_verification() const {
switch (type_) {
case Type::Code:
return telegram_api::make_object<telegram_api::emailVerificationCode>(code_);
case Type::Apple:
return telegram_api::make_object<telegram_api::emailVerificationApple>(code_);
case Type::Google:
return telegram_api::make_object<telegram_api::emailVerificationGoogle>(code_);
default:
UNREACHABLE();
return nullptr;
}
}
} // namespace td
|