Add deleteAllCallMessages method.
This commit is contained in:
parent
3ff68546ab
commit
4fa29ab1b8
@ -3859,6 +3859,9 @@ searchSecretMessages chat_id:int53 query:string offset:string limit:int32 filter
|
|||||||
//@limit The maximum number of messages to be returned; up to 100. Fewer messages may be returned than specified by the limit, even if the end of the message history has not been reached @only_missed If true, returns only messages with missed calls
|
//@limit The maximum number of messages to be returned; up to 100. Fewer messages may be returned than specified by the limit, even if the end of the message history has not been reached @only_missed If true, returns only messages with missed calls
|
||||||
searchCallMessages from_message_id:int53 limit:int32 only_missed:Bool = Messages;
|
searchCallMessages from_message_id:int53 limit:int32 only_missed:Bool = Messages;
|
||||||
|
|
||||||
|
//@description Deletes all call messages @revoke Pass true to delete the messages for all users
|
||||||
|
deleteAllCallMessages revoke:Bool = Ok;
|
||||||
|
|
||||||
//@description Returns information about the recent locations of chat members that were sent to the chat. Returns up to 1 location message per user @chat_id Chat identifier @limit The maximum number of messages to be returned
|
//@description Returns information about the recent locations of chat members that were sent to the chat. Returns up to 1 location message per user @chat_id Chat identifier @limit The maximum number of messages to be returned
|
||||||
searchChatRecentLocationMessages chat_id:int53 limit:int32 = Messages;
|
searchChatRecentLocationMessages chat_id:int53 limit:int32 = Messages;
|
||||||
|
|
||||||
|
Binary file not shown.
@ -2303,6 +2303,59 @@ class DeleteChannelHistoryQuery : public Td::ResultHandler {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class DeletePhoneCallHistoryQuery : public Td::ResultHandler {
|
||||||
|
Promise<Unit> promise_;
|
||||||
|
bool revoke_;
|
||||||
|
|
||||||
|
void send_request() {
|
||||||
|
int32 flags = 0;
|
||||||
|
if (revoke_) {
|
||||||
|
flags |= telegram_api::messages_deletePhoneCallHistory::REVOKE_MASK;
|
||||||
|
}
|
||||||
|
send_query(
|
||||||
|
G()->net_query_creator().create(telegram_api::messages_deletePhoneCallHistory(flags, false /*ignored*/)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit DeletePhoneCallHistoryQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void send(bool revoke) {
|
||||||
|
revoke_ = revoke;
|
||||||
|
|
||||||
|
send_request();
|
||||||
|
}
|
||||||
|
|
||||||
|
void on_result(uint64 id, BufferSlice packet) override {
|
||||||
|
auto result_ptr = fetch_result<telegram_api::messages_deletePhoneCallHistory>(packet);
|
||||||
|
if (result_ptr.is_error()) {
|
||||||
|
return on_error(id, result_ptr.move_as_error());
|
||||||
|
}
|
||||||
|
|
||||||
|
auto affected_history = result_ptr.move_as_ok();
|
||||||
|
CHECK(affected_history->get_id() == telegram_api::messages_affectedHistory::ID);
|
||||||
|
|
||||||
|
if (affected_history->pts_count_ > 0) {
|
||||||
|
affected_history->pts_count_ = 0; // force receiving real updates from the server
|
||||||
|
auto promise = affected_history->offset_ > 0 ? Promise<Unit>() : std::move(promise_);
|
||||||
|
td->updates_manager_->add_pending_pts_update(make_tl_object<dummyUpdate>(), affected_history->pts_,
|
||||||
|
affected_history->pts_count_, std::move(promise),
|
||||||
|
"delete phone call history query");
|
||||||
|
} else if (affected_history->offset_ <= 0) {
|
||||||
|
promise_.set_value(Unit());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (affected_history->offset_ > 0) {
|
||||||
|
send_request();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void on_error(uint64 id, Status status) override {
|
||||||
|
promise_.set_error(std::move(status));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class BlockFromRepliesQuery : public Td::ResultHandler {
|
class BlockFromRepliesQuery : public Td::ResultHandler {
|
||||||
Promise<Unit> promise_;
|
Promise<Unit> promise_;
|
||||||
|
|
||||||
@ -10075,6 +10128,46 @@ void MessagesManager::delete_dialog_history_from_server(DialogId dialog_id, Mess
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MessagesManager::delete_all_call_messages(bool revoke, Promise<Unit> &&promise) {
|
||||||
|
delete_all_call_messages_from_server(revoke, 0, std::move(promise));
|
||||||
|
}
|
||||||
|
|
||||||
|
class MessagesManager::DeleteAllCallMessagesFromServerLogEvent {
|
||||||
|
public:
|
||||||
|
bool revoke_;
|
||||||
|
|
||||||
|
template <class StorerT>
|
||||||
|
void store(StorerT &storer) const {
|
||||||
|
BEGIN_STORE_FLAGS();
|
||||||
|
STORE_FLAG(revoke_);
|
||||||
|
END_STORE_FLAGS();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class ParserT>
|
||||||
|
void parse(ParserT &parser) {
|
||||||
|
BEGIN_PARSE_FLAGS();
|
||||||
|
PARSE_FLAG(revoke_);
|
||||||
|
END_PARSE_FLAGS();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
uint64 MessagesManager::save_delete_all_call_messages_from_server_log_event(bool revoke) {
|
||||||
|
DeleteAllCallMessagesFromServerLogEvent log_event{revoke};
|
||||||
|
return binlog_add(G()->td_db()->get_binlog(), LogEvent::HandlerType::DeleteAllCallMessagesFromServer,
|
||||||
|
get_log_event_storer(log_event));
|
||||||
|
}
|
||||||
|
|
||||||
|
void MessagesManager::delete_all_call_messages_from_server(bool revoke, uint64 log_event_id, Promise<Unit> &&promise) {
|
||||||
|
if (log_event_id == 0) {
|
||||||
|
log_event_id = save_delete_all_call_messages_from_server_log_event(revoke);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto new_promise = get_erase_log_event_promise(log_event_id, std::move(promise));
|
||||||
|
promise = std::move(new_promise); // to prevent self-move
|
||||||
|
|
||||||
|
td_->create_handler<DeletePhoneCallHistoryQuery>(std::move(promise))->send(revoke);
|
||||||
|
}
|
||||||
|
|
||||||
void MessagesManager::find_messages(const Message *m, vector<MessageId> &message_ids,
|
void MessagesManager::find_messages(const Message *m, vector<MessageId> &message_ids,
|
||||||
const std::function<bool(const Message *)> &condition) {
|
const std::function<bool(const Message *)> &condition) {
|
||||||
if (m == nullptr) {
|
if (m == nullptr) {
|
||||||
@ -35568,6 +35661,13 @@ void MessagesManager::on_binlog_events(vector<BinlogEvent> &&events) {
|
|||||||
log_event.revoke_, true, event.id_, Auto());
|
log_event.revoke_, true, event.id_, Auto());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case LogEvent::HandlerType::DeleteAllCallMessagesFromServer: {
|
||||||
|
DeleteAllCallMessagesFromServerLogEvent log_event;
|
||||||
|
log_event_parse(log_event, event.data_).ensure();
|
||||||
|
|
||||||
|
delete_all_call_messages_from_server(log_event.revoke_, event.id_, Auto());
|
||||||
|
break;
|
||||||
|
}
|
||||||
case LogEvent::HandlerType::BlockMessageSenderFromRepliesOnServer: {
|
case LogEvent::HandlerType::BlockMessageSenderFromRepliesOnServer: {
|
||||||
BlockMessageSenderFromRepliesOnServerLogEvent log_event;
|
BlockMessageSenderFromRepliesOnServerLogEvent log_event;
|
||||||
log_event_parse(log_event, event.data_).ensure();
|
log_event_parse(log_event, event.data_).ensure();
|
||||||
|
@ -338,6 +338,8 @@ class MessagesManager : public Actor {
|
|||||||
|
|
||||||
void delete_dialog_history(DialogId dialog_id, bool remove_from_dialog_list, bool revoke, Promise<Unit> &&promise);
|
void delete_dialog_history(DialogId dialog_id, bool remove_from_dialog_list, bool revoke, Promise<Unit> &&promise);
|
||||||
|
|
||||||
|
void delete_all_call_messages(bool revoke, Promise<Unit> &&promise);
|
||||||
|
|
||||||
void delete_dialog_messages_from_user(DialogId dialog_id, UserId user_id, Promise<Unit> &&promise);
|
void delete_dialog_messages_from_user(DialogId dialog_id, UserId user_id, Promise<Unit> &&promise);
|
||||||
|
|
||||||
void delete_dialog(DialogId dialog_id);
|
void delete_dialog(DialogId dialog_id);
|
||||||
@ -1591,6 +1593,7 @@ class MessagesManager : public Actor {
|
|||||||
class ChangeDialogReportSpamStateOnServerLogEvent;
|
class ChangeDialogReportSpamStateOnServerLogEvent;
|
||||||
class DeleteAllChannelMessagesFromUserOnServerLogEvent;
|
class DeleteAllChannelMessagesFromUserOnServerLogEvent;
|
||||||
class DeleteDialogHistoryFromServerLogEvent;
|
class DeleteDialogHistoryFromServerLogEvent;
|
||||||
|
class DeleteAllCallMessagesFromServerLogEvent;
|
||||||
class DeleteMessageLogEvent;
|
class DeleteMessageLogEvent;
|
||||||
class DeleteMessagesFromServerLogEvent;
|
class DeleteMessagesFromServerLogEvent;
|
||||||
class DeleteScheduledMessagesFromServerLogEvent;
|
class DeleteScheduledMessagesFromServerLogEvent;
|
||||||
@ -1888,6 +1891,8 @@ class MessagesManager : public Actor {
|
|||||||
void delete_dialog_history_from_server(DialogId dialog_id, MessageId max_message_id, bool remove_from_dialog_list,
|
void delete_dialog_history_from_server(DialogId dialog_id, MessageId max_message_id, bool remove_from_dialog_list,
|
||||||
bool revoke, bool allow_error, uint64 log_event_id, Promise<Unit> &&promise);
|
bool revoke, bool allow_error, uint64 log_event_id, Promise<Unit> &&promise);
|
||||||
|
|
||||||
|
void delete_all_call_messages_from_server(bool revoke, uint64 log_event_id, Promise<Unit> &&promise);
|
||||||
|
|
||||||
void block_message_sender_from_replies_on_server(MessageId message_id, bool delete_message, bool delete_all_messages,
|
void block_message_sender_from_replies_on_server(MessageId message_id, bool delete_message, bool delete_all_messages,
|
||||||
bool report_spam, uint64 log_event_id, Promise<Unit> &&promise);
|
bool report_spam, uint64 log_event_id, Promise<Unit> &&promise);
|
||||||
|
|
||||||
@ -2884,6 +2889,8 @@ class MessagesManager : public Actor {
|
|||||||
uint64 save_delete_dialog_history_from_server_log_event(DialogId dialog_id, MessageId max_message_id,
|
uint64 save_delete_dialog_history_from_server_log_event(DialogId dialog_id, MessageId max_message_id,
|
||||||
bool remove_from_dialog_list, bool revoke);
|
bool remove_from_dialog_list, bool revoke);
|
||||||
|
|
||||||
|
uint64 save_delete_all_call_messages_from_server_log_event(bool revoke);
|
||||||
|
|
||||||
uint64 save_block_message_sender_from_replies_on_server_log_event(MessageId message_id, bool delete_message,
|
uint64 save_block_message_sender_from_replies_on_server_log_event(MessageId message_id, bool delete_message,
|
||||||
bool delete_all_messages, bool report_spam);
|
bool delete_all_messages, bool report_spam);
|
||||||
|
|
||||||
|
@ -5511,6 +5511,12 @@ void Td::on_request(uint64 id, td_api::searchCallMessages &request) {
|
|||||||
CREATE_REQUEST(SearchCallMessagesRequest, request.from_message_id_, request.limit_, request.only_missed_);
|
CREATE_REQUEST(SearchCallMessagesRequest, request.from_message_id_, request.limit_, request.only_missed_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Td::on_request(uint64 id, const td_api::deleteAllCallMessages &request) {
|
||||||
|
CHECK_IS_USER();
|
||||||
|
CREATE_OK_REQUEST_PROMISE();
|
||||||
|
messages_manager_->delete_all_call_messages(request.revoke_, std::move(promise));
|
||||||
|
}
|
||||||
|
|
||||||
void Td::on_request(uint64 id, const td_api::searchChatRecentLocationMessages &request) {
|
void Td::on_request(uint64 id, const td_api::searchChatRecentLocationMessages &request) {
|
||||||
CHECK_IS_USER();
|
CHECK_IS_USER();
|
||||||
CREATE_REQUEST(SearchChatRecentLocationMessagesRequest, request.chat_id_, request.limit_);
|
CREATE_REQUEST(SearchChatRecentLocationMessagesRequest, request.chat_id_, request.limit_);
|
||||||
|
@ -588,6 +588,8 @@ class Td final : public NetQueryCallback {
|
|||||||
|
|
||||||
void on_request(uint64 id, td_api::searchCallMessages &request);
|
void on_request(uint64 id, td_api::searchCallMessages &request);
|
||||||
|
|
||||||
|
void on_request(uint64 id, const td_api::deleteAllCallMessages &request);
|
||||||
|
|
||||||
void on_request(uint64 id, const td_api::searchChatRecentLocationMessages &request);
|
void on_request(uint64 id, const td_api::searchChatRecentLocationMessages &request);
|
||||||
|
|
||||||
void on_request(uint64 id, const td_api::getActiveLiveLocationMessages &request);
|
void on_request(uint64 id, const td_api::getActiveLiveLocationMessages &request);
|
||||||
|
@ -116,6 +116,7 @@ Status init_binlog(Binlog &binlog, string path, BinlogKeyValue<Binlog> &binlog_p
|
|||||||
case LogEvent::HandlerType::ReadMessageThreadHistoryOnServer:
|
case LogEvent::HandlerType::ReadMessageThreadHistoryOnServer:
|
||||||
case LogEvent::HandlerType::BlockMessageSenderFromRepliesOnServer:
|
case LogEvent::HandlerType::BlockMessageSenderFromRepliesOnServer:
|
||||||
case LogEvent::HandlerType::UnpinAllDialogMessagesOnServer:
|
case LogEvent::HandlerType::UnpinAllDialogMessagesOnServer:
|
||||||
|
case LogEvent::HandlerType::DeleteAllCallMessagesFromServer:
|
||||||
events.to_messages_manager.push_back(event.clone());
|
events.to_messages_manager.push_back(event.clone());
|
||||||
break;
|
break;
|
||||||
case LogEvent::HandlerType::AddMessagePushNotification:
|
case LogEvent::HandlerType::AddMessagePushNotification:
|
||||||
|
@ -2013,6 +2013,9 @@ class CliClient final : public Actor {
|
|||||||
get_args(args, limit, offset_message_id, only_missed);
|
get_args(args, limit, offset_message_id, only_missed);
|
||||||
send_request(td_api::make_object<td_api::searchCallMessages>(as_message_id(offset_message_id), as_limit(limit),
|
send_request(td_api::make_object<td_api::searchCallMessages>(as_message_id(offset_message_id), as_limit(limit),
|
||||||
only_missed));
|
only_missed));
|
||||||
|
} else if (op == "DeleteAllCallMessages") {
|
||||||
|
bool revoke = as_bool(args);
|
||||||
|
send_request(td_api::make_object<td_api::deleteAllCallMessages>(revoke));
|
||||||
} else if (op == "SCRLM") {
|
} else if (op == "SCRLM") {
|
||||||
string chat_id;
|
string chat_id;
|
||||||
string limit;
|
string limit;
|
||||||
|
@ -100,6 +100,7 @@ class LogEvent {
|
|||||||
ReadMessageThreadHistoryOnServer = 0x119,
|
ReadMessageThreadHistoryOnServer = 0x119,
|
||||||
BlockMessageSenderFromRepliesOnServer = 0x120,
|
BlockMessageSenderFromRepliesOnServer = 0x120,
|
||||||
UnpinAllDialogMessagesOnServer = 0x121,
|
UnpinAllDialogMessagesOnServer = 0x121,
|
||||||
|
DeleteAllCallMessagesFromServer = 0x122,
|
||||||
GetChannelDifference = 0x140,
|
GetChannelDifference = 0x140,
|
||||||
AddMessagePushNotification = 0x200,
|
AddMessagePushNotification = 0x200,
|
||||||
EditMessagePushNotification = 0x201,
|
EditMessagePushNotification = 0x201,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user