| 657 | } |
| 658 | |
| 659 | void FileLoadTask::process(ProcessArgs &&args) { |
| 660 | _result = MakePreparedFile({ |
| 661 | .taskId = id(), |
| 662 | .id = _id, |
| 663 | .to = _to, |
| 664 | .caption = _caption, |
| 665 | .spoiler = _spoiler, |
| 666 | .album = _album, |
| 667 | }); |
| 668 | if (const auto cover = _videoCover.get()) { |
| 669 | cover->process(); |
| 670 | if (const auto &result = cover->peekResult()) { |
| 671 | if (result->type == SendMediaType::Photo |
| 672 | && !result->fileparts.empty()) { |
| 673 | _result->videoCover = result; |
| 674 | } |
| 675 | } |
| 676 | } |
| 677 | |
| 678 | QString filename, filemime; |
| 679 | qint64 filesize = 0; |
| 680 | QByteArray filedata; |
| 681 | |
| 682 | auto isAnimation = false; |
| 683 | auto isSong = false; |
| 684 | auto isVideo = false; |
| 685 | auto isVoice = (_type == SendMediaType::Audio); |
| 686 | auto isRound = (_type == SendMediaType::Round); |
| 687 | auto isSticker = false; |
| 688 | |
| 689 | auto fullimage = QImage(); |
| 690 | auto fullimagebytes = QByteArray(); |
| 691 | auto fullimageformat = QByteArray(); |
| 692 | auto info = _filepath.isEmpty() ? QFileInfo() : QFileInfo(_filepath); |
| 693 | if (info.exists()) { |
| 694 | if (info.isDir()) { |
| 695 | _result->filesize = -1; |
| 696 | return; |
| 697 | } |
| 698 | |
| 699 | // Voice sending is supported only from memory for now. |
| 700 | // Because for voice we force mime type and don't read MediaInformation. |
| 701 | // For a real file we always read mime type and read MediaInformation. |
| 702 | Assert(!isVoice && !isRound); |
| 703 | |
| 704 | filesize = info.size(); |
| 705 | filename = info.fileName(); |
| 706 | if (!_information) { |
| 707 | _information = readMediaInformation(Core::MimeTypeForFile(info).name()); |
| 708 | } |
| 709 | filemime = _information->filemime; |
| 710 | if (auto image = std::get_if<Ui::PreparedFileInformation::Image>( |
| 711 | &_information->media)) { |
| 712 | fullimage = base::take(image->data); |
| 713 | fullimagebytes = base::take(image->bytes); |
| 714 | fullimageformat = base::take(image->format); |
| 715 | if (!Core::IsMimeSticker(filemime) |
| 716 | && fullimageformat != u"jpeg"_q) { |
no test coverage detected