2018-07-15 16:36:19 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
|
|
|
the official desktop application for the Telegram messaging service.
|
|
|
|
|
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|
|
|
*/
|
|
|
|
#include "data/data_file_origin.h"
|
|
|
|
|
|
|
|
namespace Data {
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
struct FileReferenceAccumulator {
|
|
|
|
template <typename Type>
|
|
|
|
void push(const MTPVector<Type> &data) {
|
|
|
|
for (const auto &item : data.v) {
|
|
|
|
push(item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void push(const MTPPhoto &data) {
|
|
|
|
data.match([&](const MTPDphoto &data) {
|
2019-03-22 14:19:43 +00:00
|
|
|
result.data.emplace(
|
2019-07-05 13:38:38 +00:00
|
|
|
PhotoFileLocationId{ data.vid().v },
|
|
|
|
data.vfile_reference().v);
|
2018-07-15 16:36:19 +00:00
|
|
|
}, [](const MTPDphotoEmpty &data) {
|
|
|
|
});
|
|
|
|
}
|
|
|
|
void push(const MTPDocument &data) {
|
|
|
|
data.match([&](const MTPDdocument &data) {
|
2019-01-04 11:09:48 +00:00
|
|
|
result.data.emplace(
|
2019-07-05 13:38:38 +00:00
|
|
|
DocumentFileLocationId{ data.vid().v },
|
|
|
|
data.vfile_reference().v);
|
2018-07-15 16:36:19 +00:00
|
|
|
}, [](const MTPDdocumentEmpty &data) {
|
|
|
|
});
|
|
|
|
}
|
2019-11-29 09:09:15 +00:00
|
|
|
void push(const MTPPage &data) {
|
|
|
|
data.match([&](const auto &data) {
|
|
|
|
push(data.vphotos());
|
|
|
|
push(data.vdocuments());
|
|
|
|
});
|
|
|
|
}
|
2019-01-16 18:03:04 +00:00
|
|
|
void push(const MTPWallPaper &data) {
|
|
|
|
data.match([&](const MTPDwallPaper &data) {
|
2019-07-05 13:38:38 +00:00
|
|
|
push(data.vdocument());
|
2019-12-29 11:41:10 +00:00
|
|
|
}, [&](const MTPDwallPaperNoFile &data) {
|
2019-01-16 18:03:04 +00:00
|
|
|
});
|
|
|
|
}
|
2019-09-09 08:51:07 +00:00
|
|
|
void push(const MTPTheme &data) {
|
|
|
|
data.match([&](const MTPDtheme &data) {
|
|
|
|
if (const auto document = data.vdocument()) {
|
|
|
|
push(*document);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2019-12-29 12:28:27 +00:00
|
|
|
void push(const MTPWebPageAttribute &data) {
|
|
|
|
data.match([&](const MTPDwebPageAttributeTheme &data) {
|
|
|
|
if (const auto documents = data.vdocuments()) {
|
|
|
|
push(*documents);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2018-07-15 16:36:19 +00:00
|
|
|
void push(const MTPWebPage &data) {
|
|
|
|
data.match([&](const MTPDwebPage &data) {
|
2019-07-05 13:38:38 +00:00
|
|
|
if (const auto document = data.vdocument()) {
|
|
|
|
push(*document);
|
2018-07-15 16:36:19 +00:00
|
|
|
}
|
2019-12-29 12:28:27 +00:00
|
|
|
if (const auto attributes = data.vattributes()) {
|
|
|
|
push(*attributes);
|
2019-09-09 11:56:05 +00:00
|
|
|
}
|
2019-07-05 13:38:38 +00:00
|
|
|
if (const auto photo = data.vphoto()) {
|
|
|
|
push(*photo);
|
2018-07-15 16:36:19 +00:00
|
|
|
}
|
2019-11-29 09:09:15 +00:00
|
|
|
if (const auto page = data.vcached_page()) {
|
|
|
|
push(*page);
|
|
|
|
}
|
2018-07-15 16:36:19 +00:00
|
|
|
}, [](const auto &data) {
|
|
|
|
});
|
|
|
|
}
|
|
|
|
void push(const MTPGame &data) {
|
|
|
|
data.match([&](const MTPDgame &data) {
|
2019-07-05 13:38:38 +00:00
|
|
|
if (const auto document = data.vdocument()) {
|
|
|
|
push(*document);
|
2018-07-15 16:36:19 +00:00
|
|
|
}
|
|
|
|
}, [](const auto &data) {
|
|
|
|
});
|
|
|
|
}
|
|
|
|
void push(const MTPMessageMedia &data) {
|
|
|
|
data.match([&](const MTPDmessageMediaPhoto &data) {
|
2019-07-05 13:38:38 +00:00
|
|
|
if (const auto photo = data.vphoto()) {
|
|
|
|
push(*photo);
|
2018-07-15 16:36:19 +00:00
|
|
|
}
|
|
|
|
}, [&](const MTPDmessageMediaDocument &data) {
|
2019-07-05 13:38:38 +00:00
|
|
|
if (const auto document = data.vdocument()) {
|
|
|
|
push(*document);
|
2018-07-15 16:36:19 +00:00
|
|
|
}
|
|
|
|
}, [&](const MTPDmessageMediaWebPage &data) {
|
2019-07-05 13:38:38 +00:00
|
|
|
push(data.vwebpage());
|
2018-07-15 16:36:19 +00:00
|
|
|
}, [&](const MTPDmessageMediaGame &data) {
|
2019-07-05 13:38:38 +00:00
|
|
|
push(data.vgame());
|
2018-07-15 16:36:19 +00:00
|
|
|
}, [](const auto &data) {
|
|
|
|
});
|
|
|
|
}
|
|
|
|
void push(const MTPMessage &data) {
|
|
|
|
data.match([&](const MTPDmessage &data) {
|
2019-07-05 13:38:38 +00:00
|
|
|
if (const auto media = data.vmedia()) {
|
|
|
|
push(*media);
|
2018-07-15 16:36:19 +00:00
|
|
|
}
|
|
|
|
}, [&](const MTPDmessageService &data) {
|
2019-07-05 13:38:38 +00:00
|
|
|
data.vaction().match(
|
2018-07-15 16:36:19 +00:00
|
|
|
[&](const MTPDmessageActionChatEditPhoto &data) {
|
2019-07-05 13:38:38 +00:00
|
|
|
push(data.vphoto());
|
2018-07-15 16:36:19 +00:00
|
|
|
}, [](const auto &data) {
|
|
|
|
});
|
|
|
|
}, [](const MTPDmessageEmpty &data) {
|
|
|
|
});
|
|
|
|
}
|
|
|
|
void push(const MTPmessages_Messages &data) {
|
|
|
|
data.match([](const MTPDmessages_messagesNotModified &) {
|
|
|
|
}, [&](const auto &data) {
|
2019-07-05 13:38:38 +00:00
|
|
|
push(data.vmessages());
|
2018-07-15 16:36:19 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
void push(const MTPphotos_Photos &data) {
|
|
|
|
data.match([&](const auto &data) {
|
2019-07-05 13:38:38 +00:00
|
|
|
push(data.vphotos());
|
2018-07-15 16:36:19 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
void push(const MTPmessages_RecentStickers &data) {
|
|
|
|
data.match([&](const MTPDmessages_recentStickers &data) {
|
2019-07-05 13:38:38 +00:00
|
|
|
push(data.vstickers());
|
2018-07-15 16:36:19 +00:00
|
|
|
}, [](const MTPDmessages_recentStickersNotModified &data) {
|
|
|
|
});
|
|
|
|
}
|
|
|
|
void push(const MTPmessages_FavedStickers &data) {
|
|
|
|
data.match([&](const MTPDmessages_favedStickers &data) {
|
2019-07-05 13:38:38 +00:00
|
|
|
push(data.vstickers());
|
2018-07-15 16:36:19 +00:00
|
|
|
}, [](const MTPDmessages_favedStickersNotModified &data) {
|
|
|
|
});
|
|
|
|
}
|
|
|
|
void push(const MTPmessages_StickerSet &data) {
|
|
|
|
data.match([&](const MTPDmessages_stickerSet &data) {
|
2019-07-05 13:38:38 +00:00
|
|
|
push(data.vdocuments());
|
2021-11-19 19:04:40 +00:00
|
|
|
}, [](const MTPDmessages_stickerSetNotModified &data) {
|
2018-07-15 16:36:19 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
void push(const MTPmessages_SavedGifs &data) {
|
|
|
|
data.match([&](const MTPDmessages_savedGifs &data) {
|
2019-07-05 13:38:38 +00:00
|
|
|
push(data.vgifs());
|
2018-07-15 16:36:19 +00:00
|
|
|
}, [](const MTPDmessages_savedGifsNotModified &data) {
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
UpdatedFileReferences result;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename Type>
|
|
|
|
UpdatedFileReferences GetFileReferencesHelper(const Type &data) {
|
|
|
|
FileReferenceAccumulator result;
|
|
|
|
result.push(data);
|
|
|
|
return result.result;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
UpdatedFileReferences GetFileReferences(const MTPmessages_Messages &data) {
|
|
|
|
return GetFileReferencesHelper(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
UpdatedFileReferences GetFileReferences(const MTPphotos_Photos &data) {
|
|
|
|
return GetFileReferencesHelper(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
UpdatedFileReferences GetFileReferences(
|
|
|
|
const MTPmessages_RecentStickers &data) {
|
|
|
|
return GetFileReferencesHelper(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
UpdatedFileReferences GetFileReferences(
|
|
|
|
const MTPmessages_FavedStickers &data) {
|
|
|
|
return GetFileReferencesHelper(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
UpdatedFileReferences GetFileReferences(
|
|
|
|
const MTPmessages_StickerSet &data) {
|
|
|
|
return GetFileReferencesHelper(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
UpdatedFileReferences GetFileReferences(const MTPmessages_SavedGifs &data) {
|
|
|
|
return GetFileReferencesHelper(data);
|
|
|
|
}
|
|
|
|
|
2019-01-17 08:18:23 +00:00
|
|
|
UpdatedFileReferences GetFileReferences(const MTPWallPaper &data) {
|
2019-01-16 18:03:04 +00:00
|
|
|
return GetFileReferencesHelper(data);
|
|
|
|
}
|
|
|
|
|
2019-09-09 08:51:07 +00:00
|
|
|
UpdatedFileReferences GetFileReferences(const MTPTheme &data) {
|
|
|
|
return GetFileReferencesHelper(data);
|
|
|
|
}
|
|
|
|
|
2018-07-15 16:36:19 +00:00
|
|
|
} // namespace Data
|