Add fileTypeNotificationSound.
This commit is contained in:
parent
c359710cf6
commit
3378131467
@ -3475,6 +3475,9 @@ fileTypeAudio = FileType;
|
||||
//@description The file is a document
|
||||
fileTypeDocument = FileType;
|
||||
|
||||
//@description The file is a notification sound
|
||||
fileTypeNotificationSound = FileType;
|
||||
|
||||
//@description The file is a photo
|
||||
fileTypePhoto = FileType;
|
||||
|
||||
|
@ -65,7 +65,8 @@ tl_object_ptr<td_api::document> DocumentsManager::get_document_object(FileId fil
|
||||
|
||||
Document DocumentsManager::on_get_document(RemoteDocument remote_document, DialogId owner_dialog_id,
|
||||
MultiPromiseActor *load_data_multipromise_ptr,
|
||||
Document::Type default_document_type, bool is_background, bool is_pattern) {
|
||||
Document::Type default_document_type, bool is_background, bool is_pattern,
|
||||
bool is_ringtone) {
|
||||
tl_object_ptr<telegram_api::documentAttributeAnimated> animated;
|
||||
tl_object_ptr<telegram_api::documentAttributeVideo> video;
|
||||
tl_object_ptr<telegram_api::documentAttributeAudio> audio;
|
||||
@ -224,6 +225,15 @@ Document DocumentsManager::on_get_document(RemoteDocument remote_document, Dialo
|
||||
}
|
||||
}
|
||||
|
||||
if (is_ringtone) {
|
||||
if (document_type != Document::Type::Audio) {
|
||||
LOG(ERROR) << "Receive notification tone of type " << document_type;
|
||||
document_type = Document::Type::Audio;
|
||||
}
|
||||
file_type = FileType::Ringtone;
|
||||
default_extension = Slice("mp3");
|
||||
}
|
||||
|
||||
int64 id;
|
||||
int64 access_hash;
|
||||
int32 dc_id;
|
||||
|
@ -80,7 +80,7 @@ class DocumentsManager {
|
||||
Document on_get_document(RemoteDocument remote_document, DialogId owner_dialog_id,
|
||||
MultiPromiseActor *load_data_multipromise_ptr = nullptr,
|
||||
Document::Type default_document_type = Document::Type::General, bool is_background = false,
|
||||
bool is_pattern = false);
|
||||
bool is_pattern = false, bool is_ringtone = false);
|
||||
|
||||
void create_document(FileId file_id, string minithumbnail, PhotoSize thumbnail, string file_name, string mime_type,
|
||||
bool replace);
|
||||
|
@ -7,6 +7,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "td/telegram/DialogId.h"
|
||||
#include "td/telegram/files/FileId.h"
|
||||
#include "td/telegram/NotificationSettings.h"
|
||||
#include "td/telegram/td_api.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
|
@ -45,6 +45,7 @@ void FileGcWorker::run_gc(const FileGcParameters ¶meters, std::vector<FullFi
|
||||
immune_types[narrow_cast<size_t>(FileType::Thumbnail)] = true;
|
||||
immune_types[narrow_cast<size_t>(FileType::Wallpaper)] = true;
|
||||
immune_types[narrow_cast<size_t>(FileType::Background)] = true;
|
||||
immune_types[narrow_cast<size_t>(FileType::Ringtone)] = true;
|
||||
}
|
||||
|
||||
if (!parameters.file_types_.empty()) {
|
||||
|
@ -211,6 +211,7 @@ class FullRemoteFileLocation {
|
||||
case FileType::Secure:
|
||||
case FileType::Background:
|
||||
case FileType::DocumentAsFile:
|
||||
case FileType::Ringtone:
|
||||
return LocationType::Common;
|
||||
case FileType::None:
|
||||
case FileType::Size:
|
||||
|
@ -305,6 +305,7 @@ void FullRemoteFileLocation::AsUnique::store(StorerT &storer) const {
|
||||
case FileType::VideoNote:
|
||||
case FileType::Background:
|
||||
case FileType::DocumentAsFile:
|
||||
case FileType::Ringtone:
|
||||
return 2;
|
||||
case FileType::SecureRaw:
|
||||
case FileType::Secure:
|
||||
|
@ -913,6 +913,11 @@ string FileManager::get_file_name(FileType file_type, Slice path) {
|
||||
return fix_file_extension(file_name, "sticker", "webp");
|
||||
}
|
||||
break;
|
||||
case FileType::Ringtone:
|
||||
if (extension != "ogg" && extension != "oga" && extension != "mp3" && extension != "mpeg3") {
|
||||
return fix_file_extension(file_name, "notification_tone", "mp3");
|
||||
}
|
||||
break;
|
||||
case FileType::Document:
|
||||
case FileType::Animation:
|
||||
case FileType::Encrypted:
|
||||
@ -2880,7 +2885,8 @@ void FileManager::cancel_upload(FileId file_id) {
|
||||
|
||||
static bool is_document_type(FileType type) {
|
||||
return type == FileType::Document || type == FileType::Sticker || type == FileType::Audio ||
|
||||
type == FileType::Animation || type == FileType::Background || type == FileType::DocumentAsFile;
|
||||
type == FileType::Animation || type == FileType::Background || type == FileType::DocumentAsFile ||
|
||||
type == FileType::Ringtone;
|
||||
}
|
||||
|
||||
static bool is_background_type(FileType type) {
|
||||
|
@ -40,6 +40,8 @@ FileType get_file_type(const td_api::FileType &file_type) {
|
||||
return FileType::VideoNote;
|
||||
case td_api::fileTypeSecure::ID:
|
||||
return FileType::Secure;
|
||||
case td_api::fileTypeNotificationSound::ID:
|
||||
return FileType::Ringtone;
|
||||
case td_api::fileTypeNone::ID:
|
||||
return FileType::None;
|
||||
default:
|
||||
@ -87,6 +89,8 @@ tl_object_ptr<td_api::FileType> get_file_type_object(FileType file_type) {
|
||||
return make_tl_object<td_api::fileTypeWallpaper>();
|
||||
case FileType::DocumentAsFile:
|
||||
return make_tl_object<td_api::fileTypeDocument>();
|
||||
case FileType::Ringtone:
|
||||
return make_tl_object<td_api::fileTypeNotificationSound>();
|
||||
case FileType::None:
|
||||
return make_tl_object<td_api::fileTypeNone>();
|
||||
default:
|
||||
@ -146,6 +150,8 @@ CSlice get_file_type_name(FileType file_type) {
|
||||
return CSlice("wallpapers");
|
||||
case FileType::DocumentAsFile:
|
||||
return CSlice("documents");
|
||||
case FileType::Ringtone:
|
||||
return CSlice("notification_sounds");
|
||||
case FileType::Size:
|
||||
case FileType::None:
|
||||
default:
|
||||
@ -170,6 +176,7 @@ FileDirType get_file_dir_type(FileType file_type) {
|
||||
case FileType::Secure:
|
||||
case FileType::SecureRaw:
|
||||
case FileType::Background:
|
||||
case FileType::Ringtone:
|
||||
return FileDirType::Secure;
|
||||
default:
|
||||
return FileDirType::Common;
|
||||
@ -183,6 +190,7 @@ bool is_file_big(FileType file_type, int64 expected_size) {
|
||||
case FileType::Photo:
|
||||
case FileType::EncryptedThumbnail:
|
||||
case FileType::VideoNote:
|
||||
case FileType::Ringtone:
|
||||
return false;
|
||||
default:
|
||||
break;
|
||||
|
@ -33,6 +33,7 @@ enum class FileType : int32 {
|
||||
Secure,
|
||||
Background,
|
||||
DocumentAsFile,
|
||||
Ringtone,
|
||||
Size,
|
||||
None
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user