Move get_dialog_event_log to separate file.
This commit is contained in:
parent
4f1e5db8cd
commit
a3e9a0be1f
@ -302,6 +302,7 @@ set(TDLIB_SOURCE
|
||||
td/telegram/DialogAction.cpp
|
||||
td/telegram/DialogAdministrator.cpp
|
||||
td/telegram/DialogDb.cpp
|
||||
td/telegram/DialogEventLog.cpp
|
||||
td/telegram/DialogFilter.cpp
|
||||
td/telegram/DialogId.cpp
|
||||
td/telegram/DialogInviteLink.cpp
|
||||
@ -483,6 +484,7 @@ set(TDLIB_SOURCE
|
||||
td/telegram/DialogAdministrator.h
|
||||
td/telegram/DialogDate.h
|
||||
td/telegram/DialogDb.h
|
||||
td/telegram/DialogEventLog.h
|
||||
td/telegram/DialogFilter.h
|
||||
td/telegram/DialogFilterId.h
|
||||
td/telegram/DialogId.h
|
||||
|
496
td/telegram/DialogEventLog.cpp
Normal file
496
td/telegram/DialogEventLog.cpp
Normal file
@ -0,0 +1,496 @@
|
||||
//
|
||||
// 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)
|
||||
//
|
||||
#include "td/telegram/DialogEventLog.h"
|
||||
|
||||
#include "td/telegram/ChannelId.h"
|
||||
#include "td/telegram/ContactsManager.h"
|
||||
#include "td/telegram/DialogInviteLink.h"
|
||||
#include "td/telegram/DialogLocation.h"
|
||||
#include "td/telegram/DialogParticipant.h"
|
||||
#include "td/telegram/GroupCallManager.h"
|
||||
#include "td/telegram/GroupCallParticipant.h"
|
||||
#include "td/telegram/InputGroupCallId.h"
|
||||
#include "td/telegram/MessagesManager.h"
|
||||
#include "td/telegram/MessageTtlSetting.h"
|
||||
#include "td/telegram/StickersManager.h"
|
||||
#include "td/telegram/Td.h"
|
||||
|
||||
#include "td/utils/misc.h"
|
||||
|
||||
namespace td {
|
||||
|
||||
static td_api::object_ptr<td_api::ChatEventAction> get_chat_event_action_object(
|
||||
Td *td, ChannelId channel_id, tl_object_ptr<telegram_api::ChannelAdminLogEventAction> &&action_ptr) {
|
||||
CHECK(action_ptr != nullptr);
|
||||
switch (action_ptr->get_id()) {
|
||||
case telegram_api::channelAdminLogEventActionParticipantJoin::ID:
|
||||
return td_api::make_object<td_api::chatEventMemberJoined>();
|
||||
case telegram_api::channelAdminLogEventActionParticipantJoinByInvite::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionParticipantJoinByInvite>(action_ptr);
|
||||
DialogInviteLink invite_link(std::move(action->invite_));
|
||||
if (!invite_link.is_valid()) {
|
||||
LOG(ERROR) << "Wrong invite link: " << invite_link;
|
||||
return nullptr;
|
||||
}
|
||||
return td_api::make_object<td_api::chatEventMemberJoinedByInviteLink>(
|
||||
invite_link.get_chat_invite_link_object(td->contacts_manager_.get()));
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionParticipantJoinByRequest::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionParticipantJoinByRequest>(action_ptr);
|
||||
DialogInviteLink invite_link(std::move(action->invite_));
|
||||
if (!invite_link.is_valid()) {
|
||||
LOG(ERROR) << "Wrong invite link: " << invite_link;
|
||||
return nullptr;
|
||||
}
|
||||
UserId approver_user_id(action->approved_by_);
|
||||
if (!approver_user_id.is_valid()) {
|
||||
return nullptr;
|
||||
}
|
||||
return td_api::make_object<td_api::chatEventMemberJoinedByRequest>(
|
||||
td->contacts_manager_->get_user_id_object(approver_user_id, "chatEventMemberJoinedByRequest"),
|
||||
invite_link.get_chat_invite_link_object(td->contacts_manager_.get()));
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionParticipantLeave::ID:
|
||||
return td_api::make_object<td_api::chatEventMemberLeft>();
|
||||
case telegram_api::channelAdminLogEventActionParticipantInvite::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionParticipantInvite>(action_ptr);
|
||||
DialogParticipant dialog_participant(std::move(action->participant_));
|
||||
if (!dialog_participant.is_valid() || dialog_participant.dialog_id_.get_type() != DialogType::User) {
|
||||
LOG(ERROR) << "Wrong invite: " << dialog_participant;
|
||||
return nullptr;
|
||||
}
|
||||
return td_api::make_object<td_api::chatEventMemberInvited>(
|
||||
td->contacts_manager_->get_user_id_object(dialog_participant.dialog_id_.get_user_id(),
|
||||
"chatEventMemberInvited"),
|
||||
dialog_participant.status_.get_chat_member_status_object());
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionParticipantToggleBan::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionParticipantToggleBan>(action_ptr);
|
||||
DialogParticipant old_dialog_participant(std::move(action->prev_participant_));
|
||||
DialogParticipant new_dialog_participant(std::move(action->new_participant_));
|
||||
if (old_dialog_participant.dialog_id_ != new_dialog_participant.dialog_id_) {
|
||||
LOG(ERROR) << old_dialog_participant.dialog_id_ << " VS " << new_dialog_participant.dialog_id_;
|
||||
return nullptr;
|
||||
}
|
||||
if (!old_dialog_participant.is_valid() || !new_dialog_participant.is_valid()) {
|
||||
LOG(ERROR) << "Wrong restrict: " << old_dialog_participant << " -> " << new_dialog_participant;
|
||||
return nullptr;
|
||||
}
|
||||
return td_api::make_object<td_api::chatEventMemberRestricted>(
|
||||
td->messages_manager_->get_message_sender_object(old_dialog_participant.dialog_id_,
|
||||
"chatEventMemberRestricted"),
|
||||
old_dialog_participant.status_.get_chat_member_status_object(),
|
||||
new_dialog_participant.status_.get_chat_member_status_object());
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionParticipantToggleAdmin::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionParticipantToggleAdmin>(action_ptr);
|
||||
DialogParticipant old_dialog_participant(std::move(action->prev_participant_));
|
||||
DialogParticipant new_dialog_participant(std::move(action->new_participant_));
|
||||
if (old_dialog_participant.dialog_id_ != new_dialog_participant.dialog_id_) {
|
||||
LOG(ERROR) << old_dialog_participant.dialog_id_ << " VS " << new_dialog_participant.dialog_id_;
|
||||
return nullptr;
|
||||
}
|
||||
if (!old_dialog_participant.is_valid() || !new_dialog_participant.is_valid() ||
|
||||
old_dialog_participant.dialog_id_.get_type() != DialogType::User) {
|
||||
LOG(ERROR) << "Wrong edit administrator: " << old_dialog_participant << " -> " << new_dialog_participant;
|
||||
return nullptr;
|
||||
}
|
||||
return td_api::make_object<td_api::chatEventMemberPromoted>(
|
||||
td->contacts_manager_->get_user_id_object(old_dialog_participant.dialog_id_.get_user_id(),
|
||||
"chatEventMemberPromoted"),
|
||||
old_dialog_participant.status_.get_chat_member_status_object(),
|
||||
new_dialog_participant.status_.get_chat_member_status_object());
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionChangeTitle::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionChangeTitle>(action_ptr);
|
||||
return td_api::make_object<td_api::chatEventTitleChanged>(std::move(action->prev_value_),
|
||||
std::move(action->new_value_));
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionChangeAbout::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionChangeAbout>(action_ptr);
|
||||
return td_api::make_object<td_api::chatEventDescriptionChanged>(std::move(action->prev_value_),
|
||||
std::move(action->new_value_));
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionChangeUsername::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionChangeUsername>(action_ptr);
|
||||
return td_api::make_object<td_api::chatEventUsernameChanged>(std::move(action->prev_value_),
|
||||
std::move(action->new_value_));
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionChangePhoto::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionChangePhoto>(action_ptr);
|
||||
auto file_manager = td->file_manager_.get();
|
||||
auto old_photo = get_photo(file_manager, std::move(action->prev_photo_), DialogId(channel_id));
|
||||
auto new_photo = get_photo(file_manager, std::move(action->new_photo_), DialogId(channel_id));
|
||||
return td_api::make_object<td_api::chatEventPhotoChanged>(get_chat_photo_object(file_manager, old_photo),
|
||||
get_chat_photo_object(file_manager, new_photo));
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionDefaultBannedRights::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionDefaultBannedRights>(action_ptr);
|
||||
auto old_permissions = get_restricted_rights(std::move(action->prev_banned_rights_));
|
||||
auto new_permissions = get_restricted_rights(std::move(action->new_banned_rights_));
|
||||
return td_api::make_object<td_api::chatEventPermissionsChanged>(old_permissions.get_chat_permissions_object(),
|
||||
new_permissions.get_chat_permissions_object());
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionToggleInvites::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionToggleInvites>(action_ptr);
|
||||
return td_api::make_object<td_api::chatEventInvitesToggled>(action->new_value_);
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionToggleSignatures::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionToggleSignatures>(action_ptr);
|
||||
return td_api::make_object<td_api::chatEventSignMessagesToggled>(action->new_value_);
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionUpdatePinned::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionUpdatePinned>(action_ptr);
|
||||
auto message =
|
||||
td->messages_manager_->get_dialog_event_log_message_object(DialogId(channel_id), std::move(action->message_));
|
||||
if (message == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
if (message->is_pinned_) {
|
||||
return td_api::make_object<td_api::chatEventMessagePinned>(std::move(message));
|
||||
} else {
|
||||
return td_api::make_object<td_api::chatEventMessageUnpinned>(std::move(message));
|
||||
}
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionEditMessage::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionEditMessage>(action_ptr);
|
||||
auto old_message = td->messages_manager_->get_dialog_event_log_message_object(DialogId(channel_id),
|
||||
std::move(action->prev_message_));
|
||||
auto new_message = td->messages_manager_->get_dialog_event_log_message_object(DialogId(channel_id),
|
||||
std::move(action->new_message_));
|
||||
if (old_message == nullptr || new_message == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
return td_api::make_object<td_api::chatEventMessageEdited>(std::move(old_message), std::move(new_message));
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionStopPoll::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionStopPoll>(action_ptr);
|
||||
auto message =
|
||||
td->messages_manager_->get_dialog_event_log_message_object(DialogId(channel_id), std::move(action->message_));
|
||||
if (message == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
return td_api::make_object<td_api::chatEventPollStopped>(std::move(message));
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionDeleteMessage::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionDeleteMessage>(action_ptr);
|
||||
auto message =
|
||||
td->messages_manager_->get_dialog_event_log_message_object(DialogId(channel_id), std::move(action->message_));
|
||||
if (message == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
return td_api::make_object<td_api::chatEventMessageDeleted>(std::move(message));
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionChangeStickerSet::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionChangeStickerSet>(action_ptr);
|
||||
auto old_sticker_set_id = td->stickers_manager_->add_sticker_set(std::move(action->prev_stickerset_));
|
||||
auto new_sticker_set_id = td->stickers_manager_->add_sticker_set(std::move(action->new_stickerset_));
|
||||
return td_api::make_object<td_api::chatEventStickerSetChanged>(old_sticker_set_id.get(),
|
||||
new_sticker_set_id.get());
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionTogglePreHistoryHidden::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionTogglePreHistoryHidden>(action_ptr);
|
||||
return td_api::make_object<td_api::chatEventIsAllHistoryAvailableToggled>(!action->new_value_);
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionChangeLinkedChat::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionChangeLinkedChat>(action_ptr);
|
||||
|
||||
auto get_dialog_from_channel_id = [messages_manager = td->messages_manager_.get()](int64 channel_id_int) {
|
||||
ChannelId channel_id(channel_id_int);
|
||||
if (!channel_id.is_valid()) {
|
||||
return DialogId();
|
||||
}
|
||||
|
||||
DialogId dialog_id(channel_id);
|
||||
messages_manager->force_create_dialog(dialog_id, "get_dialog_from_channel_id");
|
||||
return dialog_id;
|
||||
};
|
||||
|
||||
auto old_linked_dialog_id = get_dialog_from_channel_id(action->prev_value_);
|
||||
auto new_linked_dialog_id = get_dialog_from_channel_id(action->new_value_);
|
||||
if (old_linked_dialog_id == new_linked_dialog_id) {
|
||||
LOG(ERROR) << "Receive the same linked " << new_linked_dialog_id;
|
||||
return nullptr;
|
||||
}
|
||||
return td_api::make_object<td_api::chatEventLinkedChatChanged>(old_linked_dialog_id.get(),
|
||||
new_linked_dialog_id.get());
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionChangeLocation::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionChangeLocation>(action_ptr);
|
||||
auto old_location = DialogLocation(std::move(action->prev_value_));
|
||||
auto new_location = DialogLocation(std::move(action->new_value_));
|
||||
return td_api::make_object<td_api::chatEventLocationChanged>(old_location.get_chat_location_object(),
|
||||
new_location.get_chat_location_object());
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionToggleSlowMode::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionToggleSlowMode>(action_ptr);
|
||||
auto old_slow_mode_delay = clamp(action->prev_value_, 0, 86400 * 366);
|
||||
auto new_slow_mode_delay = clamp(action->new_value_, 0, 86400 * 366);
|
||||
return td_api::make_object<td_api::chatEventSlowModeDelayChanged>(old_slow_mode_delay, new_slow_mode_delay);
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionExportedInviteEdit::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionExportedInviteEdit>(action_ptr);
|
||||
DialogInviteLink old_invite_link(std::move(action->prev_invite_));
|
||||
DialogInviteLink new_invite_link(std::move(action->new_invite_));
|
||||
if (!old_invite_link.is_valid() || !new_invite_link.is_valid()) {
|
||||
LOG(ERROR) << "Wrong edited invite link: " << old_invite_link << " -> " << new_invite_link;
|
||||
return nullptr;
|
||||
}
|
||||
return td_api::make_object<td_api::chatEventInviteLinkEdited>(
|
||||
old_invite_link.get_chat_invite_link_object(td->contacts_manager_.get()),
|
||||
new_invite_link.get_chat_invite_link_object(td->contacts_manager_.get()));
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionExportedInviteRevoke::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionExportedInviteRevoke>(action_ptr);
|
||||
DialogInviteLink invite_link(std::move(action->invite_));
|
||||
if (!invite_link.is_valid()) {
|
||||
LOG(ERROR) << "Wrong revoked invite link: " << invite_link;
|
||||
return nullptr;
|
||||
}
|
||||
return td_api::make_object<td_api::chatEventInviteLinkRevoked>(
|
||||
invite_link.get_chat_invite_link_object(td->contacts_manager_.get()));
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionExportedInviteDelete::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionExportedInviteDelete>(action_ptr);
|
||||
DialogInviteLink invite_link(std::move(action->invite_));
|
||||
if (!invite_link.is_valid()) {
|
||||
LOG(ERROR) << "Wrong deleted invite link: " << invite_link;
|
||||
return nullptr;
|
||||
}
|
||||
return td_api::make_object<td_api::chatEventInviteLinkDeleted>(
|
||||
invite_link.get_chat_invite_link_object(td->contacts_manager_.get()));
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionStartGroupCall::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionStartGroupCall>(action_ptr);
|
||||
auto input_group_call_id = InputGroupCallId(action->call_);
|
||||
if (!input_group_call_id.is_valid()) {
|
||||
return nullptr;
|
||||
}
|
||||
return td_api::make_object<td_api::chatEventVideoChatCreated>(
|
||||
td->group_call_manager_->get_group_call_id(input_group_call_id, DialogId(channel_id)).get());
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionDiscardGroupCall::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionDiscardGroupCall>(action_ptr);
|
||||
auto input_group_call_id = InputGroupCallId(action->call_);
|
||||
if (!input_group_call_id.is_valid()) {
|
||||
return nullptr;
|
||||
}
|
||||
return td_api::make_object<td_api::chatEventVideoChatDiscarded>(
|
||||
td->group_call_manager_->get_group_call_id(input_group_call_id, DialogId(channel_id)).get());
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionParticipantMute::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionParticipantMute>(action_ptr);
|
||||
GroupCallParticipant participant(action->participant_, 0);
|
||||
if (!participant.is_valid()) {
|
||||
return nullptr;
|
||||
}
|
||||
return td_api::make_object<td_api::chatEventVideoChatParticipantIsMutedToggled>(
|
||||
td->messages_manager_->get_message_sender_object(participant.dialog_id,
|
||||
"chatEventVideoChatParticipantIsMutedToggled"),
|
||||
true);
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionParticipantUnmute::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionParticipantUnmute>(action_ptr);
|
||||
GroupCallParticipant participant(action->participant_, 0);
|
||||
if (!participant.is_valid()) {
|
||||
return nullptr;
|
||||
}
|
||||
return td_api::make_object<td_api::chatEventVideoChatParticipantIsMutedToggled>(
|
||||
td->messages_manager_->get_message_sender_object(participant.dialog_id,
|
||||
"chatEventVideoChatParticipantIsMutedToggled"),
|
||||
false);
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionParticipantVolume::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionParticipantVolume>(action_ptr);
|
||||
GroupCallParticipant participant(action->participant_, 0);
|
||||
if (!participant.is_valid()) {
|
||||
return nullptr;
|
||||
}
|
||||
return td_api::make_object<td_api::chatEventVideoChatParticipantVolumeLevelChanged>(
|
||||
td->messages_manager_->get_message_sender_object(participant.dialog_id,
|
||||
"chatEventVideoChatParticipantVolumeLevelChanged"),
|
||||
participant.volume_level);
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionToggleGroupCallSetting::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionToggleGroupCallSetting>(action_ptr);
|
||||
return td_api::make_object<td_api::chatEventVideoChatMuteNewParticipantsToggled>(action->join_muted_);
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionChangeHistoryTTL::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionChangeHistoryTTL>(action_ptr);
|
||||
auto old_value = MessageTtlSetting(clamp(action->prev_value_, 0, 86400 * 366));
|
||||
auto new_value = MessageTtlSetting(clamp(action->new_value_, 0, 86400 * 366));
|
||||
return td_api::make_object<td_api::chatEventMessageTtlSettingChanged>(old_value.get_message_ttl_setting_object(),
|
||||
new_value.get_message_ttl_setting_object());
|
||||
}
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
class GetChannelAdminLogQuery final : public Td::ResultHandler {
|
||||
Promise<td_api::object_ptr<td_api::chatEvents>> promise_;
|
||||
ChannelId channel_id_;
|
||||
|
||||
public:
|
||||
explicit GetChannelAdminLogQuery(Promise<td_api::object_ptr<td_api::chatEvents>> &&promise)
|
||||
: promise_(std::move(promise)) {
|
||||
}
|
||||
|
||||
void send(ChannelId channel_id, const string &query, int64 from_event_id, int32 limit,
|
||||
tl_object_ptr<telegram_api::channelAdminLogEventsFilter> filter,
|
||||
vector<tl_object_ptr<telegram_api::InputUser>> input_users) {
|
||||
channel_id_ = channel_id;
|
||||
|
||||
auto input_channel = td_->contacts_manager_->get_input_channel(channel_id);
|
||||
CHECK(input_channel != nullptr);
|
||||
|
||||
int32 flags = 0;
|
||||
if (filter != nullptr) {
|
||||
flags |= telegram_api::channels_getAdminLog::EVENTS_FILTER_MASK;
|
||||
}
|
||||
if (!input_users.empty()) {
|
||||
flags |= telegram_api::channels_getAdminLog::ADMINS_MASK;
|
||||
}
|
||||
|
||||
send_query(G()->net_query_creator().create(telegram_api::channels_getAdminLog(
|
||||
flags, std::move(input_channel), query, std::move(filter), std::move(input_users), from_event_id, 0, limit)));
|
||||
}
|
||||
|
||||
void on_result(BufferSlice packet) final {
|
||||
auto result_ptr = fetch_result<telegram_api::channels_getAdminLog>(packet);
|
||||
if (result_ptr.is_error()) {
|
||||
return on_error(result_ptr.move_as_error());
|
||||
}
|
||||
|
||||
auto events = result_ptr.move_as_ok();
|
||||
LOG(INFO) << "Receive in " << channel_id_ << ' ' << to_string(events);
|
||||
td_->contacts_manager_->on_get_users(std::move(events->users_), "on_get_event_log");
|
||||
td_->contacts_manager_->on_get_chats(std::move(events->chats_), "on_get_event_log");
|
||||
|
||||
auto result = td_api::make_object<td_api::chatEvents>();
|
||||
result->events_.reserve(events->events_.size());
|
||||
for (auto &event : events->events_) {
|
||||
if (event->date_ <= 0) {
|
||||
LOG(ERROR) << "Receive wrong event date = " << event->date_;
|
||||
event->date_ = 0;
|
||||
}
|
||||
|
||||
UserId user_id(event->user_id_);
|
||||
if (!user_id.is_valid()) {
|
||||
LOG(ERROR) << "Receive invalid " << user_id;
|
||||
continue;
|
||||
}
|
||||
LOG_IF(ERROR, !td_->contacts_manager_->have_user(user_id)) << "Have no info about " << user_id;
|
||||
|
||||
auto action = get_chat_event_action_object(td_, channel_id_, std::move(event->action_));
|
||||
if (action == nullptr) {
|
||||
continue;
|
||||
}
|
||||
result->events_.push_back(td_api::make_object<td_api::chatEvent>(
|
||||
event->id_, event->date_, td_->contacts_manager_->get_user_id_object(user_id, "chatEvent"),
|
||||
std::move(action)));
|
||||
}
|
||||
|
||||
promise_.set_value(std::move(result));
|
||||
}
|
||||
|
||||
void on_error(Status status) final {
|
||||
td_->contacts_manager_->on_get_channel_error(channel_id_, status, "GetChannelAdminLogQuery");
|
||||
promise_.set_error(std::move(status));
|
||||
}
|
||||
};
|
||||
|
||||
static telegram_api::object_ptr<telegram_api::channelAdminLogEventsFilter> get_input_channel_admin_log_events_filter(
|
||||
const td_api::object_ptr<td_api::chatEventLogFilters> &filters) {
|
||||
if (filters == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int32 flags = 0;
|
||||
if (filters->message_edits_) {
|
||||
flags |= telegram_api::channelAdminLogEventsFilter::EDIT_MASK;
|
||||
}
|
||||
if (filters->message_deletions_) {
|
||||
flags |= telegram_api::channelAdminLogEventsFilter::DELETE_MASK;
|
||||
}
|
||||
if (filters->message_pins_) {
|
||||
flags |= telegram_api::channelAdminLogEventsFilter::PINNED_MASK;
|
||||
}
|
||||
if (filters->member_joins_) {
|
||||
flags |= telegram_api::channelAdminLogEventsFilter::JOIN_MASK;
|
||||
}
|
||||
if (filters->member_leaves_) {
|
||||
flags |= telegram_api::channelAdminLogEventsFilter::LEAVE_MASK;
|
||||
}
|
||||
if (filters->member_invites_) {
|
||||
flags |= telegram_api::channelAdminLogEventsFilter::INVITE_MASK;
|
||||
}
|
||||
if (filters->member_promotions_) {
|
||||
flags |= telegram_api::channelAdminLogEventsFilter::PROMOTE_MASK;
|
||||
flags |= telegram_api::channelAdminLogEventsFilter::DEMOTE_MASK;
|
||||
}
|
||||
if (filters->member_restrictions_) {
|
||||
flags |= telegram_api::channelAdminLogEventsFilter::BAN_MASK;
|
||||
flags |= telegram_api::channelAdminLogEventsFilter::UNBAN_MASK;
|
||||
flags |= telegram_api::channelAdminLogEventsFilter::KICK_MASK;
|
||||
flags |= telegram_api::channelAdminLogEventsFilter::UNKICK_MASK;
|
||||
}
|
||||
if (filters->info_changes_) {
|
||||
flags |= telegram_api::channelAdminLogEventsFilter::INFO_MASK;
|
||||
}
|
||||
if (filters->setting_changes_) {
|
||||
flags |= telegram_api::channelAdminLogEventsFilter::SETTINGS_MASK;
|
||||
}
|
||||
if (filters->invite_link_changes_) {
|
||||
flags |= telegram_api::channelAdminLogEventsFilter::INVITES_MASK;
|
||||
}
|
||||
if (filters->video_chat_changes_) {
|
||||
flags |= telegram_api::channelAdminLogEventsFilter::GROUP_CALL_MASK;
|
||||
}
|
||||
|
||||
return telegram_api::make_object<telegram_api::channelAdminLogEventsFilter>(
|
||||
flags, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/,
|
||||
false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/,
|
||||
false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/);
|
||||
}
|
||||
|
||||
void get_dialog_event_log(Td *td, DialogId dialog_id, const string &query, int64 from_event_id, int32 limit,
|
||||
const td_api::object_ptr<td_api::chatEventLogFilters> &filters,
|
||||
const vector<UserId> &user_ids, Promise<td_api::object_ptr<td_api::chatEvents>> &&promise) {
|
||||
if (!td->messages_manager_->have_dialog_force(dialog_id, "get_dialog_event_log")) {
|
||||
return promise.set_error(Status::Error(400, "Chat not found"));
|
||||
}
|
||||
|
||||
if (dialog_id.get_type() != DialogType::Channel) {
|
||||
return promise.set_error(Status::Error(400, "Chat is not a supergroup chat"));
|
||||
}
|
||||
|
||||
auto channel_id = dialog_id.get_channel_id();
|
||||
if (!td->contacts_manager_->have_channel(channel_id)) {
|
||||
return promise.set_error(Status::Error(400, "Chat info not found"));
|
||||
}
|
||||
|
||||
if (!td->contacts_manager_->get_channel_status(channel_id).is_administrator()) {
|
||||
return promise.set_error(Status::Error(400, "Not enough rights to get event log"));
|
||||
}
|
||||
|
||||
vector<tl_object_ptr<telegram_api::InputUser>> input_users;
|
||||
for (auto user_id : user_ids) {
|
||||
auto input_user = td->contacts_manager_->get_input_user(user_id);
|
||||
if (input_user == nullptr) {
|
||||
return promise.set_error(Status::Error(400, "User not found"));
|
||||
}
|
||||
input_users.push_back(std::move(input_user));
|
||||
}
|
||||
|
||||
td->create_handler<GetChannelAdminLogQuery>(std::move(promise))
|
||||
->send(channel_id, query, from_event_id, limit, get_input_channel_admin_log_events_filter(filters),
|
||||
std::move(input_users));
|
||||
}
|
||||
|
||||
} // namespace td
|
25
td/telegram/DialogEventLog.h
Normal file
25
td/telegram/DialogEventLog.h
Normal file
@ -0,0 +1,25 @@
|
||||
//
|
||||
// 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"
|
||||
#include "td/telegram/td_api.h"
|
||||
#include "td/telegram/UserId.h"
|
||||
|
||||
#include "td/actor/PromiseFuture.h"
|
||||
|
||||
#include "td/utils/common.h"
|
||||
|
||||
namespace td {
|
||||
|
||||
class Td;
|
||||
|
||||
void get_dialog_event_log(Td *td, DialogId dialog_id, const string &query, int64 from_event_id, int32 limit,
|
||||
const td_api::object_ptr<td_api::chatEventLogFilters> &filters,
|
||||
const vector<UserId> &user_ids, Promise<td_api::object_ptr<td_api::chatEvents>> &&promise);
|
||||
|
||||
} // namespace td
|
@ -5628,10 +5628,6 @@ void on_sent_message_content(Td *td, const MessageContent *content) {
|
||||
}
|
||||
}
|
||||
|
||||
StickerSetId add_sticker_set(Td *td, tl_object_ptr<telegram_api::InputStickerSet> &&input_sticker_set) {
|
||||
return td->stickers_manager_->add_sticker_set(std::move(input_sticker_set));
|
||||
}
|
||||
|
||||
bool is_unsent_animated_emoji_click(Td *td, DialogId dialog_id, const DialogAction &action) {
|
||||
auto emoji = action.get_watching_animations_emoji();
|
||||
if (emoji.empty()) {
|
||||
|
@ -20,7 +20,6 @@
|
||||
#include "td/telegram/ReplyMarkup.h"
|
||||
#include "td/telegram/secret_api.h"
|
||||
#include "td/telegram/SecretInputMedia.h"
|
||||
#include "td/telegram/StickerSetId.h"
|
||||
#include "td/telegram/td_api.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
#include "td/telegram/TopDialogCategory.h"
|
||||
@ -245,8 +244,6 @@ void add_message_content_dependencies(Dependencies &dependencies, const MessageC
|
||||
|
||||
void on_sent_message_content(Td *td, const MessageContent *content);
|
||||
|
||||
StickerSetId add_sticker_set(Td *td, tl_object_ptr<telegram_api::InputStickerSet> &&input_sticker_set);
|
||||
|
||||
bool is_unsent_animated_emoji_click(Td *td, DialogId dialog_id, const DialogAction &action);
|
||||
|
||||
void on_dialog_used(TopDialogCategory category, DialogId dialog_id, int32 date);
|
||||
|
@ -14,7 +14,6 @@
|
||||
#include "td/telegram/DialogDb.h"
|
||||
#include "td/telegram/DialogFilter.h"
|
||||
#include "td/telegram/DialogFilter.hpp"
|
||||
#include "td/telegram/DialogInviteLink.h"
|
||||
#include "td/telegram/DialogLocation.h"
|
||||
#include "td/telegram/DraftMessage.h"
|
||||
#include "td/telegram/DraftMessage.hpp"
|
||||
@ -4696,53 +4695,6 @@ class ResolveUsernameQuery final : public Td::ResultHandler {
|
||||
}
|
||||
};
|
||||
|
||||
class GetChannelAdminLogQuery final : public Td::ResultHandler {
|
||||
Promise<Unit> promise_;
|
||||
ChannelId channel_id_;
|
||||
int64 random_id_;
|
||||
|
||||
public:
|
||||
explicit GetChannelAdminLogQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
|
||||
}
|
||||
|
||||
void send(ChannelId channel_id, const string &query, int64 from_event_id, int32 limit,
|
||||
tl_object_ptr<telegram_api::channelAdminLogEventsFilter> filter,
|
||||
vector<tl_object_ptr<telegram_api::InputUser>> input_users, int64 random_id) {
|
||||
channel_id_ = channel_id;
|
||||
random_id_ = random_id;
|
||||
|
||||
auto input_channel = td_->contacts_manager_->get_input_channel(channel_id);
|
||||
CHECK(input_channel != nullptr);
|
||||
|
||||
int32 flags = 0;
|
||||
if (filter != nullptr) {
|
||||
flags |= telegram_api::channels_getAdminLog::EVENTS_FILTER_MASK;
|
||||
}
|
||||
if (!input_users.empty()) {
|
||||
flags |= telegram_api::channels_getAdminLog::ADMINS_MASK;
|
||||
}
|
||||
|
||||
send_query(G()->net_query_creator().create(telegram_api::channels_getAdminLog(
|
||||
flags, std::move(input_channel), query, std::move(filter), std::move(input_users), from_event_id, 0, limit)));
|
||||
}
|
||||
|
||||
void on_result(BufferSlice packet) final {
|
||||
auto result_ptr = fetch_result<telegram_api::channels_getAdminLog>(packet);
|
||||
if (result_ptr.is_error()) {
|
||||
return on_error(result_ptr.move_as_error());
|
||||
}
|
||||
|
||||
td_->messages_manager_->on_get_event_log(channel_id_, random_id_, result_ptr.move_as_ok());
|
||||
promise_.set_value(Unit());
|
||||
}
|
||||
|
||||
void on_error(Status status) final {
|
||||
td_->contacts_manager_->on_get_channel_error(channel_id_, status, "GetChannelAdminLogQuery");
|
||||
td_->messages_manager_->on_get_event_log(channel_id_, random_id_, nullptr);
|
||||
promise_.set_error(std::move(status));
|
||||
}
|
||||
};
|
||||
|
||||
class MessagesManager::UploadMediaCallback final : public FileManager::UploadCallback {
|
||||
public:
|
||||
void on_progress(FileId file_id) final {
|
||||
@ -23595,6 +23547,17 @@ tl_object_ptr<td_api::MessageSchedulingState> MessagesManager::get_message_sched
|
||||
return td_api::make_object<td_api::messageSchedulingStateSendAtDate>(send_date);
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::message> MessagesManager::get_dialog_event_log_message_object(
|
||||
DialogId dialog_id, tl_object_ptr<telegram_api::Message> &&message) {
|
||||
auto dialog_message = create_message(parse_telegram_api_message(std::move(message), false, "dialog_event_log"),
|
||||
dialog_id.get_type() == DialogType::Channel);
|
||||
if (dialog_message.second == nullptr || dialog_message.first != dialog_id) {
|
||||
LOG(ERROR) << "Failed to create event log message in " << dialog_id;
|
||||
return nullptr;
|
||||
}
|
||||
return get_message_object(dialog_id, dialog_message.second.get(), "admin log", true);
|
||||
}
|
||||
|
||||
tl_object_ptr<td_api::message> MessagesManager::get_message_object(FullMessageId full_message_id, const char *source) {
|
||||
return get_message_object(full_message_id.get_dialog_id(), get_message_force(full_message_id, source), source);
|
||||
}
|
||||
@ -23688,7 +23651,7 @@ tl_object_ptr<td_api::message> MessagesManager::get_message_object(DialogId dial
|
||||
auto contains_unread_mention = for_event_log ? false : m->contains_unread_mention;
|
||||
auto date = is_scheduled ? 0 : m->date;
|
||||
auto edit_date = m->hide_edit_date ? 0 : m->edit_date;
|
||||
auto is_pinned = for_event_log || is_scheduled ? false : m->is_pinned;
|
||||
auto is_pinned = is_scheduled ? false : m->is_pinned;
|
||||
auto has_timestamped_media = for_event_log || reply_to_message_id == 0 || m->max_own_media_timestamp >= 0;
|
||||
auto reply_markup = get_reply_markup_object(m->reply_markup);
|
||||
|
||||
@ -32294,475 +32257,6 @@ void MessagesManager::unpin_all_dialog_messages_on_server(DialogId dialog_id, ui
|
||||
->send(dialog_id);
|
||||
}
|
||||
|
||||
tl_object_ptr<telegram_api::channelAdminLogEventsFilter> MessagesManager::get_channel_admin_log_events_filter(
|
||||
const tl_object_ptr<td_api::chatEventLogFilters> &filters) {
|
||||
if (filters == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int32 flags = 0;
|
||||
if (filters->message_edits_) {
|
||||
flags |= telegram_api::channelAdminLogEventsFilter::EDIT_MASK;
|
||||
}
|
||||
if (filters->message_deletions_) {
|
||||
flags |= telegram_api::channelAdminLogEventsFilter::DELETE_MASK;
|
||||
}
|
||||
if (filters->message_pins_) {
|
||||
flags |= telegram_api::channelAdminLogEventsFilter::PINNED_MASK;
|
||||
}
|
||||
if (filters->member_joins_) {
|
||||
flags |= telegram_api::channelAdminLogEventsFilter::JOIN_MASK;
|
||||
}
|
||||
if (filters->member_leaves_) {
|
||||
flags |= telegram_api::channelAdminLogEventsFilter::LEAVE_MASK;
|
||||
}
|
||||
if (filters->member_invites_) {
|
||||
flags |= telegram_api::channelAdminLogEventsFilter::INVITE_MASK;
|
||||
}
|
||||
if (filters->member_promotions_) {
|
||||
flags |= telegram_api::channelAdminLogEventsFilter::PROMOTE_MASK;
|
||||
flags |= telegram_api::channelAdminLogEventsFilter::DEMOTE_MASK;
|
||||
}
|
||||
if (filters->member_restrictions_) {
|
||||
flags |= telegram_api::channelAdminLogEventsFilter::BAN_MASK;
|
||||
flags |= telegram_api::channelAdminLogEventsFilter::UNBAN_MASK;
|
||||
flags |= telegram_api::channelAdminLogEventsFilter::KICK_MASK;
|
||||
flags |= telegram_api::channelAdminLogEventsFilter::UNKICK_MASK;
|
||||
}
|
||||
if (filters->info_changes_) {
|
||||
flags |= telegram_api::channelAdminLogEventsFilter::INFO_MASK;
|
||||
}
|
||||
if (filters->setting_changes_) {
|
||||
flags |= telegram_api::channelAdminLogEventsFilter::SETTINGS_MASK;
|
||||
}
|
||||
if (filters->invite_link_changes_) {
|
||||
flags |= telegram_api::channelAdminLogEventsFilter::INVITES_MASK;
|
||||
}
|
||||
if (filters->video_chat_changes_) {
|
||||
flags |= telegram_api::channelAdminLogEventsFilter::GROUP_CALL_MASK;
|
||||
}
|
||||
|
||||
return make_tl_object<telegram_api::channelAdminLogEventsFilter>(
|
||||
flags, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/,
|
||||
false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/,
|
||||
false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/);
|
||||
}
|
||||
|
||||
int64 MessagesManager::get_dialog_event_log(DialogId dialog_id, const string &query, int64 from_event_id, int32 limit,
|
||||
const tl_object_ptr<td_api::chatEventLogFilters> &filters,
|
||||
const vector<UserId> &user_ids, Promise<Unit> &&promise) {
|
||||
if (!have_dialog_force(dialog_id, "get_dialog_event_log")) {
|
||||
promise.set_error(Status::Error(400, "Chat not found"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (dialog_id.get_type() != DialogType::Channel) {
|
||||
promise.set_error(Status::Error(400, "Chat is not a supergroup chat"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
auto channel_id = dialog_id.get_channel_id();
|
||||
if (!td_->contacts_manager_->have_channel(channel_id)) {
|
||||
promise.set_error(Status::Error(400, "Chat info not found"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!td_->contacts_manager_->get_channel_status(channel_id).is_administrator()) {
|
||||
promise.set_error(Status::Error(400, "Not enough rights to get event log"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
vector<tl_object_ptr<telegram_api::InputUser>> input_users;
|
||||
for (auto user_id : user_ids) {
|
||||
auto input_user = td_->contacts_manager_->get_input_user(user_id);
|
||||
if (input_user == nullptr) {
|
||||
promise.set_error(Status::Error(400, "User not found"));
|
||||
return 0;
|
||||
}
|
||||
input_users.push_back(std::move(input_user));
|
||||
}
|
||||
|
||||
int64 random_id = 0;
|
||||
do {
|
||||
random_id = Random::secure_int64();
|
||||
} while (random_id == 0 || chat_events_.find(random_id) != chat_events_.end());
|
||||
chat_events_[random_id]; // reserve place for result
|
||||
|
||||
td_->create_handler<GetChannelAdminLogQuery>(std::move(promise))
|
||||
->send(channel_id, query, from_event_id, limit, get_channel_admin_log_events_filter(filters),
|
||||
std::move(input_users), random_id);
|
||||
|
||||
return random_id;
|
||||
}
|
||||
|
||||
tl_object_ptr<td_api::ChatEventAction> MessagesManager::get_chat_event_action_object(
|
||||
ChannelId channel_id, tl_object_ptr<telegram_api::ChannelAdminLogEventAction> &&action_ptr) {
|
||||
CHECK(action_ptr != nullptr);
|
||||
switch (action_ptr->get_id()) {
|
||||
case telegram_api::channelAdminLogEventActionParticipantJoin::ID:
|
||||
return make_tl_object<td_api::chatEventMemberJoined>();
|
||||
case telegram_api::channelAdminLogEventActionParticipantJoinByInvite::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionParticipantJoinByInvite>(action_ptr);
|
||||
DialogInviteLink invite_link(std::move(action->invite_));
|
||||
if (!invite_link.is_valid()) {
|
||||
LOG(ERROR) << "Wrong invite link: " << invite_link;
|
||||
return nullptr;
|
||||
}
|
||||
return make_tl_object<td_api::chatEventMemberJoinedByInviteLink>(
|
||||
invite_link.get_chat_invite_link_object(td_->contacts_manager_.get()));
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionParticipantJoinByRequest::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionParticipantJoinByRequest>(action_ptr);
|
||||
DialogInviteLink invite_link(std::move(action->invite_));
|
||||
if (!invite_link.is_valid()) {
|
||||
LOG(ERROR) << "Wrong invite link: " << invite_link;
|
||||
return nullptr;
|
||||
}
|
||||
UserId approver_user_id(action->approved_by_);
|
||||
if (!approver_user_id.is_valid()) {
|
||||
return nullptr;
|
||||
}
|
||||
return make_tl_object<td_api::chatEventMemberJoinedByRequest>(
|
||||
td_->contacts_manager_->get_user_id_object(approver_user_id, "chatEventMemberJoinedByRequest"),
|
||||
invite_link.get_chat_invite_link_object(td_->contacts_manager_.get()));
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionParticipantLeave::ID:
|
||||
return make_tl_object<td_api::chatEventMemberLeft>();
|
||||
case telegram_api::channelAdminLogEventActionParticipantInvite::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionParticipantInvite>(action_ptr);
|
||||
DialogParticipant dialog_participant(std::move(action->participant_));
|
||||
if (!dialog_participant.is_valid() || dialog_participant.dialog_id_.get_type() != DialogType::User) {
|
||||
LOG(ERROR) << "Wrong invite: " << dialog_participant;
|
||||
return nullptr;
|
||||
}
|
||||
return make_tl_object<td_api::chatEventMemberInvited>(
|
||||
td_->contacts_manager_->get_user_id_object(dialog_participant.dialog_id_.get_user_id(),
|
||||
"chatEventMemberInvited"),
|
||||
dialog_participant.status_.get_chat_member_status_object());
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionParticipantToggleBan::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionParticipantToggleBan>(action_ptr);
|
||||
DialogParticipant old_dialog_participant(std::move(action->prev_participant_));
|
||||
DialogParticipant new_dialog_participant(std::move(action->new_participant_));
|
||||
if (old_dialog_participant.dialog_id_ != new_dialog_participant.dialog_id_) {
|
||||
LOG(ERROR) << old_dialog_participant.dialog_id_ << " VS " << new_dialog_participant.dialog_id_;
|
||||
return nullptr;
|
||||
}
|
||||
if (!old_dialog_participant.is_valid() || !new_dialog_participant.is_valid()) {
|
||||
LOG(ERROR) << "Wrong restrict: " << old_dialog_participant << " -> " << new_dialog_participant;
|
||||
return nullptr;
|
||||
}
|
||||
return make_tl_object<td_api::chatEventMemberRestricted>(
|
||||
get_message_sender_object(old_dialog_participant.dialog_id_, "chatEventMemberRestricted"),
|
||||
old_dialog_participant.status_.get_chat_member_status_object(),
|
||||
new_dialog_participant.status_.get_chat_member_status_object());
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionParticipantToggleAdmin::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionParticipantToggleAdmin>(action_ptr);
|
||||
DialogParticipant old_dialog_participant(std::move(action->prev_participant_));
|
||||
DialogParticipant new_dialog_participant(std::move(action->new_participant_));
|
||||
if (old_dialog_participant.dialog_id_ != new_dialog_participant.dialog_id_) {
|
||||
LOG(ERROR) << old_dialog_participant.dialog_id_ << " VS " << new_dialog_participant.dialog_id_;
|
||||
return nullptr;
|
||||
}
|
||||
if (!old_dialog_participant.is_valid() || !new_dialog_participant.is_valid() ||
|
||||
old_dialog_participant.dialog_id_.get_type() != DialogType::User) {
|
||||
LOG(ERROR) << "Wrong edit administrator: " << old_dialog_participant << " -> " << new_dialog_participant;
|
||||
return nullptr;
|
||||
}
|
||||
return make_tl_object<td_api::chatEventMemberPromoted>(
|
||||
td_->contacts_manager_->get_user_id_object(old_dialog_participant.dialog_id_.get_user_id(),
|
||||
"chatEventMemberPromoted"),
|
||||
old_dialog_participant.status_.get_chat_member_status_object(),
|
||||
new_dialog_participant.status_.get_chat_member_status_object());
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionChangeTitle::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionChangeTitle>(action_ptr);
|
||||
return make_tl_object<td_api::chatEventTitleChanged>(std::move(action->prev_value_),
|
||||
std::move(action->new_value_));
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionChangeAbout::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionChangeAbout>(action_ptr);
|
||||
return make_tl_object<td_api::chatEventDescriptionChanged>(std::move(action->prev_value_),
|
||||
std::move(action->new_value_));
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionChangeUsername::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionChangeUsername>(action_ptr);
|
||||
return make_tl_object<td_api::chatEventUsernameChanged>(std::move(action->prev_value_),
|
||||
std::move(action->new_value_));
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionChangePhoto::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionChangePhoto>(action_ptr);
|
||||
auto file_manager = td_->file_manager_.get();
|
||||
auto old_photo = get_photo(file_manager, std::move(action->prev_photo_), DialogId(channel_id));
|
||||
auto new_photo = get_photo(file_manager, std::move(action->new_photo_), DialogId(channel_id));
|
||||
return make_tl_object<td_api::chatEventPhotoChanged>(get_chat_photo_object(file_manager, old_photo),
|
||||
get_chat_photo_object(file_manager, new_photo));
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionDefaultBannedRights::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionDefaultBannedRights>(action_ptr);
|
||||
auto old_permissions = get_restricted_rights(std::move(action->prev_banned_rights_));
|
||||
auto new_permissions = get_restricted_rights(std::move(action->new_banned_rights_));
|
||||
return make_tl_object<td_api::chatEventPermissionsChanged>(old_permissions.get_chat_permissions_object(),
|
||||
new_permissions.get_chat_permissions_object());
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionToggleInvites::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionToggleInvites>(action_ptr);
|
||||
return make_tl_object<td_api::chatEventInvitesToggled>(action->new_value_);
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionToggleSignatures::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionToggleSignatures>(action_ptr);
|
||||
return make_tl_object<td_api::chatEventSignMessagesToggled>(action->new_value_);
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionUpdatePinned::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionUpdatePinned>(action_ptr);
|
||||
auto message = create_message(
|
||||
parse_telegram_api_message(std::move(action->message_), false, "channelAdminLogEventActionUpdatePinned"),
|
||||
true);
|
||||
if (message.second == nullptr || message.first != DialogId(channel_id)) {
|
||||
LOG(ERROR) << "Failed to get pinned message";
|
||||
return nullptr;
|
||||
}
|
||||
auto message_object = get_message_object(message.first, message.second.get(), "admin log", true);
|
||||
if (message.second->is_pinned) {
|
||||
return make_tl_object<td_api::chatEventMessagePinned>(std::move(message_object));
|
||||
} else {
|
||||
return make_tl_object<td_api::chatEventMessageUnpinned>(std::move(message_object));
|
||||
}
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionEditMessage::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionEditMessage>(action_ptr);
|
||||
auto old_message = create_message(parse_telegram_api_message(std::move(action->prev_message_), false,
|
||||
"prev channelAdminLogEventActionEditMessage"),
|
||||
true);
|
||||
auto new_message = create_message(parse_telegram_api_message(std::move(action->new_message_), false,
|
||||
"new channelAdminLogEventActionEditMessage"),
|
||||
true);
|
||||
if (old_message.second == nullptr || new_message.second == nullptr || old_message.first != new_message.first ||
|
||||
old_message.first != DialogId(channel_id)) {
|
||||
LOG(ERROR) << "Failed to get edited message";
|
||||
return nullptr;
|
||||
}
|
||||
return make_tl_object<td_api::chatEventMessageEdited>(
|
||||
get_message_object(old_message.first, old_message.second.get(), "admin log", true),
|
||||
get_message_object(new_message.first, new_message.second.get(), "admin log", true));
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionStopPoll::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionStopPoll>(action_ptr);
|
||||
auto message = create_message(
|
||||
parse_telegram_api_message(std::move(action->message_), false, "channelAdminLogEventActionStopPoll"), true);
|
||||
if (message.second == nullptr || message.first != DialogId(channel_id)) {
|
||||
LOG(ERROR) << "Failed to get stopped poll message";
|
||||
return nullptr;
|
||||
}
|
||||
if (message.second->content->get_type() != MessageContentType::Poll) {
|
||||
LOG(ERROR) << "Receive not a poll in channelAdminLogEventActionStopPoll";
|
||||
return nullptr;
|
||||
}
|
||||
return make_tl_object<td_api::chatEventPollStopped>(
|
||||
get_message_object(message.first, message.second.get(), "admin log", true));
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionDeleteMessage::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionDeleteMessage>(action_ptr);
|
||||
auto message = create_message(
|
||||
parse_telegram_api_message(std::move(action->message_), false, "channelAdminLogEventActionDeleteMessage"),
|
||||
true);
|
||||
if (message.second == nullptr || message.first != DialogId(channel_id)) {
|
||||
LOG(ERROR) << "Failed to get deleted message";
|
||||
return nullptr;
|
||||
}
|
||||
return make_tl_object<td_api::chatEventMessageDeleted>(
|
||||
get_message_object(message.first, message.second.get(), "admin log", true));
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionChangeStickerSet::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionChangeStickerSet>(action_ptr);
|
||||
auto old_sticker_set_id = add_sticker_set(td_, std::move(action->prev_stickerset_));
|
||||
auto new_sticker_set_id = add_sticker_set(td_, std::move(action->new_stickerset_));
|
||||
return make_tl_object<td_api::chatEventStickerSetChanged>(old_sticker_set_id.get(), new_sticker_set_id.get());
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionTogglePreHistoryHidden::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionTogglePreHistoryHidden>(action_ptr);
|
||||
return make_tl_object<td_api::chatEventIsAllHistoryAvailableToggled>(!action->new_value_);
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionChangeLinkedChat::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionChangeLinkedChat>(action_ptr);
|
||||
|
||||
auto get_dialog_from_channel_id = [this](int64 channel_id_int) {
|
||||
ChannelId channel_id(channel_id_int);
|
||||
if (!channel_id.is_valid()) {
|
||||
return DialogId();
|
||||
}
|
||||
|
||||
DialogId dialog_id(channel_id);
|
||||
force_create_dialog(dialog_id, "get_dialog_from_channel_id");
|
||||
return dialog_id;
|
||||
};
|
||||
|
||||
auto old_linked_dialog_id = get_dialog_from_channel_id(action->prev_value_);
|
||||
auto new_linked_dialog_id = get_dialog_from_channel_id(action->new_value_);
|
||||
if (old_linked_dialog_id == new_linked_dialog_id) {
|
||||
LOG(ERROR) << "Receive the same linked " << new_linked_dialog_id;
|
||||
return nullptr;
|
||||
}
|
||||
return make_tl_object<td_api::chatEventLinkedChatChanged>(old_linked_dialog_id.get(), new_linked_dialog_id.get());
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionChangeLocation::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionChangeLocation>(action_ptr);
|
||||
auto old_location = DialogLocation(std::move(action->prev_value_));
|
||||
auto new_location = DialogLocation(std::move(action->new_value_));
|
||||
return make_tl_object<td_api::chatEventLocationChanged>(old_location.get_chat_location_object(),
|
||||
new_location.get_chat_location_object());
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionToggleSlowMode::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionToggleSlowMode>(action_ptr);
|
||||
auto old_slow_mode_delay = clamp(action->prev_value_, 0, 86400 * 366);
|
||||
auto new_slow_mode_delay = clamp(action->new_value_, 0, 86400 * 366);
|
||||
return make_tl_object<td_api::chatEventSlowModeDelayChanged>(old_slow_mode_delay, new_slow_mode_delay);
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionExportedInviteEdit::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionExportedInviteEdit>(action_ptr);
|
||||
DialogInviteLink old_invite_link(std::move(action->prev_invite_));
|
||||
DialogInviteLink new_invite_link(std::move(action->new_invite_));
|
||||
if (!old_invite_link.is_valid() || !new_invite_link.is_valid()) {
|
||||
LOG(ERROR) << "Wrong edited invite link: " << old_invite_link << " -> " << new_invite_link;
|
||||
return nullptr;
|
||||
}
|
||||
return make_tl_object<td_api::chatEventInviteLinkEdited>(
|
||||
old_invite_link.get_chat_invite_link_object(td_->contacts_manager_.get()),
|
||||
new_invite_link.get_chat_invite_link_object(td_->contacts_manager_.get()));
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionExportedInviteRevoke::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionExportedInviteRevoke>(action_ptr);
|
||||
DialogInviteLink invite_link(std::move(action->invite_));
|
||||
if (!invite_link.is_valid()) {
|
||||
LOG(ERROR) << "Wrong revoked invite link: " << invite_link;
|
||||
return nullptr;
|
||||
}
|
||||
return make_tl_object<td_api::chatEventInviteLinkRevoked>(
|
||||
invite_link.get_chat_invite_link_object(td_->contacts_manager_.get()));
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionExportedInviteDelete::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionExportedInviteDelete>(action_ptr);
|
||||
DialogInviteLink invite_link(std::move(action->invite_));
|
||||
if (!invite_link.is_valid()) {
|
||||
LOG(ERROR) << "Wrong deleted invite link: " << invite_link;
|
||||
return nullptr;
|
||||
}
|
||||
return make_tl_object<td_api::chatEventInviteLinkDeleted>(
|
||||
invite_link.get_chat_invite_link_object(td_->contacts_manager_.get()));
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionStartGroupCall::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionStartGroupCall>(action_ptr);
|
||||
auto input_group_call_id = InputGroupCallId(action->call_);
|
||||
if (!input_group_call_id.is_valid()) {
|
||||
return nullptr;
|
||||
}
|
||||
return make_tl_object<td_api::chatEventVideoChatCreated>(
|
||||
td_->group_call_manager_->get_group_call_id(input_group_call_id, DialogId(channel_id)).get());
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionDiscardGroupCall::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionDiscardGroupCall>(action_ptr);
|
||||
auto input_group_call_id = InputGroupCallId(action->call_);
|
||||
if (!input_group_call_id.is_valid()) {
|
||||
return nullptr;
|
||||
}
|
||||
return make_tl_object<td_api::chatEventVideoChatDiscarded>(
|
||||
td_->group_call_manager_->get_group_call_id(input_group_call_id, DialogId(channel_id)).get());
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionParticipantMute::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionParticipantMute>(action_ptr);
|
||||
GroupCallParticipant participant(action->participant_, 0);
|
||||
if (!participant.is_valid()) {
|
||||
return nullptr;
|
||||
}
|
||||
return make_tl_object<td_api::chatEventVideoChatParticipantIsMutedToggled>(
|
||||
get_message_sender_object(participant.dialog_id, "chatEventVideoChatParticipantIsMutedToggled"), true);
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionParticipantUnmute::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionParticipantUnmute>(action_ptr);
|
||||
GroupCallParticipant participant(action->participant_, 0);
|
||||
if (!participant.is_valid()) {
|
||||
return nullptr;
|
||||
}
|
||||
return make_tl_object<td_api::chatEventVideoChatParticipantIsMutedToggled>(
|
||||
get_message_sender_object(participant.dialog_id, "chatEventVideoChatParticipantIsMutedToggled"), false);
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionParticipantVolume::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionParticipantVolume>(action_ptr);
|
||||
GroupCallParticipant participant(action->participant_, 0);
|
||||
if (!participant.is_valid()) {
|
||||
return nullptr;
|
||||
}
|
||||
return make_tl_object<td_api::chatEventVideoChatParticipantVolumeLevelChanged>(
|
||||
get_message_sender_object(participant.dialog_id, "chatEventVideoChatParticipantVolumeLevelChanged"),
|
||||
participant.volume_level);
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionToggleGroupCallSetting::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionToggleGroupCallSetting>(action_ptr);
|
||||
return make_tl_object<td_api::chatEventVideoChatMuteNewParticipantsToggled>(action->join_muted_);
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionChangeHistoryTTL::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionChangeHistoryTTL>(action_ptr);
|
||||
auto old_value = MessageTtlSetting(clamp(action->prev_value_, 0, 86400 * 366));
|
||||
auto new_value = MessageTtlSetting(clamp(action->new_value_, 0, 86400 * 366));
|
||||
return make_tl_object<td_api::chatEventMessageTtlSettingChanged>(old_value.get_message_ttl_setting_object(),
|
||||
new_value.get_message_ttl_setting_object());
|
||||
}
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void MessagesManager::on_get_event_log(ChannelId channel_id, int64 random_id,
|
||||
tl_object_ptr<telegram_api::channels_adminLogResults> &&events) {
|
||||
auto it = chat_events_.find(random_id);
|
||||
CHECK(it != chat_events_.end());
|
||||
auto &result = it->second;
|
||||
CHECK(result == nullptr);
|
||||
|
||||
if (events == nullptr) {
|
||||
chat_events_.erase(it);
|
||||
return;
|
||||
}
|
||||
|
||||
LOG(INFO) << "Receive in " << channel_id << " " << to_string(events);
|
||||
|
||||
td_->contacts_manager_->on_get_users(std::move(events->users_), "on_get_event_log");
|
||||
td_->contacts_manager_->on_get_chats(std::move(events->chats_), "on_get_event_log");
|
||||
|
||||
result = make_tl_object<td_api::chatEvents>();
|
||||
result->events_.reserve(events->events_.size());
|
||||
for (auto &event : events->events_) {
|
||||
if (event->date_ <= 0) {
|
||||
LOG(ERROR) << "Receive wrong event date = " << event->date_;
|
||||
event->date_ = 0;
|
||||
}
|
||||
|
||||
UserId user_id(event->user_id_);
|
||||
if (!user_id.is_valid()) {
|
||||
LOG(ERROR) << "Receive invalid " << user_id;
|
||||
continue;
|
||||
}
|
||||
LOG_IF(ERROR, !td_->contacts_manager_->have_user(user_id)) << "Have no info about " << user_id;
|
||||
|
||||
auto action = get_chat_event_action_object(channel_id, std::move(event->action_));
|
||||
if (action == nullptr) {
|
||||
continue;
|
||||
}
|
||||
result->events_.push_back(make_tl_object<td_api::chatEvent>(
|
||||
event->id_, event->date_, td_->contacts_manager_->get_user_id_object(user_id, "chatEvent"), std::move(action)));
|
||||
}
|
||||
}
|
||||
|
||||
tl_object_ptr<td_api::chatEvents> MessagesManager::get_chat_events_object(int64 random_id) {
|
||||
auto it = chat_events_.find(random_id);
|
||||
CHECK(it != chat_events_.end());
|
||||
auto result = std::move(it->second);
|
||||
chat_events_.erase(it);
|
||||
return result;
|
||||
}
|
||||
|
||||
unique_ptr<MessagesManager::Message> *MessagesManager::treap_find_message(unique_ptr<Message> *v,
|
||||
MessageId message_id) {
|
||||
return const_cast<unique_ptr<Message> *>(treap_find_message(static_cast<const unique_ptr<Message> *>(v), message_id));
|
||||
|
@ -510,15 +510,6 @@ class MessagesManager final : public Actor {
|
||||
|
||||
void get_dialog_info_full(DialogId dialog_id, Promise<Unit> &&promise, const char *source);
|
||||
|
||||
int64 get_dialog_event_log(DialogId dialog_id, const string &query, int64 from_event_id, int32 limit,
|
||||
const tl_object_ptr<td_api::chatEventLogFilters> &filters, const vector<UserId> &user_ids,
|
||||
Promise<Unit> &&promise);
|
||||
|
||||
void on_get_event_log(ChannelId channel_id, int64 random_id,
|
||||
tl_object_ptr<telegram_api::channels_adminLogResults> &&events);
|
||||
|
||||
tl_object_ptr<td_api::chatEvents> get_chat_events_object(int64 random_id);
|
||||
|
||||
string get_dialog_title(DialogId dialog_id) const;
|
||||
|
||||
bool have_dialog(DialogId dialog_id) const;
|
||||
@ -767,6 +758,9 @@ class MessagesManager final : public Actor {
|
||||
|
||||
tl_object_ptr<td_api::message> get_dialog_message_by_date_object(int64 random_id);
|
||||
|
||||
td_api::object_ptr<td_api::message> get_dialog_event_log_message_object(
|
||||
DialogId dialog_id, tl_object_ptr<telegram_api::Message> &&message);
|
||||
|
||||
tl_object_ptr<td_api::message> get_message_object(FullMessageId full_message_id, const char *source);
|
||||
|
||||
tl_object_ptr<td_api::messages> get_messages_object(int32 total_count, DialogId dialog_id,
|
||||
@ -2999,12 +2993,6 @@ class MessagesManager final : public Actor {
|
||||
|
||||
void load_secret_thumbnail(FileId thumbnail_file_id);
|
||||
|
||||
static tl_object_ptr<telegram_api::channelAdminLogEventsFilter> get_channel_admin_log_events_filter(
|
||||
const tl_object_ptr<td_api::chatEventLogFilters> &filters);
|
||||
|
||||
tl_object_ptr<td_api::ChatEventAction> get_chat_event_action_object(
|
||||
ChannelId channel_id, tl_object_ptr<telegram_api::ChannelAdminLogEventAction> &&action_ptr);
|
||||
|
||||
void on_upload_media(FileId file_id, tl_object_ptr<telegram_api::InputFile> input_file,
|
||||
tl_object_ptr<telegram_api::InputEncryptedFile> input_encrypted_file);
|
||||
void on_upload_media_error(FileId file_id, Status status);
|
||||
@ -3362,8 +3350,6 @@ class MessagesManager final : public Actor {
|
||||
};
|
||||
std::unordered_map<DialogId, MessageEmbeddingCodes, DialogIdHash> message_embedding_codes_[2];
|
||||
|
||||
std::unordered_map<int64, tl_object_ptr<td_api::chatEvents>> chat_events_; // random_id -> chat events
|
||||
|
||||
std::unordered_map<DialogId, vector<Promise<Unit>>, DialogIdHash> get_dialog_notification_settings_queries_;
|
||||
|
||||
std::unordered_map<DialogId, vector<Promise<Unit>>, DialogIdHash> get_dialog_queries_;
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "td/telegram/DeviceTokenManager.h"
|
||||
#include "td/telegram/DialogAction.h"
|
||||
#include "td/telegram/DialogAdministrator.h"
|
||||
#include "td/telegram/DialogEventLog.h"
|
||||
#include "td/telegram/DialogFilter.h"
|
||||
#include "td/telegram/DialogFilterId.h"
|
||||
#include "td/telegram/DialogId.h"
|
||||
@ -1848,39 +1849,6 @@ class JoinChatByInviteLinkRequest final : public RequestActor<DialogId> {
|
||||
}
|
||||
};
|
||||
|
||||
class GetChatEventLogRequest final : public RequestOnceActor {
|
||||
DialogId dialog_id_;
|
||||
string query_;
|
||||
int64 from_event_id_;
|
||||
int32 limit_;
|
||||
tl_object_ptr<td_api::chatEventLogFilters> filters_;
|
||||
vector<UserId> user_ids_;
|
||||
|
||||
int64 random_id_ = 0;
|
||||
|
||||
void do_run(Promise<Unit> &&promise) final {
|
||||
random_id_ = td_->messages_manager_->get_dialog_event_log(dialog_id_, query_, from_event_id_, limit_, filters_,
|
||||
user_ids_, std::move(promise));
|
||||
}
|
||||
|
||||
void do_send_result() final {
|
||||
CHECK(random_id_ != 0);
|
||||
send_result(td_->messages_manager_->get_chat_events_object(random_id_));
|
||||
}
|
||||
|
||||
public:
|
||||
GetChatEventLogRequest(ActorShared<Td> td, uint64 request_id, int64 dialog_id, string &&query, int64 from_event_id,
|
||||
int32 limit, tl_object_ptr<td_api::chatEventLogFilters> &&filters, vector<UserId> user_ids)
|
||||
: RequestOnceActor(std::move(td), request_id)
|
||||
, dialog_id_(dialog_id)
|
||||
, query_(std::move(query))
|
||||
, from_event_id_(from_event_id)
|
||||
, limit_(limit)
|
||||
, filters_(std::move(filters))
|
||||
, user_ids_(std::move(user_ids)) {
|
||||
}
|
||||
};
|
||||
|
||||
class ImportContactsRequest final : public RequestActor<> {
|
||||
vector<Contact> contacts_;
|
||||
int64 random_id_;
|
||||
@ -6450,8 +6418,10 @@ void Td::on_request(uint64 id, td_api::joinChatByInviteLink &request) {
|
||||
void Td::on_request(uint64 id, td_api::getChatEventLog &request) {
|
||||
CHECK_IS_USER();
|
||||
CLEAN_INPUT_STRING(request.query_);
|
||||
CREATE_REQUEST(GetChatEventLogRequest, request.chat_id_, std::move(request.query_), request.from_event_id_,
|
||||
request.limit_, std::move(request.filters_), UserId::get_user_ids(request.user_ids_));
|
||||
CREATE_REQUEST_PROMISE();
|
||||
get_dialog_event_log(this, DialogId(request.chat_id_), std::move(request.query_), request.from_event_id_,
|
||||
request.limit_, std::move(request.filters_), UserId::get_user_ids(request.user_ids_),
|
||||
std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::clearAllDraftMessages &request) {
|
||||
|
Loading…
Reference in New Issue
Block a user