2021-11-22 22:24:18 +01:00
|
|
|
//
|
2022-12-31 22:28:08 +01:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
|
2021-11-22 22:24:18 +01: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
|
|
|
|
|
|
|
|
#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-23 11:06:38 +01:00
|
|
|
int32 join_request_date_ = 0;
|
|
|
|
string join_request_dialog_title_;
|
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-23 11:06:38 +01:00
|
|
|
bool is_join_request_broadcast_ = 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,
|
2021-11-23 11:06:38 +01:00
|
|
|
int32 distance, bool can_invite_members, string join_request_dialog_title,
|
|
|
|
bool is_join_request_broadcast, int32 join_request_date);
|
2021-11-22 22:24:18 +01:00
|
|
|
|
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 11:06:38 +01:00
|
|
|
bool has_join_request = !join_request_dialog_title_.empty();
|
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);
|
2021-11-23 11:06:38 +01:00
|
|
|
STORE_FLAG(is_join_request_broadcast_);
|
|
|
|
STORE_FLAG(has_join_request);
|
2021-11-23 09:41:35 +01:00
|
|
|
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
|
|
|
}
|
2021-11-23 11:06:38 +01:00
|
|
|
if (has_join_request) {
|
|
|
|
td::store(join_request_dialog_title_, storer);
|
|
|
|
td::store(join_request_date_, storer);
|
|
|
|
}
|
2021-11-23 09:41:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class ParserT>
|
|
|
|
void parse(ParserT &parser) {
|
|
|
|
bool has_distance;
|
2021-11-23 11:06:38 +01:00
|
|
|
bool has_join_request;
|
2021-11-23 09:41:35 +01:00
|
|
|
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);
|
2021-11-23 11:06:38 +01:00
|
|
|
PARSE_FLAG(is_join_request_broadcast_);
|
|
|
|
PARSE_FLAG(has_join_request);
|
2021-11-23 09:41:35 +01:00
|
|
|
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-23 11:06:38 +01:00
|
|
|
if (has_join_request) {
|
|
|
|
td::parse(join_request_dialog_title_, parser);
|
|
|
|
td::parse(join_request_date_, 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
|