Add class AccentColorId.
This commit is contained in:
parent
02b87ef1f3
commit
22e4b0d641
@ -539,6 +539,7 @@ set(TDLIB_SOURCE
|
|||||||
td/mtproto/TransportType.h
|
td/mtproto/TransportType.h
|
||||||
td/mtproto/utils.h
|
td/mtproto/utils.h
|
||||||
|
|
||||||
|
td/telegram/AccentColorId.h
|
||||||
td/telegram/AccessRights.h
|
td/telegram/AccessRights.h
|
||||||
td/telegram/AccountManager.h
|
td/telegram/AccountManager.h
|
||||||
td/telegram/AffectedHistory.h
|
td/telegram/AffectedHistory.h
|
||||||
|
@ -743,6 +743,10 @@ premiumGiveawayInfoOngoing creation_date:int32 status:PremiumGiveawayParticipant
|
|||||||
premiumGiveawayInfoCompleted creation_date:int32 actual_winners_selection_date:int32 was_refunded:Bool winner_count:int32 activation_count:int32 gift_code:string = PremiumGiveawayInfo;
|
premiumGiveawayInfoCompleted creation_date:int32 actual_winners_selection_date:int32 was_refunded:Bool winner_count:int32 activation_count:int32 gift_code:string = PremiumGiveawayInfo;
|
||||||
|
|
||||||
|
|
||||||
|
//@description Contains accent color identifier for user/chat name, and backgrounds of chat photo, replies and link previews
|
||||||
|
//@id Accent color identifier; 0 - red, 1 - orange, 2 - purple/violet, 3 - green, 4 - cyan, 5 - blue, 6 - pink
|
||||||
|
accentColorId id:int32 = AccentColorId;
|
||||||
|
|
||||||
//@description Describes a custom emoji to be shown instead of the Telegram Premium badge
|
//@description Describes a custom emoji to be shown instead of the Telegram Premium badge
|
||||||
//@custom_emoji_id Identifier of the custom emoji in stickerFormatTgs format
|
//@custom_emoji_id Identifier of the custom emoji in stickerFormatTgs format
|
||||||
//@expiration_date Point in time (Unix timestamp) when the status will expire; 0 if never
|
//@expiration_date Point in time (Unix timestamp) when the status will expire; 0 if never
|
||||||
@ -767,6 +771,7 @@ usernames active_usernames:vector<string> disabled_usernames:vector<string> edit
|
|||||||
//@phone_number Phone number of the user
|
//@phone_number Phone number of the user
|
||||||
//@status Current online status of the user
|
//@status Current online status of the user
|
||||||
//@profile_photo Profile photo of the user; may be null
|
//@profile_photo Profile photo of the user; may be null
|
||||||
|
//@accent_color_id Identifier of the accent color for name, and backgrounds of profile photo, reply and link preview
|
||||||
//@emoji_status Emoji status to be shown instead of the default Telegram Premium badge; may be null. For Telegram Premium users only
|
//@emoji_status Emoji status to be shown instead of the default Telegram Premium badge; may be null. For Telegram Premium users only
|
||||||
//@is_contact The user is a contact of the current user
|
//@is_contact The user is a contact of the current user
|
||||||
//@is_mutual_contact The user is a contact of the current user and the current user is a contact of the user
|
//@is_mutual_contact The user is a contact of the current user and the current user is a contact of the user
|
||||||
@ -783,7 +788,7 @@ usernames active_usernames:vector<string> disabled_usernames:vector<string> edit
|
|||||||
//@type Type of the user
|
//@type Type of the user
|
||||||
//@language_code IETF language tag of the user's language; only available to bots
|
//@language_code IETF language tag of the user's language; only available to bots
|
||||||
//@added_to_attachment_menu True, if the user added the current bot to attachment menu; only available to bots
|
//@added_to_attachment_menu True, if the user added the current bot to attachment menu; only available to bots
|
||||||
user id:int53 first_name:string last_name:string usernames:usernames phone_number:string status:UserStatus profile_photo:profilePhoto emoji_status:emojiStatus is_contact:Bool is_mutual_contact:Bool is_close_friend:Bool is_verified:Bool is_premium:Bool is_support:Bool restriction_reason:string is_scam:Bool is_fake:Bool has_active_stories:Bool has_unread_active_stories:Bool have_access:Bool type:UserType language_code:string added_to_attachment_menu:Bool = User;
|
user id:int53 first_name:string last_name:string usernames:usernames phone_number:string status:UserStatus profile_photo:profilePhoto accent_color_id:accentColorId emoji_status:emojiStatus is_contact:Bool is_mutual_contact:Bool is_close_friend:Bool is_verified:Bool is_premium:Bool is_support:Bool restriction_reason:string is_scam:Bool is_fake:Bool has_active_stories:Bool has_unread_active_stories:Bool have_access:Bool type:UserType language_code:string added_to_attachment_menu:Bool = User;
|
||||||
|
|
||||||
|
|
||||||
//@description Contains information about a bot
|
//@description Contains information about a bot
|
||||||
@ -4189,7 +4194,7 @@ chatEventUsernameChanged old_username:string new_username:string = ChatEventActi
|
|||||||
chatEventActiveUsernamesChanged old_usernames:vector<string> new_usernames:vector<string> = ChatEventAction;
|
chatEventActiveUsernamesChanged old_usernames:vector<string> new_usernames:vector<string> = ChatEventAction;
|
||||||
|
|
||||||
//@description The chat accent color was changed @old_accent_color_id Previous identifier of chat accent color @new_accent_color_id New identifier of chat accent color
|
//@description The chat accent color was changed @old_accent_color_id Previous identifier of chat accent color @new_accent_color_id New identifier of chat accent color
|
||||||
chatEventAccentColorChanged old_accent_color_id:int32 new_accent_color_id:int32 = ChatEventAction;
|
chatEventAccentColorChanged old_accent_color_id:accentColorId new_accent_color_id:accentColorId = ChatEventAction;
|
||||||
|
|
||||||
//@description The chat's custom emoji for reply background was changed @old_reply_background_custom_emoji_id Previous identifier of the custom emoji @new_reply_background_custom_emoji_id New identifier of the custom emoji
|
//@description The chat's custom emoji for reply background was changed @old_reply_background_custom_emoji_id Previous identifier of the custom emoji @new_reply_background_custom_emoji_id New identifier of the custom emoji
|
||||||
chatEventReplyBackgroundCustomEmojiChanged old_reply_background_custom_emoji_id:int64 new_reply_background_custom_emoji_id:int64 = ChatEventAction;
|
chatEventReplyBackgroundCustomEmojiChanged old_reply_background_custom_emoji_id:int64 new_reply_background_custom_emoji_id:int64 = ChatEventAction;
|
||||||
|
83
td/telegram/AccentColorId.h
Normal file
83
td/telegram/AccentColorId.h
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
//
|
||||||
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
|
||||||
|
//
|
||||||
|
// 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)
|
||||||
|
//
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "td/telegram/ChannelId.h"
|
||||||
|
#include "td/telegram/ChatId.h"
|
||||||
|
#include "td/telegram/td_api.h"
|
||||||
|
#include "td/telegram/UserId.h"
|
||||||
|
|
||||||
|
#include "td/utils/common.h"
|
||||||
|
#include "td/utils/HashTableUtils.h"
|
||||||
|
#include "td/utils/StringBuilder.h"
|
||||||
|
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
|
namespace td {
|
||||||
|
|
||||||
|
class AccentColorId {
|
||||||
|
int32 id = -1;
|
||||||
|
|
||||||
|
public:
|
||||||
|
AccentColorId() = default;
|
||||||
|
|
||||||
|
explicit constexpr AccentColorId(int32 accent_color_id) : id(accent_color_id) {
|
||||||
|
}
|
||||||
|
template <class T, typename = std::enable_if_t<std::is_convertible<T, int32>::value>>
|
||||||
|
AccentColorId(T accent_color_id) = delete;
|
||||||
|
|
||||||
|
explicit AccentColorId(UserId user_id) : id(user_id.get() % 7) {
|
||||||
|
}
|
||||||
|
|
||||||
|
explicit AccentColorId(ChatId chat_id) : id(chat_id.get() % 7) {
|
||||||
|
}
|
||||||
|
|
||||||
|
explicit AccentColorId(ChannelId channel_id) : id(channel_id.get() % 7) {
|
||||||
|
}
|
||||||
|
|
||||||
|
bool is_valid() const {
|
||||||
|
return id >= 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32 get() const {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator==(const AccentColorId &other) const {
|
||||||
|
return id == other.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator!=(const AccentColorId &other) const {
|
||||||
|
return id != other.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
td_api::object_ptr<td_api::accentColorId> get_accent_color_id_object() const {
|
||||||
|
return td_api::make_object<td_api::accentColorId>(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class StorerT>
|
||||||
|
void store(StorerT &storer) const {
|
||||||
|
storer.store_int(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class ParserT>
|
||||||
|
void parse(ParserT &parser) {
|
||||||
|
id = parser.fetch_int();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct AccentColorIdHash {
|
||||||
|
uint32 operator()(AccentColorId accent_color_id) const {
|
||||||
|
return Hash<int32>()(accent_color_id.get());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
inline StringBuilder &operator<<(StringBuilder &string_builder, AccentColorId accent_color_id) {
|
||||||
|
return string_builder << "accent color #" << accent_color_id.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace td
|
@ -19145,8 +19145,8 @@ td_api::object_ptr<td_api::updateUser> ContactsManager::get_update_user_object(U
|
|||||||
td_api::object_ptr<td_api::updateUser> ContactsManager::get_update_unknown_user_object(UserId user_id) const {
|
td_api::object_ptr<td_api::updateUser> ContactsManager::get_update_unknown_user_object(UserId user_id) const {
|
||||||
auto have_access = user_id == get_my_id() || user_messages_.count(user_id) != 0;
|
auto have_access = user_id == get_my_id() || user_messages_.count(user_id) != 0;
|
||||||
return td_api::make_object<td_api::updateUser>(td_api::make_object<td_api::user>(
|
return td_api::make_object<td_api::updateUser>(td_api::make_object<td_api::user>(
|
||||||
user_id.get(), "", "", nullptr, "", td_api::make_object<td_api::userStatusEmpty>(), nullptr, nullptr, false,
|
user_id.get(), "", "", nullptr, "", td_api::make_object<td_api::userStatusEmpty>(), nullptr, nullptr, nullptr,
|
||||||
false, false, false, false, false, "", false, false, false, false, have_access,
|
false, false, false, false, false, false, "", false, false, false, false, have_access,
|
||||||
td_api::make_object<td_api::userTypeUnknown>(), "", false));
|
td_api::make_object<td_api::userTypeUnknown>(), "", false));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -19184,7 +19184,7 @@ tl_object_ptr<td_api::user> ContactsManager::get_user_object(UserId user_id, con
|
|||||||
return td_api::make_object<td_api::user>(
|
return td_api::make_object<td_api::user>(
|
||||||
user_id.get(), u->first_name, u->last_name, u->usernames.get_usernames_object(), u->phone_number,
|
user_id.get(), u->first_name, u->last_name, u->usernames.get_usernames_object(), u->phone_number,
|
||||||
get_user_status_object(user_id, u, G()->unix_time()),
|
get_user_status_object(user_id, u, G()->unix_time()),
|
||||||
get_profile_photo_object(td_->file_manager_.get(), u->photo), std::move(emoji_status), u->is_contact,
|
get_profile_photo_object(td_->file_manager_.get(), u->photo), nullptr, std::move(emoji_status), u->is_contact,
|
||||||
u->is_mutual_contact, u->is_close_friend, u->is_verified, u->is_premium, u->is_support,
|
u->is_mutual_contact, u->is_close_friend, u->is_verified, u->is_premium, u->is_support,
|
||||||
get_restriction_reason_description(u->restriction_reasons), u->is_scam, u->is_fake,
|
get_restriction_reason_description(u->restriction_reasons), u->is_scam, u->is_fake,
|
||||||
u->max_active_story_id.is_valid(), get_user_has_unread_stories(u), have_access, std::move(type), u->language_code,
|
u->max_active_story_id.is_valid(), get_user_has_unread_stories(u), have_access, std::move(type), u->language_code,
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
//
|
//
|
||||||
#include "td/telegram/DialogEventLog.h"
|
#include "td/telegram/DialogEventLog.h"
|
||||||
|
|
||||||
|
#include "td/telegram/AccentColorId.h"
|
||||||
#include "td/telegram/ChannelId.h"
|
#include "td/telegram/ChannelId.h"
|
||||||
#include "td/telegram/ChatReactions.h"
|
#include "td/telegram/ChatReactions.h"
|
||||||
#include "td/telegram/ContactsManager.h"
|
#include "td/telegram/ContactsManager.h"
|
||||||
@ -428,9 +429,10 @@ static td_api::object_ptr<td_api::ChatEventAction> get_chat_event_action_object(
|
|||||||
}
|
}
|
||||||
case telegram_api::channelAdminLogEventActionChangeColor::ID: {
|
case telegram_api::channelAdminLogEventActionChangeColor::ID: {
|
||||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionChangeColor>(action_ptr);
|
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionChangeColor>(action_ptr);
|
||||||
auto old_accent_color_id = clamp(action->prev_value_, 0, 256);
|
auto old_accent_color_id = AccentColorId(action->prev_value_);
|
||||||
auto new_accent_color_id = clamp(action->new_value_, 0, 256);
|
auto new_accent_color_id = AccentColorId(action->new_value_);
|
||||||
return td_api::make_object<td_api::chatEventAccentColorChanged>(old_accent_color_id, new_accent_color_id);
|
return td_api::make_object<td_api::chatEventAccentColorChanged>(old_accent_color_id.get_accent_color_id_object(),
|
||||||
|
new_accent_color_id.get_accent_color_id_object());
|
||||||
}
|
}
|
||||||
case telegram_api::channelAdminLogEventActionChangeBackgroundEmoji::ID: {
|
case telegram_api::channelAdminLogEventActionChangeBackgroundEmoji::ID: {
|
||||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionChangeBackgroundEmoji>(action_ptr);
|
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionChangeBackgroundEmoji>(action_ptr);
|
||||||
|
Loading…
Reference in New Issue
Block a user