Add MessagesManager::generate_new_media_album_id() method.
GitOrigin-RevId: 1a0c71404b09585f66728ea494a8bd920795664c
This commit is contained in:
parent
611878f098
commit
cbd4b2a8a4
@ -16313,6 +16313,15 @@ Result<InputMessageContent> MessagesManager::process_input_message_content(
|
||||
return std::move(content);
|
||||
}
|
||||
|
||||
int64 MessagesManager::generate_new_media_album_id() {
|
||||
int64 media_album_id = 0;
|
||||
do {
|
||||
media_album_id = Random::secure_int64();
|
||||
} while (media_album_id >= 0 || pending_message_group_sends_.count(media_album_id) != 0);
|
||||
pending_message_group_sends_[media_album_id]; // reserve place for the group
|
||||
return media_album_id;
|
||||
}
|
||||
|
||||
Result<vector<MessageId>> MessagesManager::send_message_group(
|
||||
DialogId dialog_id, MessageId reply_to_message_id, bool disable_notification, bool from_background,
|
||||
vector<tl_object_ptr<td_api::InputMessageContent>> &&input_message_contents) {
|
||||
@ -16344,9 +16353,7 @@ Result<vector<MessageId>> MessagesManager::send_message_group(
|
||||
|
||||
int64 media_album_id = 0;
|
||||
if (message_contents.size() > 1) {
|
||||
do {
|
||||
media_album_id = Random::secure_int64();
|
||||
} while (media_album_id >= 0 || pending_message_group_sends_.count(media_album_id) != 0);
|
||||
media_album_id = generate_new_media_album_id();
|
||||
}
|
||||
|
||||
// there must be no errors after get_message_to_send calls
|
||||
@ -18575,11 +18582,7 @@ Result<vector<MessageId>> MessagesManager::forward_messages(DialogId to_dialog_i
|
||||
}
|
||||
|
||||
if (allow_album) {
|
||||
int64 media_album_id = 0;
|
||||
do {
|
||||
media_album_id = Random::secure_int64();
|
||||
} while (media_album_id >= 0 || pending_message_group_sends_.count(media_album_id) != 0);
|
||||
|
||||
int64 media_album_id = generate_new_media_album_id();
|
||||
for (auto m : forwarded_messages) {
|
||||
m->media_album_id = media_album_id;
|
||||
}
|
||||
@ -18605,9 +18608,7 @@ Result<vector<MessageId>> MessagesManager::forward_messages(DialogId to_dialog_i
|
||||
}
|
||||
|
||||
if (allow_album) {
|
||||
do {
|
||||
media_album_id = Random::secure_int64();
|
||||
} while (media_album_id >= 0 || pending_message_group_sends_.count(media_album_id) != 0);
|
||||
media_album_id = generate_new_media_album_id();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1434,6 +1434,8 @@ class MessagesManager : public Actor {
|
||||
|
||||
bool is_message_unload_enabled() const;
|
||||
|
||||
int64 generate_new_media_album_id();
|
||||
|
||||
static bool can_forward_message(DialogId from_dialog_id, const Message *m);
|
||||
|
||||
static bool can_delete_channel_message(DialogParticipantStatus status, const Message *m, bool is_bot);
|
||||
|
Loading…
Reference in New Issue
Block a user