Replace user_id with member_id in chatEventLog.
This commit is contained in:
parent
ae1d1867f2
commit
cbc6d25a44
@ -2633,8 +2633,8 @@ chatEventVideoChatParticipantVolumeLevelChanged participant_id:MessageSender vol
|
||||
//@description The mute_new_participants setting of a video chat was toggled @mute_new_participants New value of the mute_new_participants setting
|
||||
chatEventVideoChatMuteNewParticipantsToggled mute_new_participants:Bool = ChatEventAction;
|
||||
|
||||
//@description Represents a chat event @id Chat event identifier @date Point in time (Unix timestamp) when the event happened @user_id Identifier of the user who performed the action that triggered the event @action Action performed by the user
|
||||
chatEvent id:int64 date:int32 user_id:int53 action:ChatEventAction = ChatEvent;
|
||||
//@description Represents a chat event @id Chat event identifier @date Point in time (Unix timestamp) when the event happened @member_id Identifier of the user or chat who performed the action @action The action
|
||||
chatEvent id:int64 date:int32 member_id:MessageSender action:ChatEventAction = ChatEvent;
|
||||
|
||||
//@description Contains a list of chat events @events List of events
|
||||
chatEvents events:vector<chatEvent> = ChatEvents;
|
||||
|
@ -30,7 +30,8 @@
|
||||
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) {
|
||||
Td *td, ChannelId channel_id, tl_object_ptr<telegram_api::ChannelAdminLogEventAction> &&action_ptr,
|
||||
DialogId &actor_dialog_id) {
|
||||
CHECK(action_ptr != nullptr);
|
||||
switch (action_ptr->get_id()) {
|
||||
case telegram_api::channelAdminLogEventActionParticipantJoin::ID:
|
||||
@ -150,8 +151,9 @@ static td_api::object_ptr<td_api::ChatEventAction> get_chat_event_action_object(
|
||||
}
|
||||
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_));
|
||||
DialogId sender_dialog_id;
|
||||
auto message = td->messages_manager_->get_dialog_event_log_message_object(
|
||||
DialogId(channel_id), std::move(action->message_), sender_dialog_id);
|
||||
if (message == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -166,19 +168,24 @@ static td_api::object_ptr<td_api::ChatEventAction> get_chat_event_action_object(
|
||||
}
|
||||
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_));
|
||||
DialogId old_sender_dialog_id;
|
||||
auto old_message = td->messages_manager_->get_dialog_event_log_message_object(
|
||||
DialogId(channel_id), std::move(action->prev_message_), old_sender_dialog_id);
|
||||
DialogId new_sender_dialog_id;
|
||||
auto new_message = td->messages_manager_->get_dialog_event_log_message_object(
|
||||
DialogId(channel_id), std::move(action->new_message_), new_sender_dialog_id);
|
||||
if (old_message == nullptr || new_message == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
if (old_sender_dialog_id == new_sender_dialog_id) {
|
||||
actor_dialog_id = old_sender_dialog_id;
|
||||
}
|
||||
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_));
|
||||
auto message = td->messages_manager_->get_dialog_event_log_message_object(
|
||||
DialogId(channel_id), std::move(action->message_), actor_dialog_id);
|
||||
if (message == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -186,8 +193,8 @@ static td_api::object_ptr<td_api::ChatEventAction> get_chat_event_action_object(
|
||||
}
|
||||
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_));
|
||||
auto message = td->messages_manager_->get_dialog_event_log_message_object(
|
||||
DialogId(channel_id), std::move(action->message_), actor_dialog_id);
|
||||
if (message == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -394,13 +401,20 @@ class GetChannelAdminLogQuery final : public Td::ResultHandler {
|
||||
}
|
||||
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_));
|
||||
DialogId actor_dialog_id;
|
||||
auto action = get_chat_event_action_object(td_, channel_id_, std::move(event->action_), actor_dialog_id);
|
||||
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)));
|
||||
if (user_id == ContactsManager::get_channel_bot_user_id() && actor_dialog_id.is_valid() &&
|
||||
actor_dialog_id.get_type() != DialogType::User) {
|
||||
user_id = UserId();
|
||||
} else {
|
||||
actor_dialog_id = DialogId();
|
||||
}
|
||||
auto actor = get_message_sender_object_const(td_, user_id, actor_dialog_id, "GetChannelAdminLogQuery");
|
||||
result->events_.push_back(
|
||||
td_api::make_object<td_api::chatEvent>(event->id_, event->date_, std::move(actor), std::move(action)));
|
||||
}
|
||||
|
||||
promise_.set_value(std::move(result));
|
||||
|
@ -23529,14 +23529,15 @@ tl_object_ptr<td_api::MessageSchedulingState> MessagesManager::get_message_sched
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::message> MessagesManager::get_dialog_event_log_message_object(
|
||||
DialogId dialog_id, tl_object_ptr<telegram_api::Message> &&message) {
|
||||
DialogId dialog_id, tl_object_ptr<telegram_api::Message> &&message, DialogId &sender_dialog_id) {
|
||||
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);
|
||||
sender_dialog_id = get_message_sender(dialog_message.second.get());
|
||||
return get_message_object(dialog_id, dialog_message.second.get(), "get_dialog_event_log_message_object", true);
|
||||
}
|
||||
|
||||
tl_object_ptr<td_api::message> MessagesManager::get_message_object(FullMessageId full_message_id, const char *source) {
|
||||
|
@ -772,7 +772,7 @@ 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);
|
||||
DialogId dialog_id, tl_object_ptr<telegram_api::Message> &&message, DialogId &sender_dialog_id);
|
||||
|
||||
tl_object_ptr<td_api::message> get_message_object(FullMessageId full_message_id, const char *source);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user