Persistent change_dialog_report_spam_state.
GitOrigin-RevId: 8a11181cc78b3fe2e7536c49a198c6fa99fa348c
This commit is contained in:
parent
0f2769bc77
commit
b998431081
@ -6571,6 +6571,45 @@ void MessagesManager::change_dialog_report_spam_state(DialogId dialog_id, bool i
|
|||||||
return promise.set_error(Status::Error(3, "Can't update chat report spam state"));
|
return promise.set_error(Status::Error(3, "Can't update chat report spam state"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
d->can_report_spam = false;
|
||||||
|
on_dialog_updated(dialog_id, "change_dialog_report_spam_state");
|
||||||
|
|
||||||
|
change_dialog_report_spam_state_on_server(dialog_id, is_spam_dialog, 0, std::move(promise));
|
||||||
|
}
|
||||||
|
|
||||||
|
class MessagesManager::ChangeDialogReportSpamStateOnServerLogEvent {
|
||||||
|
public:
|
||||||
|
DialogId dialog_id_;
|
||||||
|
bool is_spam_dialog_;
|
||||||
|
|
||||||
|
template <class StorerT>
|
||||||
|
void store(StorerT &storer) const {
|
||||||
|
td::store(dialog_id_, storer);
|
||||||
|
td::store(is_spam_dialog_, storer);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class ParserT>
|
||||||
|
void parse(ParserT &parser) {
|
||||||
|
td::parse(dialog_id_, parser);
|
||||||
|
td::parse(is_spam_dialog_, parser);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void MessagesManager::change_dialog_report_spam_state_on_server(DialogId dialog_id, bool is_spam_dialog,
|
||||||
|
uint64 logevent_id, Promise<Unit> &&promise) {
|
||||||
|
if (logevent_id == 0 && G()->parameters().use_message_db) {
|
||||||
|
ChangeDialogReportSpamStateOnServerLogEvent logevent;
|
||||||
|
logevent.dialog_id_ = dialog_id;
|
||||||
|
logevent.is_spam_dialog_ = is_spam_dialog;
|
||||||
|
|
||||||
|
auto storer = LogEventStorerImpl<ChangeDialogReportSpamStateOnServerLogEvent>(logevent);
|
||||||
|
logevent_id = BinlogHelper::add(G()->td_db()->get_binlog(),
|
||||||
|
LogEvent::HandlerType::ChangeDialogReportSpamStateOnServer, storer);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto new_promise = get_erase_logevent_promise(logevent_id, std::move(promise));
|
||||||
|
promise = std::move(new_promise); // to prevent self-move
|
||||||
|
|
||||||
switch (dialog_id.get_type()) {
|
switch (dialog_id.get_type()) {
|
||||||
case DialogType::User:
|
case DialogType::User:
|
||||||
case DialogType::Chat:
|
case DialogType::Chat:
|
||||||
@ -6580,8 +6619,6 @@ void MessagesManager::change_dialog_report_spam_state(DialogId dialog_id, bool i
|
|||||||
if (is_spam_dialog) {
|
if (is_spam_dialog) {
|
||||||
return td_->create_handler<ReportEncryptedSpamQuery>(std::move(promise))->send(dialog_id);
|
return td_->create_handler<ReportEncryptedSpamQuery>(std::move(promise))->send(dialog_id);
|
||||||
} else {
|
} else {
|
||||||
d->can_report_spam = false;
|
|
||||||
on_dialog_updated(dialog_id, "change_dialog_report_spam_state");
|
|
||||||
promise.set_value(Unit());
|
promise.set_value(Unit());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -25239,6 +25276,25 @@ void MessagesManager::on_binlog_events(vector<BinlogEvent> &&events) {
|
|||||||
reset_all_notification_settings_on_server(event.id_);
|
reset_all_notification_settings_on_server(event.id_);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case LogEvent::HandlerType::ChangeDialogReportSpamStateOnServer: {
|
||||||
|
if (!G()->parameters().use_message_db) {
|
||||||
|
BinlogHelper::erase(G()->td_db()->get_binlog(), event.id_);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
ChangeDialogReportSpamStateOnServerLogEvent log_event;
|
||||||
|
log_event_parse(log_event, event.data_).ensure();
|
||||||
|
|
||||||
|
auto dialog_id = log_event.dialog_id_;
|
||||||
|
Dialog *d = get_dialog_force(dialog_id);
|
||||||
|
if (d == nullptr || !have_input_peer(dialog_id, AccessRights::Read)) {
|
||||||
|
BinlogHelper::erase(G()->td_db()->get_binlog(), event.id_);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
change_dialog_report_spam_state_on_server(dialog_id, log_event.is_spam_dialog_, event.id_, Promise<Unit>());
|
||||||
|
break;
|
||||||
|
}
|
||||||
case LogEvent::HandlerType::GetChannelDifference: {
|
case LogEvent::HandlerType::GetChannelDifference: {
|
||||||
GetChannelDifferenceLogEvent log_event;
|
GetChannelDifferenceLogEvent log_event;
|
||||||
log_event_parse(log_event, event.data_).ensure();
|
log_event_parse(log_event, event.data_).ensure();
|
||||||
|
@ -1842,6 +1842,7 @@ class MessagesManager : public Actor {
|
|||||||
class UpdateDialogNotificationSettingsOnServerLogEvent;
|
class UpdateDialogNotificationSettingsOnServerLogEvent;
|
||||||
class UpdateScopeNotificationSettingsOnServerLogEvent;
|
class UpdateScopeNotificationSettingsOnServerLogEvent;
|
||||||
class ResetAllNotificationSettingsOnServerLogEvent;
|
class ResetAllNotificationSettingsOnServerLogEvent;
|
||||||
|
class ChangeDialogReportSpamStateOnServerLogEvent;
|
||||||
class SendBotStartMessageLogEvent;
|
class SendBotStartMessageLogEvent;
|
||||||
class SendInlineQueryResultMessageLogEvent;
|
class SendInlineQueryResultMessageLogEvent;
|
||||||
class SendMessageLogEvent;
|
class SendMessageLogEvent;
|
||||||
@ -2492,6 +2493,9 @@ class MessagesManager : public Actor {
|
|||||||
|
|
||||||
void reset_all_notification_settings_on_server(uint64 logevent_id);
|
void reset_all_notification_settings_on_server(uint64 logevent_id);
|
||||||
|
|
||||||
|
void change_dialog_report_spam_state_on_server(DialogId dialog_id, bool is_spam_dialog, uint64 logevent_id,
|
||||||
|
Promise<Unit> &&promise);
|
||||||
|
|
||||||
int64 get_next_pinned_dialog_order();
|
int64 get_next_pinned_dialog_order();
|
||||||
|
|
||||||
void update_dialog_pos(Dialog *d, bool remove_from_dialog_list, const char *source,
|
void update_dialog_pos(Dialog *d, bool remove_from_dialog_list, const char *source,
|
||||||
|
@ -85,6 +85,7 @@ Status init_binlog(Binlog &binlog, string path, BinlogKeyValue<Binlog> &binlog_p
|
|||||||
case LogEvent::HandlerType::UpdateDialogNotificationSettingsOnServer:
|
case LogEvent::HandlerType::UpdateDialogNotificationSettingsOnServer:
|
||||||
case LogEvent::HandlerType::UpdateScopeNotificationSettingsOnServer:
|
case LogEvent::HandlerType::UpdateScopeNotificationSettingsOnServer:
|
||||||
case LogEvent::HandlerType::ResetAllNotificationSettingsOnServer:
|
case LogEvent::HandlerType::ResetAllNotificationSettingsOnServer:
|
||||||
|
case LogEvent::HandlerType::ChangeDialogReportSpamStateOnServer:
|
||||||
case LogEvent::HandlerType::GetChannelDifference:
|
case LogEvent::HandlerType::GetChannelDifference:
|
||||||
events.to_messages_manager.push_back(event.clone());
|
events.to_messages_manager.push_back(event.clone());
|
||||||
break;
|
break;
|
||||||
|
@ -86,6 +86,7 @@ class LogEvent {
|
|||||||
UpdateDialogNotificationSettingsOnServer = 0x10f,
|
UpdateDialogNotificationSettingsOnServer = 0x10f,
|
||||||
UpdateScopeNotificationSettingsOnServer = 0x110,
|
UpdateScopeNotificationSettingsOnServer = 0x110,
|
||||||
ResetAllNotificationSettingsOnServer = 0x111,
|
ResetAllNotificationSettingsOnServer = 0x111,
|
||||||
|
ChangeDialogReportSpamStateOnServer = 0x112,
|
||||||
GetChannelDifference = 0x140,
|
GetChannelDifference = 0x140,
|
||||||
ConfigPmcMagic = 0x1f18,
|
ConfigPmcMagic = 0x1f18,
|
||||||
BinlogPmcMagic = 0x4327
|
BinlogPmcMagic = 0x4327
|
||||||
|
Reference in New Issue
Block a user