2018-07-13 21:25:47 +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
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2018-07-15 16:36:19 +00:00
|
|
|
#include "base/variant.h"
|
2018-07-13 21:25:47 +00:00
|
|
|
#include "data/data_types.h"
|
|
|
|
|
|
|
|
namespace Data {
|
|
|
|
|
|
|
|
using FileOriginMessage = FullMsgId;
|
2023-11-22 04:55:58 +00:00
|
|
|
using FileOriginStory = FullStoryId;
|
2018-07-13 21:25:47 +00:00
|
|
|
|
|
|
|
struct FileOriginUserPhoto {
|
|
|
|
FileOriginUserPhoto(UserId userId, PhotoId photoId)
|
|
|
|
: userId(userId)
|
|
|
|
, photoId(photoId) {
|
|
|
|
}
|
|
|
|
|
|
|
|
UserId userId = 0;
|
|
|
|
PhotoId photoId = 0;
|
2018-07-15 16:36:19 +00:00
|
|
|
|
|
|
|
inline bool operator<(const FileOriginUserPhoto &other) const {
|
|
|
|
return std::tie(userId, photoId)
|
|
|
|
< std::tie(other.userId, other.photoId);
|
|
|
|
}
|
2018-07-13 21:25:47 +00:00
|
|
|
};
|
|
|
|
|
2022-12-20 13:12:32 +00:00
|
|
|
struct FileOriginFullUser {
|
|
|
|
FileOriginFullUser(UserId userId)
|
|
|
|
: userId(userId) {
|
|
|
|
}
|
|
|
|
|
|
|
|
UserId userId = 0;
|
|
|
|
|
|
|
|
inline bool operator<(const FileOriginFullUser &other) const {
|
|
|
|
return userId < other.userId;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-07-13 21:25:47 +00:00
|
|
|
struct FileOriginPeerPhoto {
|
|
|
|
explicit FileOriginPeerPhoto(PeerId peerId) : peerId(peerId) {
|
|
|
|
}
|
|
|
|
|
|
|
|
PeerId peerId = 0;
|
2018-07-15 16:36:19 +00:00
|
|
|
|
|
|
|
inline bool operator<(const FileOriginPeerPhoto &other) const {
|
|
|
|
return peerId < other.peerId;
|
|
|
|
}
|
2018-07-13 21:25:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct FileOriginStickerSet {
|
|
|
|
FileOriginStickerSet(uint64 setId, uint64 accessHash)
|
|
|
|
: setId(setId)
|
|
|
|
, accessHash(accessHash) {
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64 setId = 0;
|
|
|
|
uint64 accessHash = 0;
|
2018-07-15 16:36:19 +00:00
|
|
|
|
|
|
|
inline bool operator<(const FileOriginStickerSet &other) const {
|
|
|
|
return setId < other.setId;
|
|
|
|
}
|
2018-07-13 21:25:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct FileOriginSavedGifs {
|
2018-07-15 16:36:19 +00:00
|
|
|
inline bool operator<(const FileOriginSavedGifs &) const {
|
|
|
|
return false;
|
|
|
|
}
|
2018-07-13 21:25:47 +00:00
|
|
|
};
|
|
|
|
|
2019-01-17 08:18:23 +00:00
|
|
|
struct FileOriginWallpaper {
|
2020-06-19 15:14:55 +00:00
|
|
|
FileOriginWallpaper(
|
|
|
|
uint64 paperId,
|
|
|
|
uint64 accessHash,
|
|
|
|
UserId ownerId,
|
|
|
|
const QString &slug)
|
2019-01-17 08:18:23 +00:00
|
|
|
: paperId(paperId)
|
2020-06-19 15:14:55 +00:00
|
|
|
, accessHash(accessHash)
|
|
|
|
, ownerId(ownerId)
|
|
|
|
, slug(slug) {
|
2019-01-17 08:18:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
uint64 paperId = 0;
|
|
|
|
uint64 accessHash = 0;
|
2020-06-19 15:14:55 +00:00
|
|
|
UserId ownerId = 0;
|
|
|
|
QString slug;
|
2019-01-17 08:18:23 +00:00
|
|
|
|
|
|
|
inline bool operator<(const FileOriginWallpaper &other) const {
|
|
|
|
return paperId < other.paperId;
|
2019-01-16 18:03:04 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-09-09 08:51:07 +00:00
|
|
|
struct FileOriginTheme {
|
|
|
|
FileOriginTheme(uint64 themeId, uint64 accessHash)
|
|
|
|
: themeId(themeId)
|
|
|
|
, accessHash(accessHash) {
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64 themeId = 0;
|
|
|
|
uint64 accessHash = 0;
|
|
|
|
|
|
|
|
inline bool operator<(const FileOriginTheme &other) const {
|
|
|
|
return themeId < other.themeId;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-04-05 12:26:18 +00:00
|
|
|
struct FileOriginRingtones {
|
|
|
|
inline bool operator<(const FileOriginRingtones &) const {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-06-10 08:03:47 +00:00
|
|
|
struct FileOriginPremiumPreviews {
|
|
|
|
inline bool operator<(const FileOriginPremiumPreviews &) const {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-01-04 11:09:48 +00:00
|
|
|
struct FileOrigin {
|
2020-08-31 09:04:17 +00:00
|
|
|
using Variant = std::variant<
|
|
|
|
v::null_t,
|
2019-01-04 11:09:48 +00:00
|
|
|
FileOriginMessage,
|
|
|
|
FileOriginUserPhoto,
|
2022-12-20 13:12:32 +00:00
|
|
|
FileOriginFullUser,
|
2019-01-04 11:09:48 +00:00
|
|
|
FileOriginPeerPhoto,
|
|
|
|
FileOriginStickerSet,
|
2019-01-16 18:03:04 +00:00
|
|
|
FileOriginSavedGifs,
|
2019-09-09 08:51:07 +00:00
|
|
|
FileOriginWallpaper,
|
2022-04-05 12:26:18 +00:00
|
|
|
FileOriginTheme,
|
2022-06-10 08:03:47 +00:00
|
|
|
FileOriginRingtones,
|
2023-05-26 08:45:50 +00:00
|
|
|
FileOriginPremiumPreviews,
|
|
|
|
FileOriginStory>;
|
2019-01-04 11:09:48 +00:00
|
|
|
|
|
|
|
FileOrigin() = default;
|
|
|
|
FileOrigin(FileOriginMessage data) : data(data) {
|
|
|
|
}
|
|
|
|
FileOrigin(FileOriginUserPhoto data) : data(data) {
|
|
|
|
}
|
2022-12-20 13:12:32 +00:00
|
|
|
FileOrigin(FileOriginFullUser data) : data(data) {
|
|
|
|
}
|
2019-01-04 11:09:48 +00:00
|
|
|
FileOrigin(FileOriginPeerPhoto data) : data(data) {
|
|
|
|
}
|
|
|
|
FileOrigin(FileOriginStickerSet data) : data(data) {
|
|
|
|
}
|
|
|
|
FileOrigin(FileOriginSavedGifs data) : data(data) {
|
|
|
|
}
|
2019-01-17 08:18:23 +00:00
|
|
|
FileOrigin(FileOriginWallpaper data) : data(data) {
|
2019-01-16 18:03:04 +00:00
|
|
|
}
|
2019-09-09 08:51:07 +00:00
|
|
|
FileOrigin(FileOriginTheme data) : data(data) {
|
|
|
|
}
|
2022-04-05 12:26:18 +00:00
|
|
|
FileOrigin(FileOriginRingtones data) : data(data) {
|
|
|
|
}
|
2022-06-10 08:03:47 +00:00
|
|
|
FileOrigin(FileOriginPremiumPreviews data) : data(data) {
|
|
|
|
}
|
2023-05-26 08:45:50 +00:00
|
|
|
FileOrigin(FileOriginStory data) : data(data) {
|
|
|
|
}
|
2019-01-04 11:09:48 +00:00
|
|
|
|
|
|
|
explicit operator bool() const {
|
2020-08-31 09:04:17 +00:00
|
|
|
return !v::is_null(data);
|
2019-01-04 11:09:48 +00:00
|
|
|
}
|
|
|
|
inline bool operator<(const FileOrigin &other) const {
|
|
|
|
return data < other.data;
|
|
|
|
}
|
|
|
|
|
|
|
|
Variant data;
|
|
|
|
};
|
2018-07-13 21:25:47 +00:00
|
|
|
|
2019-03-22 14:19:43 +00:00
|
|
|
struct DocumentFileLocationId {
|
|
|
|
uint64 id = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
inline bool operator<(DocumentFileLocationId a, DocumentFileLocationId b) {
|
|
|
|
return a.id < b.id;
|
|
|
|
}
|
2018-07-15 16:36:19 +00:00
|
|
|
|
2019-03-22 14:19:43 +00:00
|
|
|
struct PhotoFileLocationId {
|
|
|
|
uint64 id = 0;
|
2018-07-15 16:36:19 +00:00
|
|
|
};
|
|
|
|
|
2019-03-22 14:19:43 +00:00
|
|
|
inline bool operator<(PhotoFileLocationId a, PhotoFileLocationId b) {
|
|
|
|
return a.id < b.id;
|
|
|
|
}
|
2018-07-15 16:36:19 +00:00
|
|
|
|
2020-08-31 08:14:53 +00:00
|
|
|
using FileLocationId = std::variant<
|
2019-03-22 14:19:43 +00:00
|
|
|
DocumentFileLocationId,
|
|
|
|
PhotoFileLocationId>;
|
|
|
|
|
2019-01-04 11:09:48 +00:00
|
|
|
struct UpdatedFileReferences {
|
|
|
|
std::map<FileLocationId, QByteArray> data;
|
|
|
|
};
|
2018-07-15 16:36:19 +00:00
|
|
|
|
|
|
|
UpdatedFileReferences GetFileReferences(const MTPmessages_Messages &data);
|
|
|
|
UpdatedFileReferences GetFileReferences(const MTPphotos_Photos &data);
|
2022-12-20 13:12:32 +00:00
|
|
|
UpdatedFileReferences GetFileReferences(const MTPusers_UserFull &data);
|
2018-07-15 16:36:19 +00:00
|
|
|
UpdatedFileReferences GetFileReferences(
|
|
|
|
const MTPmessages_RecentStickers &data);
|
|
|
|
UpdatedFileReferences GetFileReferences(
|
|
|
|
const MTPmessages_FavedStickers &data);
|
|
|
|
UpdatedFileReferences GetFileReferences(const MTPmessages_StickerSet &data);
|
|
|
|
UpdatedFileReferences GetFileReferences(const MTPmessages_SavedGifs &data);
|
2019-01-17 08:18:23 +00:00
|
|
|
UpdatedFileReferences GetFileReferences(const MTPWallPaper &data);
|
2019-09-09 08:51:07 +00:00
|
|
|
UpdatedFileReferences GetFileReferences(const MTPTheme &data);
|
2022-04-05 14:08:07 +00:00
|
|
|
UpdatedFileReferences GetFileReferences(
|
|
|
|
const MTPaccount_SavedRingtones &data);
|
2022-06-10 08:03:47 +00:00
|
|
|
UpdatedFileReferences GetFileReferences(const MTPhelp_PremiumPromo &data);
|
2023-05-26 08:45:50 +00:00
|
|
|
UpdatedFileReferences GetFileReferences(const MTPstories_Stories &data);
|
2018-07-15 16:36:19 +00:00
|
|
|
|
2022-04-25 18:09:51 +00:00
|
|
|
// Admin Log Event.
|
|
|
|
UpdatedFileReferences GetFileReferences(const MTPMessageMedia &data);
|
|
|
|
|
2018-07-13 21:25:47 +00:00
|
|
|
} // namespace Data
|