mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Allow sending one-time round videos.
This commit is contained in:
parent
302e9371c8
commit
c010ecfe38
3 changed files with 28 additions and 24 deletions
|
@ -456,6 +456,7 @@ void SendConfirmedFile(
|
||||||
not_null<Main::Session*> session,
|
not_null<Main::Session*> session,
|
||||||
const std::shared_ptr<FilePrepareResult> &file) {
|
const std::shared_ptr<FilePrepareResult> &file) {
|
||||||
const auto isEditing = (file->type != SendMediaType::Audio)
|
const auto isEditing = (file->type != SendMediaType::Audio)
|
||||||
|
&& (file->type != SendMediaType::Round)
|
||||||
&& (file->to.replaceMediaOf != 0);
|
&& (file->to.replaceMediaOf != 0);
|
||||||
const auto newId = FullMsgId(
|
const auto newId = FullMsgId(
|
||||||
file->to.peer,
|
file->to.peer,
|
||||||
|
@ -525,7 +526,8 @@ void SendConfirmedFile(
|
||||||
// Shortcut messages have no 'edited' badge.
|
// Shortcut messages have no 'edited' badge.
|
||||||
flags |= MessageFlag::HideEdited;
|
flags |= MessageFlag::HideEdited;
|
||||||
}
|
}
|
||||||
if (file->type == SendMediaType::Audio) {
|
if (file->type == SendMediaType::Audio
|
||||||
|
|| file->type == SendMediaType::Round) {
|
||||||
if (!peer->isChannel() || peer->isMegagroup()) {
|
if (!peer->isChannel() || peer->isMegagroup()) {
|
||||||
flags |= MessageFlag::MediaIsUnread;
|
flags |= MessageFlag::MediaIsUnread;
|
||||||
}
|
}
|
||||||
|
@ -551,29 +553,25 @@ void SendConfirmedFile(
|
||||||
MTPint());
|
MTPint());
|
||||||
} else if (file->type == SendMediaType::Audio) {
|
} else if (file->type == SendMediaType::Audio) {
|
||||||
const auto ttlSeconds = file->to.options.ttlSeconds;
|
const auto ttlSeconds = file->to.options.ttlSeconds;
|
||||||
const auto isVoice = [&] {
|
|
||||||
return file->document.match([](const MTPDdocumentEmpty &d) {
|
|
||||||
return false;
|
|
||||||
}, [](const MTPDdocument &d) {
|
|
||||||
return ranges::any_of(d.vattributes().v, [&](
|
|
||||||
const MTPDocumentAttribute &attribute) {
|
|
||||||
using Att = MTPDdocumentAttributeAudio;
|
|
||||||
return attribute.match([](const Att &data) -> bool {
|
|
||||||
return data.vflags().v & Att::Flag::f_voice;
|
|
||||||
}, [](const auto &) {
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}();
|
|
||||||
using Flag = MTPDmessageMediaDocument::Flag;
|
using Flag = MTPDmessageMediaDocument::Flag;
|
||||||
return MTP_messageMediaDocument(
|
return MTP_messageMediaDocument(
|
||||||
MTP_flags(Flag::f_document
|
MTP_flags(Flag::f_document
|
||||||
| (isVoice ? Flag::f_voice : Flag())
|
| Flag::f_voice
|
||||||
| (ttlSeconds ? Flag::f_ttl_seconds : Flag())),
|
| (ttlSeconds ? Flag::f_ttl_seconds : Flag())),
|
||||||
file->document,
|
file->document,
|
||||||
MTPVector<MTPDocument>(), // alt_documents
|
MTPVector<MTPDocument>(), // alt_documents
|
||||||
MTP_int(ttlSeconds));
|
MTP_int(ttlSeconds));
|
||||||
|
} else if (file->type == SendMediaType::Round) {
|
||||||
|
using Flag = MTPDmessageMediaDocument::Flag;
|
||||||
|
const auto ttlSeconds = file->to.options.ttlSeconds;
|
||||||
|
return MTP_messageMediaDocument(
|
||||||
|
MTP_flags(Flag::f_document
|
||||||
|
| Flag::f_round
|
||||||
|
| (ttlSeconds ? Flag::f_ttl_seconds : Flag())
|
||||||
|
| (file->spoiler ? Flag::f_spoiler : Flag())),
|
||||||
|
file->document,
|
||||||
|
MTPVector<MTPDocument>(), // alt_documents
|
||||||
|
MTP_int(ttlSeconds));
|
||||||
} else {
|
} else {
|
||||||
Unexpected("Type in sendFilesConfirmed.");
|
Unexpected("Type in sendFilesConfirmed.");
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,7 +124,8 @@ Uploader::Entry::Entry(
|
||||||
: file->thumbId) {
|
: file->thumbId) {
|
||||||
if (file->type == SendMediaType::File
|
if (file->type == SendMediaType::File
|
||||||
|| file->type == SendMediaType::ThemeFile
|
|| file->type == SendMediaType::ThemeFile
|
||||||
|| file->type == SendMediaType::Audio) {
|
|| file->type == SendMediaType::Audio
|
||||||
|
|| file->type == SendMediaType::Round) {
|
||||||
setDocSize(file->filesize);
|
setDocSize(file->filesize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -294,7 +295,8 @@ void Uploader::upload(
|
||||||
file->partssize);
|
file->partssize);
|
||||||
} else if (file->type == SendMediaType::File
|
} else if (file->type == SendMediaType::File
|
||||||
|| file->type == SendMediaType::ThemeFile
|
|| file->type == SendMediaType::ThemeFile
|
||||||
|| file->type == SendMediaType::Audio) {
|
|| file->type == SendMediaType::Audio
|
||||||
|
|| file->type == SendMediaType::Round) {
|
||||||
const auto document = file->thumb.isNull()
|
const auto document = file->thumb.isNull()
|
||||||
? session().data().processDocument(file->document)
|
? session().data().processDocument(file->document)
|
||||||
: session().data().processDocument(
|
: session().data().processDocument(
|
||||||
|
@ -356,7 +358,8 @@ void Uploader::notifyFailed(const Entry &entry) {
|
||||||
_photoFailed.fire_copy(entry.itemId);
|
_photoFailed.fire_copy(entry.itemId);
|
||||||
} else if (type == SendMediaType::File
|
} else if (type == SendMediaType::File
|
||||||
|| type == SendMediaType::ThemeFile
|
|| type == SendMediaType::ThemeFile
|
||||||
|| type == SendMediaType::Audio) {
|
|| type == SendMediaType::Audio
|
||||||
|
|| type == SendMediaType::Round) {
|
||||||
const auto document = session().data().document(entry.file->id);
|
const auto document = session().data().document(entry.file->id);
|
||||||
if (document->uploading()) {
|
if (document->uploading()) {
|
||||||
document->status = FileUploadFailed;
|
document->status = FileUploadFailed;
|
||||||
|
@ -385,7 +388,8 @@ QByteArray Uploader::readDocPart(not_null<Entry*> entry) {
|
||||||
const auto checked = [&](QByteArray result) {
|
const auto checked = [&](QByteArray result) {
|
||||||
if ((entry->file->type == SendMediaType::File
|
if ((entry->file->type == SendMediaType::File
|
||||||
|| entry->file->type == SendMediaType::ThemeFile
|
|| entry->file->type == SendMediaType::ThemeFile
|
||||||
|| entry->file->type == SendMediaType::Audio)
|
|| entry->file->type == SendMediaType::Audio
|
||||||
|
|| entry->file->type == SendMediaType::Round)
|
||||||
&& entry->docSize <= kUseBigFilesFrom) {
|
&& entry->docSize <= kUseBigFilesFrom) {
|
||||||
entry->md5Hash.feed(result.data(), result.size());
|
entry->md5Hash.feed(result.data(), result.size());
|
||||||
}
|
}
|
||||||
|
@ -756,7 +760,8 @@ void Uploader::partLoaded(const MTPBool &result, mtpRequestId requestId) {
|
||||||
_photoProgress.fire_copy(itemId);
|
_photoProgress.fire_copy(itemId);
|
||||||
} else if (entry.file->type == SendMediaType::File
|
} else if (entry.file->type == SendMediaType::File
|
||||||
|| entry.file->type == SendMediaType::ThemeFile
|
|| entry.file->type == SendMediaType::ThemeFile
|
||||||
|| entry.file->type == SendMediaType::Audio) {
|
|| entry.file->type == SendMediaType::Audio
|
||||||
|
|| entry.file->type == SendMediaType::Round) {
|
||||||
const auto document = session().data().document(entry.file->id);
|
const auto document = session().data().document(entry.file->id);
|
||||||
if (document->uploading()) {
|
if (document->uploading()) {
|
||||||
document->uploadingData->offset = std::min(
|
document->uploadingData->offset = std::min(
|
||||||
|
@ -856,7 +861,8 @@ void Uploader::finishFront() {
|
||||||
});
|
});
|
||||||
} else if (entry.file->type == SendMediaType::File
|
} else if (entry.file->type == SendMediaType::File
|
||||||
|| entry.file->type == SendMediaType::ThemeFile
|
|| entry.file->type == SendMediaType::ThemeFile
|
||||||
|| entry.file->type == SendMediaType::Audio) {
|
|| entry.file->type == SendMediaType::Audio
|
||||||
|
|| entry.file->type == SendMediaType::Round) {
|
||||||
QByteArray docMd5(32, Qt::Uninitialized);
|
QByteArray docMd5(32, Qt::Uninitialized);
|
||||||
hashMd5Hex(entry.md5Hash.result(), docMd5.data());
|
hashMd5Hex(entry.md5Hash.result(), docMd5.data());
|
||||||
|
|
||||||
|
|
|
@ -1014,7 +1014,7 @@ void FileLoadTask::process(Args &&args) {
|
||||||
MTPVector<MTPVideoSize>(),
|
MTPVector<MTPVideoSize>(),
|
||||||
MTP_int(_dcId),
|
MTP_int(_dcId),
|
||||||
MTP_vector<MTPDocumentAttribute>(attributes));
|
MTP_vector<MTPDocumentAttribute>(attributes));
|
||||||
_type = SendMediaType::File;
|
_type = isRound ? SendMediaType::Round : SendMediaType::File;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_information) {
|
if (_information) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue