2020-07-11 22:50:21 +02:00
|
|
|
//
|
2024-01-01 01:07:21 +01:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2024
|
2020-07-11 22:50:21 +02:00
|
|
|
//
|
|
|
|
// 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)
|
|
|
|
//
|
|
|
|
#pragma once
|
|
|
|
|
2021-02-22 16:06:18 +01:00
|
|
|
#include "td/telegram/DialogId.h"
|
2020-07-11 22:50:21 +02:00
|
|
|
#include "td/telegram/td_api.h"
|
|
|
|
|
|
|
|
#include "td/utils/common.h"
|
2022-06-27 12:30:18 +02:00
|
|
|
#include "td/utils/Promise.h"
|
2020-07-11 22:50:21 +02:00
|
|
|
#include "td/utils/Slice.h"
|
|
|
|
|
|
|
|
namespace td {
|
|
|
|
|
2021-02-20 23:06:45 +01:00
|
|
|
struct SuggestedAction {
|
2021-06-11 01:48:10 +02:00
|
|
|
enum class Type : int32 {
|
|
|
|
Empty,
|
|
|
|
EnableArchiveAndMuteNewChats,
|
|
|
|
CheckPhoneNumber,
|
2021-12-23 18:00:41 +01:00
|
|
|
ViewChecksHint,
|
2021-06-11 01:48:10 +02:00
|
|
|
ConvertToGigagroup,
|
2021-11-26 14:22:39 +01:00
|
|
|
CheckPassword,
|
2023-01-23 14:03:32 +01:00
|
|
|
SetPassword,
|
2023-01-23 14:11:26 +01:00
|
|
|
UpgradePremium,
|
2023-04-25 15:48:16 +02:00
|
|
|
SubscribeToAnnualPremium,
|
2023-12-21 16:16:32 +01:00
|
|
|
RestorePremium,
|
2024-03-22 12:55:23 +01:00
|
|
|
GiftPremiumForChristmas,
|
|
|
|
BirthdaySetup
|
2021-06-11 01:48:10 +02:00
|
|
|
};
|
2021-02-20 23:06:45 +01:00
|
|
|
Type type_ = Type::Empty;
|
2021-02-22 16:06:18 +01:00
|
|
|
DialogId dialog_id_;
|
2021-11-26 14:22:39 +01:00
|
|
|
int32 otherwise_relogin_days_ = 0;
|
2020-07-11 22:50:21 +02:00
|
|
|
|
2021-02-20 23:06:45 +01:00
|
|
|
void init(Type type);
|
2020-07-11 22:50:21 +02:00
|
|
|
|
2021-02-20 23:06:45 +01:00
|
|
|
SuggestedAction() = default;
|
2020-07-11 22:50:21 +02:00
|
|
|
|
2021-11-26 14:22:39 +01:00
|
|
|
explicit SuggestedAction(Type type, DialogId dialog_id = DialogId(), int32 otherwise_relogin_days = 0)
|
|
|
|
: type_(type), dialog_id_(dialog_id), otherwise_relogin_days_(otherwise_relogin_days) {
|
2021-02-20 23:06:45 +01:00
|
|
|
}
|
2020-07-11 22:50:21 +02:00
|
|
|
|
2021-02-20 23:06:45 +01:00
|
|
|
explicit SuggestedAction(Slice action_str);
|
|
|
|
|
2021-02-22 16:06:18 +01:00
|
|
|
SuggestedAction(Slice action_str, DialogId dialog_id);
|
|
|
|
|
|
|
|
explicit SuggestedAction(const td_api::object_ptr<td_api::SuggestedAction> &suggested_action);
|
2021-02-20 23:06:45 +01:00
|
|
|
|
2021-02-22 21:34:10 +01:00
|
|
|
bool is_empty() const {
|
|
|
|
return type_ == Type::Empty;
|
|
|
|
}
|
|
|
|
|
2021-02-20 23:06:45 +01:00
|
|
|
string get_suggested_action_str() const;
|
|
|
|
|
|
|
|
td_api::object_ptr<td_api::SuggestedAction> get_suggested_action_object() const;
|
2024-03-30 22:35:02 +01:00
|
|
|
|
|
|
|
template <class StorerT>
|
|
|
|
void store(StorerT &storer) const;
|
|
|
|
|
|
|
|
template <class ParserT>
|
|
|
|
void parse(ParserT &parser);
|
2021-02-20 23:06:45 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
inline bool operator==(const SuggestedAction &lhs, const SuggestedAction &rhs) {
|
2021-02-22 17:38:40 +01:00
|
|
|
CHECK(lhs.dialog_id_ == rhs.dialog_id_);
|
2021-02-20 23:06:45 +01:00
|
|
|
return lhs.type_ == rhs.type_;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool operator!=(const SuggestedAction &lhs, const SuggestedAction &rhs) {
|
|
|
|
return !(lhs == rhs);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool operator<(const SuggestedAction &lhs, const SuggestedAction &rhs) {
|
2021-02-22 17:38:40 +01:00
|
|
|
CHECK(lhs.dialog_id_ == rhs.dialog_id_);
|
2021-02-20 23:06:45 +01:00
|
|
|
return static_cast<int32>(lhs.type_) < static_cast<int32>(rhs.type_);
|
|
|
|
}
|
2020-07-11 22:50:21 +02:00
|
|
|
|
2021-02-20 22:21:14 +01:00
|
|
|
td_api::object_ptr<td_api::updateSuggestedActions> get_update_suggested_actions_object(
|
2023-01-17 11:22:21 +01:00
|
|
|
const vector<SuggestedAction> &added_actions, const vector<SuggestedAction> &removed_actions, const char *source);
|
2021-02-20 22:21:14 +01:00
|
|
|
|
2024-03-30 23:10:26 +01:00
|
|
|
bool update_suggested_actions(vector<SuggestedAction> &suggested_actions,
|
2021-02-22 16:25:49 +01:00
|
|
|
vector<SuggestedAction> &&new_suggested_actions);
|
|
|
|
|
2024-03-30 23:10:26 +01:00
|
|
|
bool remove_suggested_action(vector<SuggestedAction> &suggested_actions, SuggestedAction suggested_action);
|
2021-02-22 16:25:49 +01:00
|
|
|
|
2021-11-26 12:48:43 +01:00
|
|
|
void dismiss_suggested_action(SuggestedAction action, Promise<Unit> &&promise);
|
|
|
|
|
2020-07-11 22:50:21 +02:00
|
|
|
} // namespace td
|