Add notificationSound.date.
This commit is contained in:
parent
497bc9006a
commit
ff50eec3ee
@ -3162,10 +3162,11 @@ notificationGroupTypeCalls = NotificationGroupType;
|
||||
//@description Describes a notification sound in MP3 format
|
||||
//@id Unique identifier of the notification sound
|
||||
//@duration Duration of the sound, in seconds
|
||||
//@date Point in time (Unix timestamp) when the sound was created
|
||||
//@title Title of the notification sound
|
||||
//@data Arbitrary data, defined while the sound was uploaded
|
||||
//@sound File containing the sound
|
||||
notificationSound id:int64 duration:int32 title:string data:string sound:file = NotificationSound;
|
||||
notificationSound id:int64 duration:int32 date:int32 title:string data:string sound:file = NotificationSound;
|
||||
|
||||
//@description Contains a list of notification sounds @notification_sounds A list of notification sounds
|
||||
notificationSounds notification_sounds:vector<notificationSound> = NotificationSounds;
|
||||
|
@ -58,8 +58,8 @@ td_api::object_ptr<td_api::notificationSound> AudiosManager::get_notification_so
|
||||
CHECK(file_view.get_type() == FileType::Ringtone);
|
||||
CHECK(file_view.has_remote_location());
|
||||
auto document_id = file_view.remote_location().get_id();
|
||||
return td_api::make_object<td_api::notificationSound>(document_id, audio->duration, audio->title, audio->performer,
|
||||
td_->file_manager_->get_file_object(file_id));
|
||||
return td_api::make_object<td_api::notificationSound>(document_id, audio->duration, audio->date, audio->title,
|
||||
audio->performer, td_->file_manager_->get_file_object(file_id));
|
||||
}
|
||||
|
||||
FileId AudiosManager::on_get_audio(unique_ptr<Audio> new_audio, bool replace) {
|
||||
@ -85,6 +85,9 @@ FileId AudiosManager::on_get_audio(unique_ptr<Audio> new_audio, bool replace) {
|
||||
LOG(DEBUG) << "Audio " << file_id << " file name has changed";
|
||||
a->file_name = std::move(new_audio->file_name);
|
||||
}
|
||||
if (a->date != new_audio->date) {
|
||||
a->date = new_audio->date;
|
||||
}
|
||||
if (a->minithumbnail != new_audio->minithumbnail) {
|
||||
a->minithumbnail = std::move(new_audio->minithumbnail);
|
||||
}
|
||||
@ -177,7 +180,8 @@ void AudiosManager::delete_audio_thumbnail(FileId file_id) {
|
||||
}
|
||||
|
||||
void AudiosManager::create_audio(FileId file_id, string minithumbnail, PhotoSize thumbnail, string file_name,
|
||||
string mime_type, int32 duration, string title, string performer, bool replace) {
|
||||
string mime_type, int32 duration, string title, string performer, int32 date,
|
||||
bool replace) {
|
||||
auto a = make_unique<Audio>();
|
||||
a->file_id = file_id;
|
||||
a->file_name = std::move(file_name);
|
||||
@ -185,6 +189,7 @@ void AudiosManager::create_audio(FileId file_id, string minithumbnail, PhotoSize
|
||||
a->duration = max(duration, 0);
|
||||
a->title = std::move(title);
|
||||
a->performer = std::move(performer);
|
||||
a->date = date;
|
||||
if (!td_->auth_manager_->is_bot()) {
|
||||
a->minithumbnail = std::move(minithumbnail);
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ class AudiosManager {
|
||||
td_api::object_ptr<td_api::notificationSound> get_notification_sound_object(FileId file_id) const;
|
||||
|
||||
void create_audio(FileId file_id, string minithumbnail, PhotoSize thumbnail, string file_name, string mime_type,
|
||||
int32 duration, string title, string performer, bool replace);
|
||||
int32 duration, string title, string performer, int32 date, bool replace);
|
||||
|
||||
tl_object_ptr<telegram_api::InputMedia> get_input_media(FileId file_id,
|
||||
tl_object_ptr<telegram_api::InputFile> input_file,
|
||||
@ -63,6 +63,7 @@ class AudiosManager {
|
||||
string file_name;
|
||||
string mime_type;
|
||||
int32 duration = 0;
|
||||
int32 date = 0;
|
||||
string title;
|
||||
string performer;
|
||||
string minithumbnail;
|
||||
|
@ -22,28 +22,107 @@ void AudiosManager::store_audio(FileId file_id, StorerT &storer) const {
|
||||
auto it = audios_.find(file_id);
|
||||
CHECK(it != audios_.end());
|
||||
const Audio *audio = it->second.get();
|
||||
store(audio->file_name, storer);
|
||||
store(audio->mime_type, storer);
|
||||
store(audio->duration, storer);
|
||||
store(audio->title, storer);
|
||||
store(audio->performer, storer);
|
||||
store(audio->minithumbnail, storer);
|
||||
store(audio->thumbnail, storer);
|
||||
bool has_file_name = !audio->file_name.empty();
|
||||
bool has_mime_type = !audio->mime_type.empty();
|
||||
bool has_duration = audio->duration != 0;
|
||||
bool has_title = !audio->title.empty();
|
||||
bool has_performer = !audio->performer.empty();
|
||||
bool has_minithumbnail = !audio->minithumbnail.empty();
|
||||
bool has_thumbnail = audio->thumbnail.file_id.is_valid();
|
||||
bool has_date = audio->date != 0;
|
||||
BEGIN_STORE_FLAGS();
|
||||
STORE_FLAG(has_file_name);
|
||||
STORE_FLAG(has_mime_type);
|
||||
STORE_FLAG(has_duration);
|
||||
STORE_FLAG(has_title);
|
||||
STORE_FLAG(has_performer);
|
||||
STORE_FLAG(has_minithumbnail);
|
||||
STORE_FLAG(has_thumbnail);
|
||||
STORE_FLAG(has_date);
|
||||
END_STORE_FLAGS();
|
||||
if (has_file_name) {
|
||||
store(audio->file_name, storer);
|
||||
}
|
||||
if (has_mime_type) {
|
||||
store(audio->mime_type, storer);
|
||||
}
|
||||
if (has_duration) {
|
||||
store(audio->duration, storer);
|
||||
}
|
||||
if (has_title) {
|
||||
store(audio->title, storer);
|
||||
}
|
||||
if (has_performer) {
|
||||
store(audio->performer, storer);
|
||||
}
|
||||
if (has_minithumbnail) {
|
||||
store(audio->minithumbnail, storer);
|
||||
}
|
||||
if (has_thumbnail) {
|
||||
store(audio->thumbnail, storer);
|
||||
}
|
||||
if (has_date) {
|
||||
store(audio->date, storer);
|
||||
}
|
||||
store(file_id, storer);
|
||||
}
|
||||
|
||||
template <class ParserT>
|
||||
FileId AudiosManager::parse_audio(ParserT &parser) {
|
||||
auto audio = make_unique<Audio>();
|
||||
parse(audio->file_name, parser);
|
||||
parse(audio->mime_type, parser);
|
||||
parse(audio->duration, parser);
|
||||
parse(audio->title, parser);
|
||||
parse(audio->performer, parser);
|
||||
if (parser.version() >= static_cast<int32>(Version::SupportMinithumbnails)) {
|
||||
bool has_file_name;
|
||||
bool has_mime_type;
|
||||
bool has_duration;
|
||||
bool has_title;
|
||||
bool has_performer;
|
||||
bool has_minithumbnail;
|
||||
bool has_thumbnail;
|
||||
bool has_date;
|
||||
if (parser.version() >= static_cast<int32>(Version::AddAudioFlags)) {
|
||||
BEGIN_PARSE_FLAGS();
|
||||
PARSE_FLAG(has_file_name);
|
||||
PARSE_FLAG(has_mime_type);
|
||||
PARSE_FLAG(has_duration);
|
||||
PARSE_FLAG(has_title);
|
||||
PARSE_FLAG(has_performer);
|
||||
PARSE_FLAG(has_minithumbnail);
|
||||
PARSE_FLAG(has_thumbnail);
|
||||
PARSE_FLAG(has_date);
|
||||
END_PARSE_FLAGS();
|
||||
} else {
|
||||
has_file_name = true;
|
||||
has_mime_type = true;
|
||||
has_duration = true;
|
||||
has_title = true;
|
||||
has_performer = true;
|
||||
has_minithumbnail = parser.version() >= static_cast<int32>(Version::SupportMinithumbnails);
|
||||
has_thumbnail = true;
|
||||
has_date = false;
|
||||
}
|
||||
if (has_file_name) {
|
||||
parse(audio->file_name, parser);
|
||||
}
|
||||
if (has_mime_type) {
|
||||
parse(audio->mime_type, parser);
|
||||
}
|
||||
if (has_duration) {
|
||||
parse(audio->duration, parser);
|
||||
}
|
||||
if (has_title) {
|
||||
parse(audio->title, parser);
|
||||
}
|
||||
if (has_performer) {
|
||||
parse(audio->performer, parser);
|
||||
}
|
||||
if (has_minithumbnail) {
|
||||
parse(audio->minithumbnail, parser);
|
||||
}
|
||||
parse(audio->thumbnail, parser);
|
||||
if (has_thumbnail) {
|
||||
parse(audio->thumbnail, parser);
|
||||
}
|
||||
if (has_date) {
|
||||
parse(audio->date, parser);
|
||||
}
|
||||
parse(audio->file_id, parser);
|
||||
if (parser.get_error() != nullptr || !audio->file_id.is_valid()) {
|
||||
return FileId();
|
||||
|
@ -238,6 +238,7 @@ Document DocumentsManager::on_get_document(RemoteDocument remote_document, Dialo
|
||||
int64 access_hash;
|
||||
int32 dc_id;
|
||||
int32 size;
|
||||
int32 date = 0;
|
||||
string mime_type;
|
||||
string file_reference;
|
||||
string minithumbnail;
|
||||
@ -272,6 +273,9 @@ Document DocumentsManager::on_get_document(RemoteDocument remote_document, Dialo
|
||||
access_hash = document->access_hash_;
|
||||
dc_id = document->dc_id_;
|
||||
size = document->size_;
|
||||
if (is_ringtone) {
|
||||
date = document->date_;
|
||||
}
|
||||
mime_type = std::move(document->mime_type_);
|
||||
file_reference = document->file_reference_.as_slice().str();
|
||||
|
||||
@ -461,7 +465,7 @@ Document DocumentsManager::on_get_document(RemoteDocument remote_document, Dialo
|
||||
performer = std::move(audio->performer_);
|
||||
}
|
||||
td_->audios_manager_->create_audio(file_id, std::move(minithumbnail), std::move(thumbnail), std::move(file_name),
|
||||
std::move(mime_type), duration, std::move(title), std::move(performer),
|
||||
std::move(mime_type), duration, std::move(title), std::move(performer), date,
|
||||
!is_web);
|
||||
break;
|
||||
}
|
||||
|
@ -1740,7 +1740,7 @@ static Result<InputMessageContent> create_input_message_content(
|
||||
|
||||
td->audios_manager_->create_audio(file_id, string(), thumbnail, std::move(file_name), std::move(mime_type),
|
||||
input_audio->duration_, std::move(input_audio->title_),
|
||||
std::move(input_audio->performer_), false);
|
||||
std::move(input_audio->performer_), 0, false);
|
||||
|
||||
content = make_unique<MessageAudio>(file_id, std::move(caption));
|
||||
break;
|
||||
|
@ -49,6 +49,7 @@ enum class Version : int32 {
|
||||
Support64BitIds,
|
||||
AddInviteLinksRequiringApproval,
|
||||
AddKeyboardButtonFlags, // 35
|
||||
AddAudioFlags,
|
||||
Next
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user