2019-11-11 17:14:32 +01:00
|
|
|
//
|
2022-12-31 22:28:08 +01:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
|
2019-11-11 17:14:32 +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/td_api.h"
|
|
|
|
#include "td/telegram/UserId.h"
|
|
|
|
|
|
|
|
#include "td/utils/common.h"
|
|
|
|
#include "td/utils/StringBuilder.h"
|
|
|
|
#include "td/utils/tl_helpers.h"
|
|
|
|
|
|
|
|
namespace td {
|
|
|
|
|
|
|
|
class ContactsManager;
|
|
|
|
|
|
|
|
class DialogAdministrator {
|
|
|
|
UserId user_id_;
|
|
|
|
string rank_;
|
2019-12-07 21:38:05 +01:00
|
|
|
bool is_creator_ = false;
|
2019-11-11 17:14:32 +01:00
|
|
|
|
2021-01-13 14:28:24 +01:00
|
|
|
friend StringBuilder &operator<<(StringBuilder &string_builder, const DialogAdministrator &administrator);
|
2019-11-11 17:14:32 +01:00
|
|
|
|
|
|
|
public:
|
|
|
|
DialogAdministrator() = default;
|
|
|
|
|
2019-12-07 21:38:05 +01:00
|
|
|
DialogAdministrator(UserId user_id, const string &rank, bool is_creator)
|
|
|
|
: user_id_(user_id), rank_(rank), is_creator_(is_creator) {
|
2019-11-11 17:14:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
td_api::object_ptr<td_api::chatAdministrator> get_chat_administrator_object(
|
|
|
|
const ContactsManager *contacts_manager) const;
|
|
|
|
|
|
|
|
UserId get_user_id() const {
|
|
|
|
return user_id_;
|
|
|
|
}
|
|
|
|
|
|
|
|
const string &get_rank() const {
|
|
|
|
return rank_;
|
|
|
|
}
|
|
|
|
|
2019-12-07 21:38:05 +01:00
|
|
|
bool is_creator() const {
|
|
|
|
return is_creator_;
|
|
|
|
}
|
|
|
|
|
2019-11-11 17:14:32 +01:00
|
|
|
template <class StorerT>
|
|
|
|
void store(StorerT &storer) const {
|
|
|
|
using td::store;
|
|
|
|
bool has_rank = !rank_.empty();
|
|
|
|
BEGIN_STORE_FLAGS();
|
|
|
|
STORE_FLAG(has_rank);
|
2019-12-07 21:38:05 +01:00
|
|
|
STORE_FLAG(is_creator_);
|
2019-11-11 17:14:32 +01:00
|
|
|
END_STORE_FLAGS();
|
|
|
|
store(user_id_, storer);
|
|
|
|
if (has_rank) {
|
|
|
|
store(rank_, storer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class ParserT>
|
|
|
|
void parse(ParserT &parser) {
|
|
|
|
using td::parse;
|
|
|
|
bool has_rank;
|
|
|
|
BEGIN_PARSE_FLAGS();
|
|
|
|
PARSE_FLAG(has_rank);
|
2019-12-07 21:38:05 +01:00
|
|
|
PARSE_FLAG(is_creator_);
|
2019-11-11 17:14:32 +01:00
|
|
|
END_PARSE_FLAGS();
|
|
|
|
parse(user_id_, parser);
|
|
|
|
if (has_rank) {
|
|
|
|
parse(rank_, parser);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
inline bool operator==(const DialogAdministrator &lhs, const DialogAdministrator &rhs) {
|
2019-12-07 21:38:05 +01:00
|
|
|
return lhs.get_user_id() == rhs.get_user_id() && lhs.get_rank() == rhs.get_rank() &&
|
|
|
|
lhs.is_creator() == rhs.is_creator();
|
2019-11-11 17:14:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
inline bool operator!=(const DialogAdministrator &lhs, const DialogAdministrator &rhs) {
|
|
|
|
return !(lhs == rhs);
|
|
|
|
}
|
|
|
|
|
|
|
|
StringBuilder &operator<<(StringBuilder &string_builder, const DialogAdministrator &administrator);
|
|
|
|
|
|
|
|
} // namespace td
|