Register video note messages.
This commit is contained in:
parent
ea12905dd2
commit
02ed5e4f1e
@ -3922,6 +3922,9 @@ void register_message_content(Td *td, const MessageContent *content, FullMessage
|
||||
}
|
||||
return;
|
||||
}
|
||||
case MessageContentType::VideoNote:
|
||||
return td->video_notes_manager_->register_video_note(static_cast<const MessageVideoNote *>(content)->file_id,
|
||||
full_message_id, source);
|
||||
case MessageContentType::VoiceNote:
|
||||
return td->voice_notes_manager_->register_voice_note(static_cast<const MessageVoiceNote *>(content)->file_id,
|
||||
full_message_id, source);
|
||||
@ -3956,6 +3959,12 @@ void reregister_message_content(Td *td, const MessageContent *old_content, const
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MessageContentType::VideoNote:
|
||||
if (static_cast<const MessageVideoNote *>(old_content)->file_id ==
|
||||
static_cast<const MessageVideoNote *>(new_content)->file_id) {
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case MessageContentType::VoiceNote:
|
||||
if (static_cast<const MessageVoiceNote *>(old_content)->file_id ==
|
||||
static_cast<const MessageVoiceNote *>(new_content)->file_id) {
|
||||
@ -4003,6 +4012,9 @@ void unregister_message_content(Td *td, const MessageContent *content, FullMessa
|
||||
}
|
||||
return;
|
||||
}
|
||||
case MessageContentType::VideoNote:
|
||||
return td->video_notes_manager_->unregister_video_note(static_cast<const MessageVideoNote *>(content)->file_id,
|
||||
full_message_id, source);
|
||||
case MessageContentType::VoiceNote:
|
||||
return td->voice_notes_manager_->unregister_voice_note(static_cast<const MessageVoiceNote *>(content)->file_id,
|
||||
full_message_id, source);
|
||||
|
@ -141,6 +141,34 @@ void VideoNotesManager::create_video_note(FileId file_id, string minithumbnail,
|
||||
on_get_video_note(std::move(v), replace);
|
||||
}
|
||||
|
||||
void VideoNotesManager::register_video_note(FileId video_note_file_id, FullMessageId full_message_id,
|
||||
const char *source) {
|
||||
if (full_message_id.get_message_id().is_scheduled() || !full_message_id.get_message_id().is_server()) {
|
||||
return;
|
||||
}
|
||||
LOG(INFO) << "Register video note " << video_note_file_id << " from " << full_message_id << " from " << source;
|
||||
bool is_inserted = video_note_messages_[video_note_file_id].insert(full_message_id).second;
|
||||
LOG_CHECK(is_inserted) << source << ' ' << video_note_file_id << ' ' << full_message_id;
|
||||
is_inserted = message_video_notes_.emplace(full_message_id, video_note_file_id).second;
|
||||
CHECK(is_inserted);
|
||||
}
|
||||
|
||||
void VideoNotesManager::unregister_video_note(FileId video_note_file_id, FullMessageId full_message_id,
|
||||
const char *source) {
|
||||
if (full_message_id.get_message_id().is_scheduled() || !full_message_id.get_message_id().is_server()) {
|
||||
return;
|
||||
}
|
||||
LOG(INFO) << "Unregister video note " << video_note_file_id << " from " << full_message_id << " from " << source;
|
||||
auto &message_ids = video_note_messages_[video_note_file_id];
|
||||
auto is_deleted = message_ids.erase(full_message_id) > 0;
|
||||
LOG_CHECK(is_deleted) << source << ' ' << video_note_file_id << ' ' << full_message_id;
|
||||
if (message_ids.empty()) {
|
||||
video_note_messages_.erase(video_note_file_id);
|
||||
}
|
||||
is_deleted = message_video_notes_.erase(full_message_id) > 0;
|
||||
CHECK(is_deleted);
|
||||
}
|
||||
|
||||
SecretInputMedia VideoNotesManager::get_secret_input_media(FileId video_note_file_id,
|
||||
tl_object_ptr<telegram_api::InputEncryptedFile> input_file,
|
||||
BufferSlice thumbnail, int32 layer) const {
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
#include "td/telegram/Dimensions.h"
|
||||
#include "td/telegram/files/FileId.h"
|
||||
#include "td/telegram/FullMessageId.h"
|
||||
#include "td/telegram/PhotoSize.h"
|
||||
#include "td/telegram/SecretInputMedia.h"
|
||||
#include "td/telegram/td_api.h"
|
||||
@ -15,6 +16,7 @@
|
||||
|
||||
#include "td/utils/buffer.h"
|
||||
#include "td/utils/common.h"
|
||||
#include "td/utils/FlatHashSet.h"
|
||||
#include "td/utils/WaitFreeHashMap.h"
|
||||
|
||||
namespace td {
|
||||
@ -37,6 +39,10 @@ class VideoNotesManager {
|
||||
void create_video_note(FileId file_id, string minithumbnail, PhotoSize thumbnail, int32 duration,
|
||||
Dimensions dimensions, bool replace);
|
||||
|
||||
void register_video_note(FileId video_note_file_id, FullMessageId full_message_id, const char *source);
|
||||
|
||||
void unregister_video_note(FileId video_note_file_id, FullMessageId full_message_id, const char *source);
|
||||
|
||||
tl_object_ptr<telegram_api::InputMedia> get_input_media(FileId file_id,
|
||||
tl_object_ptr<telegram_api::InputFile> input_file,
|
||||
tl_object_ptr<telegram_api::InputFile> input_thumbnail) const;
|
||||
@ -76,6 +82,9 @@ class VideoNotesManager {
|
||||
|
||||
Td *td_;
|
||||
WaitFreeHashMap<FileId, unique_ptr<VideoNote>, FileIdHash> video_notes_;
|
||||
|
||||
FlatHashMap<FileId, FlatHashSet<FullMessageId, FullMessageIdHash>, FileIdHash> video_note_messages_;
|
||||
FlatHashMap<FullMessageId, FileId, FullMessageIdHash> message_video_notes_;
|
||||
};
|
||||
|
||||
} // namespace td
|
||||
|
Loading…
Reference in New Issue
Block a user