Commit 2333f783 authored by Sébastien Blin's avatar Sébastien Blin Committed by Andreas Traczyk
Browse files

conversation: automatically accepts < 20Mb files

and if contact is already added

Change-Id: Id1137832c5bba5f41f559db3d1c33071c9a496bf
parent b2ba93f7
......@@ -1989,11 +1989,16 @@ ConversationModelPimpl::slotTransferStatusAwaitingHost(long long dringId, datatr
auto extensionIdx = info.displayName.find_last_of(".");
if (extensionIdx == std::string::npos) return;
auto extension = info.displayName.substr(extensionIdx);
try {
auto contactInfo = linked.owner.contactModel->getContact(conversations[conversationIdx].participants.front());
// Only accept if contact is added
if (contactInfo.profileInfo.type != profile::Type::RING) return;
} catch (...) {
return;
}
std::transform(extension.begin(), extension.end(), extension.begin(), ::tolower);
auto fileExtensions = {".gif", ".jpg", ".jpeg", ".png", ".webp", ".ogg", ".mp3", ".wav", ".flac", ".webm", ".mp4", ".mkv"};
auto isAutoAccepted = std::find(fileExtensions.begin(), fileExtensions.end(), extension) != fileExtensions.end();
auto destinationDir = lrc.getDataTransferModel().downloadDirectory;
if (info.totalSize < 20 * 1024 * 1024 && isAutoAccepted && !destinationDir.empty()) {
if (info.totalSize < 20 * 1024 * 1024 && !destinationDir.empty()) {
auto wantedFilename = destinationDir + info.displayName;
auto duplicate = 0;
while (std::ifstream(wantedFilename).good()) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment