2020-01-27 14:06:00 +01:00
|
|
|
//
|
2024-01-01 01:07:21 +01:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2024
|
2020-01-27 14:06:00 +01:00
|
|
|
//
|
|
|
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
|
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
//
|
|
|
|
#include "td/telegram/MessageContentType.h"
|
|
|
|
|
|
|
|
namespace td {
|
|
|
|
|
|
|
|
StringBuilder &operator<<(StringBuilder &string_builder, MessageContentType content_type) {
|
|
|
|
switch (content_type) {
|
|
|
|
case MessageContentType::None:
|
|
|
|
return string_builder << "None";
|
|
|
|
case MessageContentType::Animation:
|
|
|
|
return string_builder << "Animation";
|
|
|
|
case MessageContentType::Audio:
|
|
|
|
return string_builder << "Audio";
|
|
|
|
case MessageContentType::Document:
|
|
|
|
return string_builder << "Document";
|
|
|
|
case MessageContentType::ExpiredPhoto:
|
|
|
|
return string_builder << "ExpiredPhoto";
|
|
|
|
case MessageContentType::Photo:
|
|
|
|
return string_builder << "Photo";
|
|
|
|
case MessageContentType::ExpiredVideo:
|
|
|
|
return string_builder << "ExpiredVideo";
|
|
|
|
case MessageContentType::Video:
|
|
|
|
return string_builder << "Video";
|
|
|
|
case MessageContentType::VideoNote:
|
|
|
|
return string_builder << "VideoNote";
|
|
|
|
case MessageContentType::VoiceNote:
|
|
|
|
return string_builder << "VoiceNote";
|
|
|
|
case MessageContentType::Contact:
|
|
|
|
return string_builder << "Contact";
|
|
|
|
case MessageContentType::LiveLocation:
|
|
|
|
return string_builder << "LiveLocation";
|
|
|
|
case MessageContentType::Location:
|
|
|
|
return string_builder << "Location";
|
|
|
|
case MessageContentType::Venue:
|
|
|
|
return string_builder << "Venue";
|
|
|
|
case MessageContentType::Game:
|
|
|
|
return string_builder << "Game";
|
|
|
|
case MessageContentType::Invoice:
|
|
|
|
return string_builder << "Invoice";
|
|
|
|
case MessageContentType::Sticker:
|
|
|
|
return string_builder << "Sticker";
|
|
|
|
case MessageContentType::Text:
|
|
|
|
return string_builder << "Text";
|
|
|
|
case MessageContentType::Unsupported:
|
|
|
|
return string_builder << "Unsupported";
|
|
|
|
case MessageContentType::ChatCreate:
|
|
|
|
return string_builder << "ChatCreate";
|
|
|
|
case MessageContentType::ChatChangeTitle:
|
|
|
|
return string_builder << "ChatChangeTitle";
|
|
|
|
case MessageContentType::ChatChangePhoto:
|
|
|
|
return string_builder << "ChatChangePhoto";
|
|
|
|
case MessageContentType::ChatDeletePhoto:
|
|
|
|
return string_builder << "ChatDeletePhoto";
|
|
|
|
case MessageContentType::ChatDeleteHistory:
|
|
|
|
return string_builder << "ChatDeleteHistory";
|
|
|
|
case MessageContentType::ChatAddUsers:
|
|
|
|
return string_builder << "ChatAddUsers";
|
|
|
|
case MessageContentType::ChatJoinedByLink:
|
|
|
|
return string_builder << "ChatJoinedByLink";
|
|
|
|
case MessageContentType::ChatDeleteUser:
|
|
|
|
return string_builder << "ChatDeleteUser";
|
|
|
|
case MessageContentType::ChatMigrateTo:
|
|
|
|
return string_builder << "ChatMigrateTo";
|
|
|
|
case MessageContentType::ChannelCreate:
|
|
|
|
return string_builder << "ChannelCreate";
|
|
|
|
case MessageContentType::ChannelMigrateFrom:
|
|
|
|
return string_builder << "ChannelMigrateFrom";
|
|
|
|
case MessageContentType::PinMessage:
|
|
|
|
return string_builder << "PinMessage";
|
|
|
|
case MessageContentType::GameScore:
|
|
|
|
return string_builder << "GameScore";
|
|
|
|
case MessageContentType::ScreenshotTaken:
|
|
|
|
return string_builder << "ScreenshotTaken";
|
|
|
|
case MessageContentType::ChatSetTtl:
|
|
|
|
return string_builder << "ChatSetTtl";
|
|
|
|
case MessageContentType::Call:
|
|
|
|
return string_builder << "Call";
|
|
|
|
case MessageContentType::PaymentSuccessful:
|
|
|
|
return string_builder << "PaymentSuccessful";
|
|
|
|
case MessageContentType::ContactRegistered:
|
|
|
|
return string_builder << "ContactRegistered";
|
|
|
|
case MessageContentType::CustomServiceAction:
|
|
|
|
return string_builder << "CustomServiceAction";
|
|
|
|
case MessageContentType::WebsiteConnected:
|
|
|
|
return string_builder << "WebsiteConnected";
|
|
|
|
case MessageContentType::PassportDataSent:
|
|
|
|
return string_builder << "PassportDataSent";
|
|
|
|
case MessageContentType::PassportDataReceived:
|
|
|
|
return string_builder << "PassportDataReceived";
|
|
|
|
case MessageContentType::Poll:
|
|
|
|
return string_builder << "Poll";
|
2020-03-29 23:34:37 +02:00
|
|
|
case MessageContentType::Dice:
|
|
|
|
return string_builder << "Dice";
|
2020-10-29 20:25:58 +01:00
|
|
|
case MessageContentType::ProximityAlertTriggered:
|
|
|
|
return string_builder << "ProximityAlertTriggered";
|
2020-11-24 12:33:16 +01:00
|
|
|
case MessageContentType::GroupCall:
|
|
|
|
return string_builder << "GroupCall";
|
|
|
|
case MessageContentType::InviteToGroupCall:
|
|
|
|
return string_builder << "InviteToGroupCall";
|
2021-08-18 15:03:10 +02:00
|
|
|
case MessageContentType::ChatSetTheme:
|
|
|
|
return string_builder << "ChatSetTheme";
|
2022-03-28 09:01:39 +02:00
|
|
|
case MessageContentType::WebViewDataSent:
|
|
|
|
return string_builder << "WebViewDataSent";
|
|
|
|
case MessageContentType::WebViewDataReceived:
|
|
|
|
return string_builder << "WebViewDataReceived";
|
2022-07-01 14:28:22 +02:00
|
|
|
case MessageContentType::GiftPremium:
|
|
|
|
return string_builder << "GiftPremium";
|
2022-10-18 15:08:53 +02:00
|
|
|
case MessageContentType::TopicCreate:
|
|
|
|
return string_builder << "TopicCreate";
|
2022-10-18 21:16:03 +02:00
|
|
|
case MessageContentType::TopicEdit:
|
|
|
|
return string_builder << "TopicEdit";
|
2022-12-09 12:13:37 +01:00
|
|
|
case MessageContentType::SuggestProfilePhoto:
|
|
|
|
return string_builder << "SuggestProfilePhoto";
|
2022-12-14 19:13:48 +01:00
|
|
|
case MessageContentType::WriteAccessAllowed:
|
|
|
|
return string_builder << "WriteAccessAllowed";
|
2023-01-10 14:20:30 +01:00
|
|
|
case MessageContentType::RequestedDialog:
|
2023-02-22 10:24:43 +01:00
|
|
|
return string_builder << "ChatShared";
|
|
|
|
case MessageContentType::WebViewWriteAccessAllowed:
|
|
|
|
return string_builder << "WebAppWriteAccessAllowed";
|
2023-04-10 13:12:35 +02:00
|
|
|
case MessageContentType::SetBackground:
|
|
|
|
return string_builder << "SetBackground";
|
2023-06-12 18:23:58 +02:00
|
|
|
case MessageContentType::Story:
|
|
|
|
return string_builder << "Story";
|
2023-08-25 15:53:50 +02:00
|
|
|
case MessageContentType::WriteAccessAllowedByRequest:
|
|
|
|
return string_builder << "WriteAccessAllowedByRequest";
|
2023-09-29 16:55:03 +02:00
|
|
|
case MessageContentType::GiftCode:
|
|
|
|
return string_builder << "GiftCode";
|
2023-09-29 23:32:39 +02:00
|
|
|
case MessageContentType::Giveaway:
|
|
|
|
return string_builder << "Giveaway";
|
2023-10-16 10:31:11 +02:00
|
|
|
case MessageContentType::GiveawayLaunch:
|
|
|
|
return string_builder << "GiveawayLaunch";
|
2023-11-09 18:28:27 +01:00
|
|
|
case MessageContentType::GiveawayResults:
|
|
|
|
return string_builder << "GiveawayResults";
|
2023-12-18 19:03:11 +01:00
|
|
|
case MessageContentType::GiveawayWinners:
|
|
|
|
return string_builder << "GiveawayWinners";
|
2024-01-02 12:27:11 +01:00
|
|
|
case MessageContentType::ExpiredVideoNote:
|
|
|
|
return string_builder << "ExpiredVideoNote";
|
|
|
|
case MessageContentType::ExpiredVoiceNote:
|
|
|
|
return string_builder << "ExpiredVoiceNote";
|
2024-02-07 18:50:00 +01:00
|
|
|
case MessageContentType::BoostApply:
|
|
|
|
return string_builder << "BoostApply";
|
2024-03-21 22:43:18 +01:00
|
|
|
case MessageContentType::DialogShared:
|
|
|
|
return string_builder << "ChatShared";
|
2024-06-21 11:25:23 +02:00
|
|
|
case MessageContentType::PaidMedia:
|
|
|
|
return string_builder << "PaidMedia";
|
2020-01-27 14:06:00 +01:00
|
|
|
default:
|
2023-07-03 14:46:31 +02:00
|
|
|
return string_builder << "Invalid type " << static_cast<int32>(content_type);
|
2020-01-27 14:06:00 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-05-15 22:59:15 +02:00
|
|
|
bool is_allowed_invert_caption_message_content(MessageContentType content_type) {
|
|
|
|
switch (content_type) {
|
|
|
|
case MessageContentType::Animation:
|
|
|
|
case MessageContentType::Photo:
|
|
|
|
case MessageContentType::Video:
|
|
|
|
return true;
|
|
|
|
default:
|
2024-06-21 13:00:29 +02:00
|
|
|
return false;
|
2024-05-15 22:59:15 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-27 14:06:00 +01:00
|
|
|
bool is_allowed_media_group_content(MessageContentType content_type) {
|
|
|
|
switch (content_type) {
|
2020-10-15 17:13:54 +02:00
|
|
|
case MessageContentType::Audio:
|
|
|
|
case MessageContentType::Document:
|
2020-01-27 14:06:00 +01:00
|
|
|
case MessageContentType::Photo:
|
|
|
|
case MessageContentType::Video:
|
|
|
|
case MessageContentType::ExpiredPhoto:
|
|
|
|
case MessageContentType::ExpiredVideo:
|
|
|
|
return true;
|
|
|
|
case MessageContentType::Animation:
|
|
|
|
case MessageContentType::Contact:
|
|
|
|
case MessageContentType::Game:
|
|
|
|
case MessageContentType::Invoice:
|
|
|
|
case MessageContentType::LiveLocation:
|
|
|
|
case MessageContentType::Location:
|
|
|
|
case MessageContentType::Sticker:
|
|
|
|
case MessageContentType::Text:
|
|
|
|
case MessageContentType::Unsupported:
|
|
|
|
case MessageContentType::Venue:
|
|
|
|
case MessageContentType::VideoNote:
|
|
|
|
case MessageContentType::VoiceNote:
|
|
|
|
case MessageContentType::ChatCreate:
|
|
|
|
case MessageContentType::ChatChangeTitle:
|
|
|
|
case MessageContentType::ChatChangePhoto:
|
|
|
|
case MessageContentType::ChatDeletePhoto:
|
|
|
|
case MessageContentType::ChatDeleteHistory:
|
|
|
|
case MessageContentType::ChatAddUsers:
|
|
|
|
case MessageContentType::ChatJoinedByLink:
|
|
|
|
case MessageContentType::ChatDeleteUser:
|
|
|
|
case MessageContentType::ChatMigrateTo:
|
|
|
|
case MessageContentType::ChannelCreate:
|
|
|
|
case MessageContentType::ChannelMigrateFrom:
|
|
|
|
case MessageContentType::PinMessage:
|
|
|
|
case MessageContentType::GameScore:
|
|
|
|
case MessageContentType::ScreenshotTaken:
|
|
|
|
case MessageContentType::ChatSetTtl:
|
|
|
|
case MessageContentType::Call:
|
|
|
|
case MessageContentType::PaymentSuccessful:
|
|
|
|
case MessageContentType::ContactRegistered:
|
|
|
|
case MessageContentType::CustomServiceAction:
|
|
|
|
case MessageContentType::WebsiteConnected:
|
|
|
|
case MessageContentType::PassportDataSent:
|
|
|
|
case MessageContentType::PassportDataReceived:
|
|
|
|
case MessageContentType::Poll:
|
2020-03-29 23:34:37 +02:00
|
|
|
case MessageContentType::Dice:
|
2020-10-29 20:25:58 +01:00
|
|
|
case MessageContentType::ProximityAlertTriggered:
|
2020-11-24 12:33:16 +01:00
|
|
|
case MessageContentType::GroupCall:
|
|
|
|
case MessageContentType::InviteToGroupCall:
|
2021-08-18 15:03:10 +02:00
|
|
|
case MessageContentType::ChatSetTheme:
|
2022-03-28 09:01:39 +02:00
|
|
|
case MessageContentType::WebViewDataSent:
|
|
|
|
case MessageContentType::WebViewDataReceived:
|
2022-07-01 14:28:22 +02:00
|
|
|
case MessageContentType::GiftPremium:
|
2022-10-18 15:08:53 +02:00
|
|
|
case MessageContentType::TopicCreate:
|
2022-10-18 21:16:03 +02:00
|
|
|
case MessageContentType::TopicEdit:
|
2022-12-09 12:13:37 +01:00
|
|
|
case MessageContentType::SuggestProfilePhoto:
|
2022-12-14 19:13:48 +01:00
|
|
|
case MessageContentType::WriteAccessAllowed:
|
2023-01-10 14:20:30 +01:00
|
|
|
case MessageContentType::RequestedDialog:
|
2023-02-22 10:24:43 +01:00
|
|
|
case MessageContentType::WebViewWriteAccessAllowed:
|
2023-04-10 13:12:35 +02:00
|
|
|
case MessageContentType::SetBackground:
|
2023-06-12 18:23:58 +02:00
|
|
|
case MessageContentType::Story:
|
2023-08-25 15:53:50 +02:00
|
|
|
case MessageContentType::WriteAccessAllowedByRequest:
|
2023-09-29 16:55:03 +02:00
|
|
|
case MessageContentType::GiftCode:
|
2023-09-29 23:32:39 +02:00
|
|
|
case MessageContentType::Giveaway:
|
2023-10-16 10:31:11 +02:00
|
|
|
case MessageContentType::GiveawayLaunch:
|
2023-11-09 18:28:27 +01:00
|
|
|
case MessageContentType::GiveawayResults:
|
2023-12-18 19:03:11 +01:00
|
|
|
case MessageContentType::GiveawayWinners:
|
2024-01-02 12:27:11 +01:00
|
|
|
case MessageContentType::ExpiredVideoNote:
|
|
|
|
case MessageContentType::ExpiredVoiceNote:
|
2024-02-07 18:50:00 +01:00
|
|
|
case MessageContentType::BoostApply:
|
2024-03-21 22:43:18 +01:00
|
|
|
case MessageContentType::DialogShared:
|
2024-06-21 11:25:23 +02:00
|
|
|
case MessageContentType::PaidMedia:
|
2020-01-27 14:06:00 +01:00
|
|
|
return false;
|
|
|
|
default:
|
|
|
|
UNREACHABLE();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-15 17:13:54 +02:00
|
|
|
bool is_homogenous_media_group_content(MessageContentType content_type) {
|
|
|
|
return content_type == MessageContentType::Audio || content_type == MessageContentType::Document;
|
|
|
|
}
|
|
|
|
|
2024-01-30 13:07:21 +01:00
|
|
|
bool can_be_secret_message_content(MessageContentType content_type) {
|
2020-01-27 14:06:00 +01:00
|
|
|
switch (content_type) {
|
|
|
|
case MessageContentType::Animation:
|
|
|
|
case MessageContentType::Audio:
|
|
|
|
case MessageContentType::Photo:
|
|
|
|
case MessageContentType::Video:
|
|
|
|
case MessageContentType::VideoNote:
|
|
|
|
case MessageContentType::VoiceNote:
|
|
|
|
return true;
|
|
|
|
case MessageContentType::Contact:
|
|
|
|
case MessageContentType::Document:
|
|
|
|
case MessageContentType::Game:
|
|
|
|
case MessageContentType::Invoice:
|
|
|
|
case MessageContentType::LiveLocation:
|
|
|
|
case MessageContentType::Location:
|
|
|
|
case MessageContentType::Sticker:
|
|
|
|
case MessageContentType::Text:
|
|
|
|
case MessageContentType::Unsupported:
|
|
|
|
case MessageContentType::Venue:
|
|
|
|
case MessageContentType::ExpiredPhoto:
|
|
|
|
case MessageContentType::ExpiredVideo:
|
|
|
|
case MessageContentType::ChatCreate:
|
|
|
|
case MessageContentType::ChatChangeTitle:
|
|
|
|
case MessageContentType::ChatChangePhoto:
|
|
|
|
case MessageContentType::ChatDeletePhoto:
|
|
|
|
case MessageContentType::ChatDeleteHistory:
|
|
|
|
case MessageContentType::ChatAddUsers:
|
|
|
|
case MessageContentType::ChatJoinedByLink:
|
|
|
|
case MessageContentType::ChatDeleteUser:
|
|
|
|
case MessageContentType::ChatMigrateTo:
|
|
|
|
case MessageContentType::ChannelCreate:
|
|
|
|
case MessageContentType::ChannelMigrateFrom:
|
|
|
|
case MessageContentType::PinMessage:
|
|
|
|
case MessageContentType::GameScore:
|
|
|
|
case MessageContentType::ScreenshotTaken:
|
|
|
|
case MessageContentType::ChatSetTtl:
|
|
|
|
case MessageContentType::Call:
|
|
|
|
case MessageContentType::PaymentSuccessful:
|
|
|
|
case MessageContentType::ContactRegistered:
|
|
|
|
case MessageContentType::CustomServiceAction:
|
|
|
|
case MessageContentType::WebsiteConnected:
|
|
|
|
case MessageContentType::PassportDataSent:
|
|
|
|
case MessageContentType::PassportDataReceived:
|
|
|
|
case MessageContentType::Poll:
|
2020-03-29 23:34:37 +02:00
|
|
|
case MessageContentType::Dice:
|
2020-10-29 20:25:58 +01:00
|
|
|
case MessageContentType::ProximityAlertTriggered:
|
2020-11-24 12:33:16 +01:00
|
|
|
case MessageContentType::GroupCall:
|
|
|
|
case MessageContentType::InviteToGroupCall:
|
2021-08-18 15:03:10 +02:00
|
|
|
case MessageContentType::ChatSetTheme:
|
2022-03-28 09:01:39 +02:00
|
|
|
case MessageContentType::WebViewDataSent:
|
|
|
|
case MessageContentType::WebViewDataReceived:
|
2022-07-01 14:28:22 +02:00
|
|
|
case MessageContentType::GiftPremium:
|
2022-10-18 15:08:53 +02:00
|
|
|
case MessageContentType::TopicCreate:
|
2022-10-18 21:16:03 +02:00
|
|
|
case MessageContentType::TopicEdit:
|
2022-12-09 12:13:37 +01:00
|
|
|
case MessageContentType::SuggestProfilePhoto:
|
2022-12-14 19:13:48 +01:00
|
|
|
case MessageContentType::WriteAccessAllowed:
|
2023-01-10 14:20:30 +01:00
|
|
|
case MessageContentType::RequestedDialog:
|
2023-02-22 10:24:43 +01:00
|
|
|
case MessageContentType::WebViewWriteAccessAllowed:
|
2023-04-10 13:12:35 +02:00
|
|
|
case MessageContentType::SetBackground:
|
2023-06-12 18:23:58 +02:00
|
|
|
case MessageContentType::Story:
|
2023-08-25 15:53:50 +02:00
|
|
|
case MessageContentType::WriteAccessAllowedByRequest:
|
2023-09-29 16:55:03 +02:00
|
|
|
case MessageContentType::GiftCode:
|
2023-09-29 23:32:39 +02:00
|
|
|
case MessageContentType::Giveaway:
|
2024-06-22 10:05:35 +02:00
|
|
|
case MessageContentType::GiveawayLaunch:
|
|
|
|
case MessageContentType::GiveawayResults:
|
|
|
|
case MessageContentType::GiveawayWinners:
|
|
|
|
case MessageContentType::ExpiredVideoNote:
|
|
|
|
case MessageContentType::ExpiredVoiceNote:
|
|
|
|
case MessageContentType::BoostApply:
|
|
|
|
case MessageContentType::DialogShared:
|
2024-06-21 11:25:23 +02:00
|
|
|
case MessageContentType::PaidMedia:
|
2024-06-22 10:05:35 +02:00
|
|
|
return false;
|
|
|
|
default:
|
|
|
|
UNREACHABLE();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool can_be_local_message_content(MessageContentType content_type) {
|
|
|
|
switch (content_type) {
|
|
|
|
case MessageContentType::Animation:
|
|
|
|
case MessageContentType::Audio:
|
|
|
|
case MessageContentType::Contact:
|
|
|
|
case MessageContentType::Document:
|
|
|
|
case MessageContentType::Location:
|
|
|
|
case MessageContentType::Photo:
|
|
|
|
case MessageContentType::Sticker:
|
|
|
|
case MessageContentType::Text:
|
|
|
|
case MessageContentType::Venue:
|
|
|
|
case MessageContentType::Video:
|
|
|
|
case MessageContentType::VideoNote:
|
|
|
|
case MessageContentType::VoiceNote:
|
|
|
|
case MessageContentType::Story:
|
|
|
|
return true;
|
|
|
|
case MessageContentType::Game:
|
|
|
|
case MessageContentType::Invoice:
|
|
|
|
case MessageContentType::LiveLocation:
|
|
|
|
case MessageContentType::Unsupported:
|
|
|
|
case MessageContentType::ExpiredPhoto:
|
|
|
|
case MessageContentType::ExpiredVideo:
|
|
|
|
case MessageContentType::ChatCreate:
|
|
|
|
case MessageContentType::ChatChangeTitle:
|
|
|
|
case MessageContentType::ChatChangePhoto:
|
|
|
|
case MessageContentType::ChatDeletePhoto:
|
|
|
|
case MessageContentType::ChatDeleteHistory:
|
|
|
|
case MessageContentType::ChatAddUsers:
|
|
|
|
case MessageContentType::ChatJoinedByLink:
|
|
|
|
case MessageContentType::ChatDeleteUser:
|
|
|
|
case MessageContentType::ChatMigrateTo:
|
|
|
|
case MessageContentType::ChannelCreate:
|
|
|
|
case MessageContentType::ChannelMigrateFrom:
|
|
|
|
case MessageContentType::PinMessage:
|
|
|
|
case MessageContentType::GameScore:
|
|
|
|
case MessageContentType::ScreenshotTaken:
|
|
|
|
case MessageContentType::ChatSetTtl:
|
|
|
|
case MessageContentType::Call:
|
|
|
|
case MessageContentType::PaymentSuccessful:
|
|
|
|
case MessageContentType::ContactRegistered:
|
|
|
|
case MessageContentType::CustomServiceAction:
|
|
|
|
case MessageContentType::WebsiteConnected:
|
|
|
|
case MessageContentType::PassportDataSent:
|
|
|
|
case MessageContentType::PassportDataReceived:
|
|
|
|
case MessageContentType::Poll:
|
|
|
|
case MessageContentType::Dice:
|
|
|
|
case MessageContentType::ProximityAlertTriggered:
|
|
|
|
case MessageContentType::GroupCall:
|
|
|
|
case MessageContentType::InviteToGroupCall:
|
|
|
|
case MessageContentType::ChatSetTheme:
|
|
|
|
case MessageContentType::WebViewDataSent:
|
|
|
|
case MessageContentType::WebViewDataReceived:
|
|
|
|
case MessageContentType::GiftPremium:
|
|
|
|
case MessageContentType::TopicCreate:
|
|
|
|
case MessageContentType::TopicEdit:
|
|
|
|
case MessageContentType::SuggestProfilePhoto:
|
|
|
|
case MessageContentType::WriteAccessAllowed:
|
|
|
|
case MessageContentType::RequestedDialog:
|
|
|
|
case MessageContentType::WebViewWriteAccessAllowed:
|
|
|
|
case MessageContentType::SetBackground:
|
|
|
|
case MessageContentType::WriteAccessAllowedByRequest:
|
|
|
|
case MessageContentType::GiftCode:
|
|
|
|
case MessageContentType::Giveaway:
|
2023-10-16 10:31:11 +02:00
|
|
|
case MessageContentType::GiveawayLaunch:
|
2023-11-09 18:28:27 +01:00
|
|
|
case MessageContentType::GiveawayResults:
|
2023-12-18 19:03:11 +01:00
|
|
|
case MessageContentType::GiveawayWinners:
|
2024-01-02 12:27:11 +01:00
|
|
|
case MessageContentType::ExpiredVideoNote:
|
|
|
|
case MessageContentType::ExpiredVoiceNote:
|
2024-02-07 18:50:00 +01:00
|
|
|
case MessageContentType::BoostApply:
|
2024-03-21 22:43:18 +01:00
|
|
|
case MessageContentType::DialogShared:
|
2024-06-21 11:25:23 +02:00
|
|
|
case MessageContentType::PaidMedia:
|
2020-01-27 14:06:00 +01:00
|
|
|
return false;
|
|
|
|
default:
|
|
|
|
UNREACHABLE();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool is_service_message_content(MessageContentType content_type) {
|
|
|
|
switch (content_type) {
|
|
|
|
case MessageContentType::Animation:
|
|
|
|
case MessageContentType::Audio:
|
|
|
|
case MessageContentType::Contact:
|
2023-10-13 11:47:34 +02:00
|
|
|
case MessageContentType::Dice:
|
2020-01-27 14:06:00 +01:00
|
|
|
case MessageContentType::Document:
|
2023-12-21 15:24:21 +01:00
|
|
|
case MessageContentType::ExpiredPhoto:
|
|
|
|
case MessageContentType::ExpiredVideo:
|
2024-01-02 12:27:11 +01:00
|
|
|
case MessageContentType::ExpiredVideoNote:
|
|
|
|
case MessageContentType::ExpiredVoiceNote:
|
2020-01-27 14:06:00 +01:00
|
|
|
case MessageContentType::Game:
|
2023-10-13 11:47:34 +02:00
|
|
|
case MessageContentType::Giveaway:
|
2023-12-18 19:03:11 +01:00
|
|
|
case MessageContentType::GiveawayWinners:
|
2020-01-27 14:06:00 +01:00
|
|
|
case MessageContentType::Invoice:
|
|
|
|
case MessageContentType::LiveLocation:
|
|
|
|
case MessageContentType::Location:
|
2024-06-21 11:25:23 +02:00
|
|
|
case MessageContentType::PaidMedia:
|
2020-01-27 14:06:00 +01:00
|
|
|
case MessageContentType::Photo:
|
2023-10-13 11:47:34 +02:00
|
|
|
case MessageContentType::Poll:
|
2020-01-27 14:06:00 +01:00
|
|
|
case MessageContentType::Sticker:
|
2023-10-13 11:47:34 +02:00
|
|
|
case MessageContentType::Story:
|
2020-01-27 14:06:00 +01:00
|
|
|
case MessageContentType::Text:
|
|
|
|
case MessageContentType::Unsupported:
|
|
|
|
case MessageContentType::Venue:
|
|
|
|
case MessageContentType::Video:
|
|
|
|
case MessageContentType::VideoNote:
|
|
|
|
case MessageContentType::VoiceNote:
|
|
|
|
return false;
|
|
|
|
case MessageContentType::ChatCreate:
|
|
|
|
case MessageContentType::ChatChangeTitle:
|
|
|
|
case MessageContentType::ChatChangePhoto:
|
|
|
|
case MessageContentType::ChatDeletePhoto:
|
|
|
|
case MessageContentType::ChatDeleteHistory:
|
|
|
|
case MessageContentType::ChatAddUsers:
|
|
|
|
case MessageContentType::ChatJoinedByLink:
|
|
|
|
case MessageContentType::ChatDeleteUser:
|
|
|
|
case MessageContentType::ChatMigrateTo:
|
|
|
|
case MessageContentType::ChannelCreate:
|
|
|
|
case MessageContentType::ChannelMigrateFrom:
|
|
|
|
case MessageContentType::PinMessage:
|
|
|
|
case MessageContentType::GameScore:
|
|
|
|
case MessageContentType::ScreenshotTaken:
|
|
|
|
case MessageContentType::ChatSetTtl:
|
|
|
|
case MessageContentType::Call:
|
|
|
|
case MessageContentType::PaymentSuccessful:
|
|
|
|
case MessageContentType::ContactRegistered:
|
|
|
|
case MessageContentType::CustomServiceAction:
|
|
|
|
case MessageContentType::WebsiteConnected:
|
|
|
|
case MessageContentType::PassportDataSent:
|
|
|
|
case MessageContentType::PassportDataReceived:
|
2020-10-29 20:25:58 +01:00
|
|
|
case MessageContentType::ProximityAlertTriggered:
|
2020-11-24 12:33:16 +01:00
|
|
|
case MessageContentType::GroupCall:
|
|
|
|
case MessageContentType::InviteToGroupCall:
|
2021-08-18 15:03:10 +02:00
|
|
|
case MessageContentType::ChatSetTheme:
|
2022-03-28 09:01:39 +02:00
|
|
|
case MessageContentType::WebViewDataSent:
|
|
|
|
case MessageContentType::WebViewDataReceived:
|
2022-07-01 14:28:22 +02:00
|
|
|
case MessageContentType::GiftPremium:
|
2022-10-18 15:08:53 +02:00
|
|
|
case MessageContentType::TopicCreate:
|
2022-10-18 21:16:03 +02:00
|
|
|
case MessageContentType::TopicEdit:
|
2022-12-09 12:13:37 +01:00
|
|
|
case MessageContentType::SuggestProfilePhoto:
|
2022-12-14 19:13:48 +01:00
|
|
|
case MessageContentType::WriteAccessAllowed:
|
2023-01-10 14:20:30 +01:00
|
|
|
case MessageContentType::RequestedDialog:
|
2023-02-22 10:24:43 +01:00
|
|
|
case MessageContentType::WebViewWriteAccessAllowed:
|
2023-04-10 13:12:35 +02:00
|
|
|
case MessageContentType::SetBackground:
|
2023-08-25 15:53:50 +02:00
|
|
|
case MessageContentType::WriteAccessAllowedByRequest:
|
2023-09-29 16:55:03 +02:00
|
|
|
case MessageContentType::GiftCode:
|
2023-10-16 10:31:11 +02:00
|
|
|
case MessageContentType::GiveawayLaunch:
|
2023-11-09 18:28:27 +01:00
|
|
|
case MessageContentType::GiveawayResults:
|
2024-02-07 18:50:00 +01:00
|
|
|
case MessageContentType::BoostApply:
|
2024-03-21 22:43:18 +01:00
|
|
|
case MessageContentType::DialogShared:
|
2020-01-27 14:06:00 +01:00
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
UNREACHABLE();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-23 18:19:54 +01:00
|
|
|
bool is_editable_message_content(MessageContentType content_type) {
|
|
|
|
switch (content_type) {
|
|
|
|
case MessageContentType::Animation:
|
|
|
|
case MessageContentType::Audio:
|
|
|
|
case MessageContentType::Document:
|
|
|
|
case MessageContentType::Game:
|
2024-06-21 11:25:23 +02:00
|
|
|
case MessageContentType::PaidMedia:
|
2024-02-23 18:19:54 +01:00
|
|
|
case MessageContentType::Photo:
|
|
|
|
case MessageContentType::Text:
|
|
|
|
case MessageContentType::Video:
|
|
|
|
case MessageContentType::VoiceNote:
|
|
|
|
return true;
|
|
|
|
case MessageContentType::LiveLocation:
|
|
|
|
case MessageContentType::Poll:
|
|
|
|
case MessageContentType::Story:
|
|
|
|
case MessageContentType::Contact:
|
|
|
|
case MessageContentType::Dice:
|
|
|
|
case MessageContentType::Giveaway:
|
|
|
|
case MessageContentType::GiveawayWinners:
|
|
|
|
case MessageContentType::Location:
|
|
|
|
case MessageContentType::Sticker:
|
|
|
|
case MessageContentType::Venue:
|
|
|
|
case MessageContentType::VideoNote:
|
|
|
|
case MessageContentType::Invoice:
|
|
|
|
case MessageContentType::Unsupported:
|
|
|
|
case MessageContentType::ChatCreate:
|
|
|
|
case MessageContentType::ChatChangeTitle:
|
|
|
|
case MessageContentType::ChatChangePhoto:
|
|
|
|
case MessageContentType::ChatDeletePhoto:
|
|
|
|
case MessageContentType::ChatDeleteHistory:
|
|
|
|
case MessageContentType::ChatAddUsers:
|
|
|
|
case MessageContentType::ChatJoinedByLink:
|
|
|
|
case MessageContentType::ChatDeleteUser:
|
|
|
|
case MessageContentType::ChatMigrateTo:
|
|
|
|
case MessageContentType::ChannelCreate:
|
|
|
|
case MessageContentType::ChannelMigrateFrom:
|
|
|
|
case MessageContentType::PinMessage:
|
|
|
|
case MessageContentType::GameScore:
|
|
|
|
case MessageContentType::ScreenshotTaken:
|
|
|
|
case MessageContentType::ChatSetTtl:
|
|
|
|
case MessageContentType::Call:
|
|
|
|
case MessageContentType::PaymentSuccessful:
|
|
|
|
case MessageContentType::ContactRegistered:
|
|
|
|
case MessageContentType::ExpiredPhoto:
|
|
|
|
case MessageContentType::ExpiredVideo:
|
|
|
|
case MessageContentType::CustomServiceAction:
|
|
|
|
case MessageContentType::WebsiteConnected:
|
|
|
|
case MessageContentType::PassportDataSent:
|
|
|
|
case MessageContentType::PassportDataReceived:
|
|
|
|
case MessageContentType::ProximityAlertTriggered:
|
|
|
|
case MessageContentType::GroupCall:
|
|
|
|
case MessageContentType::InviteToGroupCall:
|
|
|
|
case MessageContentType::ChatSetTheme:
|
|
|
|
case MessageContentType::WebViewDataSent:
|
|
|
|
case MessageContentType::WebViewDataReceived:
|
|
|
|
case MessageContentType::GiftPremium:
|
|
|
|
case MessageContentType::TopicCreate:
|
|
|
|
case MessageContentType::TopicEdit:
|
|
|
|
case MessageContentType::SuggestProfilePhoto:
|
|
|
|
case MessageContentType::WriteAccessAllowed:
|
|
|
|
case MessageContentType::RequestedDialog:
|
|
|
|
case MessageContentType::WebViewWriteAccessAllowed:
|
|
|
|
case MessageContentType::SetBackground:
|
|
|
|
case MessageContentType::WriteAccessAllowedByRequest:
|
|
|
|
case MessageContentType::GiftCode:
|
|
|
|
case MessageContentType::GiveawayLaunch:
|
|
|
|
case MessageContentType::GiveawayResults:
|
|
|
|
case MessageContentType::ExpiredVideoNote:
|
|
|
|
case MessageContentType::ExpiredVoiceNote:
|
|
|
|
case MessageContentType::BoostApply:
|
2024-03-21 22:43:18 +01:00
|
|
|
case MessageContentType::DialogShared:
|
2024-02-23 18:19:54 +01:00
|
|
|
return false;
|
|
|
|
default:
|
|
|
|
UNREACHABLE();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-12-21 15:24:21 +01:00
|
|
|
bool is_supported_reply_message_content(MessageContentType content_type) {
|
|
|
|
switch (content_type) {
|
|
|
|
case MessageContentType::Animation:
|
|
|
|
case MessageContentType::Audio:
|
|
|
|
case MessageContentType::Contact:
|
|
|
|
case MessageContentType::Dice:
|
|
|
|
case MessageContentType::Document:
|
|
|
|
case MessageContentType::Game:
|
|
|
|
case MessageContentType::Giveaway:
|
|
|
|
case MessageContentType::GiveawayWinners:
|
|
|
|
case MessageContentType::Invoice:
|
|
|
|
case MessageContentType::Location:
|
2024-06-21 11:25:23 +02:00
|
|
|
case MessageContentType::PaidMedia:
|
2023-12-21 15:24:21 +01:00
|
|
|
case MessageContentType::Photo:
|
|
|
|
case MessageContentType::Poll:
|
|
|
|
case MessageContentType::Sticker:
|
|
|
|
case MessageContentType::Story:
|
|
|
|
case MessageContentType::Text:
|
|
|
|
case MessageContentType::Unsupported:
|
|
|
|
case MessageContentType::Venue:
|
|
|
|
case MessageContentType::Video:
|
|
|
|
case MessageContentType::VideoNote:
|
|
|
|
case MessageContentType::VoiceNote:
|
2024-01-02 12:27:11 +01:00
|
|
|
// update documentation when the list changes
|
2023-12-21 15:24:21 +01:00
|
|
|
return true;
|
|
|
|
case MessageContentType::ExpiredPhoto:
|
|
|
|
case MessageContentType::ExpiredVideo:
|
2024-01-02 12:27:11 +01:00
|
|
|
case MessageContentType::ExpiredVideoNote:
|
|
|
|
case MessageContentType::ExpiredVoiceNote:
|
2023-12-21 15:24:21 +01:00
|
|
|
case MessageContentType::LiveLocation:
|
|
|
|
return false;
|
|
|
|
default:
|
|
|
|
UNREACHABLE();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-02 12:27:11 +01:00
|
|
|
bool is_expired_message_content(MessageContentType content_type) {
|
|
|
|
switch (content_type) {
|
|
|
|
case MessageContentType::ExpiredPhoto:
|
|
|
|
case MessageContentType::ExpiredVideo:
|
|
|
|
case MessageContentType::ExpiredVideoNote:
|
|
|
|
case MessageContentType::ExpiredVoiceNote:
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-06-21 13:00:29 +02:00
|
|
|
MessageContentType get_expired_message_content_type(MessageContentType content_type) {
|
|
|
|
switch (content_type) {
|
|
|
|
case MessageContentType::Photo:
|
|
|
|
return MessageContentType::ExpiredPhoto;
|
|
|
|
case MessageContentType::Video:
|
|
|
|
return MessageContentType::ExpiredVideo;
|
|
|
|
case MessageContentType::VideoNote:
|
|
|
|
return MessageContentType::ExpiredVideoNote;
|
|
|
|
case MessageContentType::VoiceNote:
|
|
|
|
return MessageContentType::ExpiredVoiceNote;
|
|
|
|
default:
|
|
|
|
return MessageContentType::None;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-27 14:06:00 +01:00
|
|
|
bool can_have_message_content_caption(MessageContentType content_type) {
|
|
|
|
switch (content_type) {
|
|
|
|
case MessageContentType::Animation:
|
|
|
|
case MessageContentType::Audio:
|
|
|
|
case MessageContentType::Document:
|
2024-06-21 11:25:23 +02:00
|
|
|
case MessageContentType::PaidMedia:
|
2020-01-27 14:06:00 +01:00
|
|
|
case MessageContentType::Photo:
|
|
|
|
case MessageContentType::Video:
|
|
|
|
case MessageContentType::VoiceNote:
|
|
|
|
return true;
|
|
|
|
case MessageContentType::Contact:
|
|
|
|
case MessageContentType::Game:
|
|
|
|
case MessageContentType::Invoice:
|
|
|
|
case MessageContentType::LiveLocation:
|
|
|
|
case MessageContentType::Location:
|
|
|
|
case MessageContentType::Sticker:
|
|
|
|
case MessageContentType::Text:
|
|
|
|
case MessageContentType::Unsupported:
|
|
|
|
case MessageContentType::Venue:
|
|
|
|
case MessageContentType::VideoNote:
|
|
|
|
case MessageContentType::ChatCreate:
|
|
|
|
case MessageContentType::ChatChangeTitle:
|
|
|
|
case MessageContentType::ChatChangePhoto:
|
|
|
|
case MessageContentType::ChatDeletePhoto:
|
|
|
|
case MessageContentType::ChatDeleteHistory:
|
|
|
|
case MessageContentType::ChatAddUsers:
|
|
|
|
case MessageContentType::ChatJoinedByLink:
|
|
|
|
case MessageContentType::ChatDeleteUser:
|
|
|
|
case MessageContentType::ChatMigrateTo:
|
|
|
|
case MessageContentType::ChannelCreate:
|
|
|
|
case MessageContentType::ChannelMigrateFrom:
|
|
|
|
case MessageContentType::PinMessage:
|
|
|
|
case MessageContentType::GameScore:
|
|
|
|
case MessageContentType::ScreenshotTaken:
|
|
|
|
case MessageContentType::ChatSetTtl:
|
|
|
|
case MessageContentType::Call:
|
|
|
|
case MessageContentType::PaymentSuccessful:
|
|
|
|
case MessageContentType::ContactRegistered:
|
|
|
|
case MessageContentType::ExpiredPhoto:
|
|
|
|
case MessageContentType::ExpiredVideo:
|
|
|
|
case MessageContentType::CustomServiceAction:
|
|
|
|
case MessageContentType::WebsiteConnected:
|
|
|
|
case MessageContentType::PassportDataSent:
|
|
|
|
case MessageContentType::PassportDataReceived:
|
|
|
|
case MessageContentType::Poll:
|
2020-03-29 23:34:37 +02:00
|
|
|
case MessageContentType::Dice:
|
2020-10-29 20:25:58 +01:00
|
|
|
case MessageContentType::ProximityAlertTriggered:
|
2020-11-24 12:33:16 +01:00
|
|
|
case MessageContentType::GroupCall:
|
|
|
|
case MessageContentType::InviteToGroupCall:
|
2021-08-18 15:03:10 +02:00
|
|
|
case MessageContentType::ChatSetTheme:
|
2022-03-28 09:01:39 +02:00
|
|
|
case MessageContentType::WebViewDataSent:
|
|
|
|
case MessageContentType::WebViewDataReceived:
|
2022-07-01 14:28:22 +02:00
|
|
|
case MessageContentType::GiftPremium:
|
2022-10-18 15:08:53 +02:00
|
|
|
case MessageContentType::TopicCreate:
|
2022-10-18 21:16:03 +02:00
|
|
|
case MessageContentType::TopicEdit:
|
2022-12-09 12:13:37 +01:00
|
|
|
case MessageContentType::SuggestProfilePhoto:
|
2022-12-14 19:13:48 +01:00
|
|
|
case MessageContentType::WriteAccessAllowed:
|
2023-01-10 14:20:30 +01:00
|
|
|
case MessageContentType::RequestedDialog:
|
2023-02-22 10:24:43 +01:00
|
|
|
case MessageContentType::WebViewWriteAccessAllowed:
|
2023-04-10 13:12:35 +02:00
|
|
|
case MessageContentType::SetBackground:
|
2023-06-12 18:23:58 +02:00
|
|
|
case MessageContentType::Story:
|
2023-08-25 15:53:50 +02:00
|
|
|
case MessageContentType::WriteAccessAllowedByRequest:
|
2023-09-29 16:55:03 +02:00
|
|
|
case MessageContentType::GiftCode:
|
2023-09-29 23:32:39 +02:00
|
|
|
case MessageContentType::Giveaway:
|
2023-10-16 10:31:11 +02:00
|
|
|
case MessageContentType::GiveawayLaunch:
|
2023-11-09 18:28:27 +01:00
|
|
|
case MessageContentType::GiveawayResults:
|
2023-12-18 19:03:11 +01:00
|
|
|
case MessageContentType::GiveawayWinners:
|
2024-01-02 12:27:11 +01:00
|
|
|
case MessageContentType::ExpiredVideoNote:
|
|
|
|
case MessageContentType::ExpiredVoiceNote:
|
2024-02-07 18:50:00 +01:00
|
|
|
case MessageContentType::BoostApply:
|
2024-03-21 22:43:18 +01:00
|
|
|
case MessageContentType::DialogShared:
|
2020-01-27 14:06:00 +01:00
|
|
|
return false;
|
|
|
|
default:
|
|
|
|
UNREACHABLE();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-05 21:28:43 +01:00
|
|
|
uint64 get_message_content_chain_id(MessageContentType content_type) {
|
|
|
|
switch (content_type) {
|
|
|
|
case MessageContentType::Animation:
|
|
|
|
case MessageContentType::Audio:
|
|
|
|
case MessageContentType::Document:
|
2022-09-22 17:05:58 +02:00
|
|
|
case MessageContentType::Invoice:
|
2024-06-21 11:25:23 +02:00
|
|
|
case MessageContentType::PaidMedia:
|
2022-02-05 21:28:43 +01:00
|
|
|
case MessageContentType::Photo:
|
|
|
|
case MessageContentType::Sticker:
|
|
|
|
case MessageContentType::Video:
|
|
|
|
case MessageContentType::VideoNote:
|
|
|
|
case MessageContentType::VoiceNote:
|
|
|
|
return 1;
|
|
|
|
default:
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-27 14:06:00 +01:00
|
|
|
} // namespace td
|