2021-11-22 22:24:18 +01:00
|
|
|
//
|
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2021
|
|
|
|
//
|
|
|
|
// 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
|
|
|
|
|
|
|
|
#include "td/telegram/DialogId.h"
|
2021-11-23 05:45:32 +01:00
|
|
|
#include "td/telegram/FolderId.h"
|
2021-11-22 22:24:18 +01:00
|
|
|
#include "td/telegram/td_api.h"
|
|
|
|
|
|
|
|
#include "td/utils/common.h"
|
2021-11-23 09:41:35 +01:00
|
|
|
#include "td/utils/tl_helpers.h"
|
2021-11-22 22:24:18 +01:00
|
|
|
|
|
|
|
namespace td {
|
|
|
|
|
2021-11-23 05:45:32 +01:00
|
|
|
class Td;
|
|
|
|
|
2021-11-23 10:05:32 +01:00
|
|
|
class DialogActionBar {
|
|
|
|
int32 distance_ = -1; // distance to the peer
|
2021-11-22 22:24:18 +01:00
|
|
|
|
2021-11-23 10:05:32 +01:00
|
|
|
bool can_report_spam_ = false;
|
|
|
|
bool can_add_contact_ = false;
|
|
|
|
bool can_block_user_ = false;
|
|
|
|
bool can_share_phone_number_ = false;
|
|
|
|
bool can_report_location_ = false;
|
|
|
|
bool can_unarchive_ = false;
|
|
|
|
bool can_invite_members_ = false;
|
2021-11-22 22:24:18 +01:00
|
|
|
|
2021-11-23 10:05:32 +01:00
|
|
|
friend bool operator==(const unique_ptr<DialogActionBar> &lhs, const unique_ptr<DialogActionBar> &rhs);
|
|
|
|
|
|
|
|
public:
|
2021-11-22 22:24:18 +01:00
|
|
|
static unique_ptr<DialogActionBar> create(bool can_report_spam, bool can_add_contact, bool can_block_user,
|
|
|
|
bool can_share_phone_number, bool can_report_location, bool can_unarchive,
|
|
|
|
int32 distance, bool can_invite_members);
|
|
|
|
|
2021-11-23 07:35:38 +01:00
|
|
|
bool is_empty() const;
|
|
|
|
|
2021-11-23 10:05:32 +01:00
|
|
|
bool can_report_spam() const {
|
|
|
|
return can_report_spam_;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool can_unarchive() const {
|
|
|
|
return can_unarchive_;
|
|
|
|
}
|
|
|
|
|
2021-11-22 22:24:18 +01:00
|
|
|
td_api::object_ptr<td_api::ChatActionBar> get_chat_action_bar_object(DialogType dialog_type,
|
|
|
|
bool hide_unarchive) const;
|
2021-11-23 05:45:32 +01:00
|
|
|
|
|
|
|
void fix(Td *td, DialogId dialog_id, bool is_dialog_blocked, FolderId folder_id);
|
2021-11-23 07:27:30 +01:00
|
|
|
|
|
|
|
bool on_dialog_unarchived();
|
|
|
|
|
|
|
|
bool on_user_contact_added();
|
|
|
|
|
|
|
|
bool on_user_deleted();
|
|
|
|
|
|
|
|
bool on_outgoing_message();
|
2021-11-23 09:41:35 +01:00
|
|
|
|
|
|
|
template <class StorerT>
|
|
|
|
void store(StorerT &storer) const {
|
2021-11-23 10:05:32 +01:00
|
|
|
bool has_distance = distance_ >= 0;
|
2021-11-23 09:41:35 +01:00
|
|
|
BEGIN_STORE_FLAGS();
|
2021-11-23 10:05:32 +01:00
|
|
|
STORE_FLAG(can_report_spam_);
|
|
|
|
STORE_FLAG(can_add_contact_);
|
|
|
|
STORE_FLAG(can_block_user_);
|
|
|
|
STORE_FLAG(can_share_phone_number_);
|
|
|
|
STORE_FLAG(can_report_location_);
|
|
|
|
STORE_FLAG(can_unarchive_);
|
|
|
|
STORE_FLAG(can_invite_members_);
|
2021-11-23 09:41:35 +01:00
|
|
|
STORE_FLAG(has_distance);
|
|
|
|
END_STORE_FLAGS();
|
|
|
|
if (has_distance) {
|
2021-11-23 10:05:32 +01:00
|
|
|
td::store(distance_, storer);
|
2021-11-23 09:41:35 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class ParserT>
|
|
|
|
void parse(ParserT &parser) {
|
|
|
|
bool has_distance;
|
|
|
|
BEGIN_PARSE_FLAGS();
|
2021-11-23 10:05:32 +01:00
|
|
|
PARSE_FLAG(can_report_spam_);
|
|
|
|
PARSE_FLAG(can_add_contact_);
|
|
|
|
PARSE_FLAG(can_block_user_);
|
|
|
|
PARSE_FLAG(can_share_phone_number_);
|
|
|
|
PARSE_FLAG(can_report_location_);
|
|
|
|
PARSE_FLAG(can_unarchive_);
|
|
|
|
PARSE_FLAG(can_invite_members_);
|
2021-11-23 09:41:35 +01:00
|
|
|
PARSE_FLAG(has_distance);
|
|
|
|
END_PARSE_FLAGS();
|
|
|
|
if (has_distance) {
|
2021-11-23 10:05:32 +01:00
|
|
|
td::parse(distance_, parser);
|
2021-11-23 09:41:35 +01:00
|
|
|
}
|
|
|
|
}
|
2021-11-22 22:24:18 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
bool operator==(const unique_ptr<DialogActionBar> &lhs, const unique_ptr<DialogActionBar> &rhs);
|
|
|
|
|
|
|
|
} // namespace td
|