Delete downlaoded files when a temporary message push notification is deleted.
GitOrigin-RevId: c0ad85377cf336d98fa5d79697f0389e3c65ec7c
This commit is contained in:
parent
d42df63ba9
commit
2ccd37584f
@ -1902,6 +1902,9 @@ void NotificationManager::remove_temporary_notification_by_message_id(Notificati
|
||||
auto remove_notification_by_message_id = [&](auto ¬ifications) {
|
||||
for (auto ¬ification : notifications) {
|
||||
if (notification.type->get_message_id() == message_id) {
|
||||
for (auto file_id : notification.type->get_file_ids(td_)) {
|
||||
this->td_->file_manager_->delete_file(file_id, Promise<>(), "remove_temporary_notification_by_message_id");
|
||||
}
|
||||
return this->remove_notification(group_id, notification.notification_id, true, force_update, Auto());
|
||||
}
|
||||
}
|
||||
|
@ -36,6 +36,10 @@ class NotificationTypeMessage : public NotificationType {
|
||||
return message_id_;
|
||||
}
|
||||
|
||||
vector<FileId> get_file_ids(const Td *td) const override {
|
||||
return {};
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::NotificationType> get_notification_type_object(DialogId dialog_id) const override {
|
||||
auto message_object = G()->td().get_actor_unsafe()->messages_manager_->get_message_object({dialog_id, message_id_});
|
||||
if (message_object == nullptr) {
|
||||
@ -72,6 +76,10 @@ class NotificationTypeSecretChat : public NotificationType {
|
||||
return MessageId();
|
||||
}
|
||||
|
||||
vector<FileId> get_file_ids(const Td *td) const override {
|
||||
return {};
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::NotificationType> get_notification_type_object(DialogId dialog_id) const override {
|
||||
return td_api::make_object<td_api::notificationTypeNewSecretChat>();
|
||||
}
|
||||
@ -102,6 +110,10 @@ class NotificationTypeCall : public NotificationType {
|
||||
return MessageId::max();
|
||||
}
|
||||
|
||||
vector<FileId> get_file_ids(const Td *td) const override {
|
||||
return {};
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::NotificationType> get_notification_type_object(DialogId dialog_id) const override {
|
||||
return td_api::make_object<td_api::notificationTypeNewCall>(call_id_.get());
|
||||
}
|
||||
@ -134,6 +146,14 @@ class NotificationTypePushMessage : public NotificationType {
|
||||
return message_id_;
|
||||
}
|
||||
|
||||
vector<FileId> get_file_ids(const Td *td) const override {
|
||||
if (!document_.empty()) {
|
||||
return document_.get_file_ids(td);
|
||||
}
|
||||
|
||||
return photo_get_file_ids(photo_);
|
||||
}
|
||||
|
||||
static td_api::object_ptr<td_api::PushMessageContent> get_push_message_content_object(Slice key, const string &arg,
|
||||
const Photo &photo,
|
||||
const Document &document) {
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "td/telegram/CallId.h"
|
||||
#include "td/telegram/DialogId.h"
|
||||
#include "td/telegram/Document.h"
|
||||
#include "td/telegram/files/FileId.h"
|
||||
#include "td/telegram/MessageId.h"
|
||||
#include "td/telegram/Photo.h"
|
||||
#include "td/telegram/td_api.h"
|
||||
@ -36,6 +37,8 @@ class NotificationType {
|
||||
|
||||
virtual MessageId get_message_id() const = 0;
|
||||
|
||||
virtual vector<FileId> get_file_ids(const Td *td) const = 0;
|
||||
|
||||
virtual td_api::object_ptr<td_api::NotificationType> get_notification_type_object(DialogId dialog_id) const = 0;
|
||||
|
||||
virtual StringBuilder &to_string_builder(StringBuilder &string_builder) const = 0;
|
||||
|
Reference in New Issue
Block a user