Add td_api::reactionNotificationSettings.
This commit is contained in:
parent
fe0246093d
commit
8246f955c9
@ -482,6 +482,8 @@ set(TDLIB_SOURCE
|
||||
td/telegram/QuickReplyManager.cpp
|
||||
td/telegram/ReactionListType.cpp
|
||||
td/telegram/ReactionManager.cpp
|
||||
td/telegram/ReactionNotificationSettings.cpp
|
||||
td/telegram/ReactionNotificationsFrom.cpp
|
||||
td/telegram/ReactionType.cpp
|
||||
td/telegram/RecentDialogList.cpp
|
||||
td/telegram/RepliedMessageInfo.cpp
|
||||
@ -832,6 +834,8 @@ set(TDLIB_SOURCE
|
||||
td/telegram/QuickReplyShortcutId.h
|
||||
td/telegram/ReactionListType.h
|
||||
td/telegram/ReactionManager.h
|
||||
td/telegram/ReactionNotificationSettings.h
|
||||
td/telegram/ReactionNotificationsFrom.h
|
||||
td/telegram/ReactionType.h
|
||||
td/telegram/ReactionUnavailabilityReason.h
|
||||
td/telegram/RecentDialogList.h
|
||||
@ -970,6 +974,8 @@ set(TDLIB_SOURCE
|
||||
td/telegram/PollManager.hpp
|
||||
td/telegram/PremiumGiftOption.hpp
|
||||
td/telegram/ReactionManager.hpp
|
||||
td/telegram/ReactionNotificationSettings.hpp
|
||||
td/telegram/ReactionNotificationsFrom.hpp
|
||||
td/telegram/ReactionType.hpp
|
||||
td/telegram/RepliedMessageInfo.hpp
|
||||
td/telegram/ReplyMarkup.hpp
|
||||
|
@ -392,6 +392,8 @@ function split_file($file, $chunks, $undo) {
|
||||
'quick_reply_manager[_(-](?![.]get[(][)])|QuickReplyManager' => 'QuickReplyManager',
|
||||
'ReactionListType|[a-z_]*_reaction_list_type' => 'ReactionListType',
|
||||
'reaction_manager[_(-](?![.]get[(][)])|ReactionManager' => 'ReactionManager',
|
||||
'ReactionNotificationSettings' => 'ReactionNotificationSettings',
|
||||
'ReactionNotificationsFrom' => 'ReactionNotificationsFrom',
|
||||
'ReactionType|[a-z_]*_reaction_type' => 'ReactionType',
|
||||
'RequestActor|RequestOnceActor' => 'RequestActor',
|
||||
'saved_messages_manager[_(-](?![.]get[(][)])|SavedMessagesManager' => 'SavedMessagesManager',
|
||||
|
@ -1665,6 +1665,26 @@ chatNotificationSettings use_default_mute_for:Bool mute_for:int32 use_default_so
|
||||
scopeNotificationSettings mute_for:int32 sound_id:int64 show_preview:Bool use_default_mute_stories:Bool mute_stories:Bool story_sound_id:int64 show_story_sender:Bool disable_pinned_message_notifications:Bool disable_mention_notifications:Bool = ScopeNotificationSettings;
|
||||
|
||||
|
||||
//@class ReactionNotificationSource @description Describes sources of reactions for which notifications will be shown
|
||||
|
||||
//@description Notifications for reactions are disabled
|
||||
reactionNotificationSourceNone = ReactionNotificationSource;
|
||||
|
||||
//@description Notifications for reactions are shown only for reactions from contacts
|
||||
reactionNotificationSourceContacts = ReactionNotificationSource;
|
||||
|
||||
//@description Notifications for reactions are shown for all reactions
|
||||
reactionNotificationSourceAll = ReactionNotificationSource;
|
||||
|
||||
|
||||
//@description Contains information about notification settings for reactions
|
||||
//@message_reaction_source Source of message reactions for which notifications are shown
|
||||
//@story_reaction_source Source of story reactions for which notifications are shown
|
||||
//@sound_id Identifier of the notification sound to be played; 0 if sound is disabled
|
||||
//@show_preview True, if reaction sender and emoji must be displayed in notifications
|
||||
reactionNotificationSettings message_reaction_source:ReactionNotificationSource story_reaction_source:ReactionNotificationSource sound_id:int64 show_preview:Bool = ReactionNotificationSettings;
|
||||
|
||||
|
||||
//@description Contains information about a message draft
|
||||
//@reply_to Information about the message to be replied; must be of the type inputMessageReplyToMessage; may be null if none
|
||||
//@date Point in time (Unix timestamp) when the draft was created
|
||||
|
@ -223,7 +223,7 @@ unique_ptr<NotificationSound> get_notification_sound(bool use_default_sound, int
|
||||
return td::make_unique<NotificationSoundRingtone>(ringtone_id);
|
||||
}
|
||||
|
||||
static unique_ptr<NotificationSound> get_notification_sound(telegram_api::NotificationSound *notification_sound) {
|
||||
unique_ptr<NotificationSound> get_notification_sound(telegram_api::NotificationSound *notification_sound) {
|
||||
if (notification_sound == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -265,8 +265,11 @@ unique_ptr<NotificationSound> get_notification_sound(telegram_api::peerNotifySet
|
||||
}
|
||||
|
||||
telegram_api::object_ptr<telegram_api::NotificationSound> get_input_notification_sound(
|
||||
const unique_ptr<NotificationSound> ¬ification_sound) {
|
||||
const unique_ptr<NotificationSound> ¬ification_sound, bool return_non_null) {
|
||||
if (notification_sound == nullptr) {
|
||||
if (return_non_null) {
|
||||
return telegram_api::make_object<telegram_api::notificationSoundDefault>();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -55,12 +55,14 @@ int64 get_notification_sound_ringtone_id(const unique_ptr<NotificationSound> &no
|
||||
|
||||
unique_ptr<NotificationSound> get_legacy_notification_sound(const string &sound);
|
||||
|
||||
unique_ptr<NotificationSound> get_notification_sound(telegram_api::NotificationSound *notification_sound);
|
||||
|
||||
unique_ptr<NotificationSound> get_notification_sound(bool use_default_sound, int64 ringtone_id);
|
||||
|
||||
unique_ptr<NotificationSound> get_notification_sound(telegram_api::peerNotifySettings *settings, bool for_stories);
|
||||
|
||||
telegram_api::object_ptr<telegram_api::NotificationSound> get_input_notification_sound(
|
||||
const unique_ptr<NotificationSound> ¬ification_sound);
|
||||
const unique_ptr<NotificationSound> ¬ification_sound, bool return_non_null = false);
|
||||
|
||||
unique_ptr<NotificationSound> dup_notification_sound(const unique_ptr<NotificationSound> ¬ification_sound);
|
||||
|
||||
|
69
td/telegram/ReactionNotificationSettings.cpp
Normal file
69
td/telegram/ReactionNotificationSettings.cpp
Normal file
@ -0,0 +1,69 @@
|
||||
//
|
||||
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2024
|
||||
//
|
||||
// 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/ReactionNotificationSettings.h"
|
||||
|
||||
namespace td {
|
||||
|
||||
ReactionNotificationSettings::ReactionNotificationSettings(
|
||||
td_api::object_ptr<td_api::reactionNotificationSettings> &¬ification_settings) {
|
||||
if (notification_settings == nullptr) {
|
||||
return;
|
||||
}
|
||||
message_reactions_ = ReactionNotificationsFrom(std::move(notification_settings->message_reaction_source_));
|
||||
story_reactions_ = ReactionNotificationsFrom(std::move(notification_settings->story_reaction_source_));
|
||||
sound_ = get_notification_sound(false, notification_settings->sound_id_);
|
||||
show_preview_ = notification_settings->show_preview_;
|
||||
}
|
||||
|
||||
ReactionNotificationSettings::ReactionNotificationSettings(
|
||||
telegram_api::object_ptr<telegram_api::reactionsNotifySettings> &¬ify_settings) {
|
||||
if (notify_settings == nullptr) {
|
||||
return;
|
||||
}
|
||||
message_reactions_ = ReactionNotificationsFrom(std::move(notify_settings->messages_notify_from_));
|
||||
story_reactions_ = ReactionNotificationsFrom(std::move(notify_settings->stories_notify_from_));
|
||||
sound_ = get_notification_sound(notify_settings->sound_.get());
|
||||
show_preview_ = notify_settings->show_previews_;
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::reactionNotificationSettings>
|
||||
ReactionNotificationSettings::get_reaction_notification_settings_object() const {
|
||||
return td_api::make_object<td_api::reactionNotificationSettings>(
|
||||
message_reactions_.get_reaction_notification_source_object(),
|
||||
story_reactions_.get_reaction_notification_source_object(), get_notification_sound_ringtone_id(sound_),
|
||||
show_preview_);
|
||||
}
|
||||
|
||||
telegram_api::object_ptr<telegram_api::reactionsNotifySettings>
|
||||
ReactionNotificationSettings::get_input_reactions_notify_settings() const {
|
||||
int32 flags = 0;
|
||||
auto messages_notify_from = message_reactions_.get_input_reaction_notifications_from();
|
||||
if (messages_notify_from != nullptr) {
|
||||
flags |= telegram_api::reactionsNotifySettings::MESSAGES_NOTIFY_FROM_MASK;
|
||||
}
|
||||
auto stories_notify_from = story_reactions_.get_input_reaction_notifications_from();
|
||||
if (stories_notify_from != nullptr) {
|
||||
flags |= telegram_api::reactionsNotifySettings::STORIES_NOTIFY_FROM_MASK;
|
||||
}
|
||||
return telegram_api::make_object<telegram_api::reactionsNotifySettings>(
|
||||
flags, std::move(messages_notify_from), std::move(stories_notify_from),
|
||||
get_input_notification_sound(sound_, true), show_preview_);
|
||||
}
|
||||
|
||||
bool operator==(const ReactionNotificationSettings &lhs, const ReactionNotificationSettings &rhs) {
|
||||
return lhs.message_reactions_ == rhs.message_reactions_ && lhs.story_reactions_ == rhs.story_reactions_ &&
|
||||
are_equivalent_notification_sounds(lhs.sound_, rhs.sound_) && lhs.show_preview_ == rhs.show_preview_;
|
||||
}
|
||||
|
||||
StringBuilder &operator<<(StringBuilder &string_builder, const ReactionNotificationSettings ¬ification_settings) {
|
||||
return string_builder << "ReactionNotificationSettings[messages: " << notification_settings.message_reactions_
|
||||
<< ", stories: " << notification_settings.story_reactions_
|
||||
<< ", sound: " << notification_settings.sound_
|
||||
<< ", show_preview: " << notification_settings.show_preview_ << ']';
|
||||
}
|
||||
|
||||
} // namespace td
|
59
td/telegram/ReactionNotificationSettings.h
Normal file
59
td/telegram/ReactionNotificationSettings.h
Normal file
@ -0,0 +1,59 @@
|
||||
//
|
||||
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2024
|
||||
//
|
||||
// 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/NotificationSound.h"
|
||||
#include "td/telegram/ReactionNotificationsFrom.h"
|
||||
#include "td/telegram/td_api.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
|
||||
#include "td/utils/common.h"
|
||||
#include "td/utils/Status.h"
|
||||
#include "td/utils/StringBuilder.h"
|
||||
|
||||
namespace td {
|
||||
|
||||
class ReactionNotificationSettings {
|
||||
ReactionNotificationsFrom message_reactions_;
|
||||
ReactionNotificationsFrom story_reactions_;
|
||||
unique_ptr<NotificationSound> sound_;
|
||||
bool show_preview_ = true;
|
||||
|
||||
friend bool operator==(const ReactionNotificationSettings &lhs, const ReactionNotificationSettings &rhs);
|
||||
|
||||
friend StringBuilder &operator<<(StringBuilder &string_builder,
|
||||
const ReactionNotificationSettings ¬ification_settings);
|
||||
|
||||
public:
|
||||
ReactionNotificationSettings() = default;
|
||||
|
||||
explicit ReactionNotificationSettings(
|
||||
td_api::object_ptr<td_api::reactionNotificationSettings> &¬ification_settings);
|
||||
|
||||
explicit ReactionNotificationSettings(
|
||||
telegram_api::object_ptr<telegram_api::reactionsNotifySettings> &¬ify_settings);
|
||||
|
||||
td_api::object_ptr<td_api::reactionNotificationSettings> get_reaction_notification_settings_object() const;
|
||||
|
||||
telegram_api::object_ptr<telegram_api::reactionsNotifySettings> get_input_reactions_notify_settings() const;
|
||||
|
||||
template <class StorerT>
|
||||
void store(StorerT &storer) const;
|
||||
|
||||
template <class ParserT>
|
||||
void parse(ParserT &parser);
|
||||
};
|
||||
|
||||
bool operator==(const ReactionNotificationSettings &lhs, const ReactionNotificationSettings &rhs);
|
||||
|
||||
inline bool operator!=(const ReactionNotificationSettings &lhs, const ReactionNotificationSettings &rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
StringBuilder &operator<<(StringBuilder &string_builder, const ReactionNotificationSettings ¬ification_settings);
|
||||
|
||||
} // namespace td
|
45
td/telegram/ReactionNotificationSettings.hpp
Normal file
45
td/telegram/ReactionNotificationSettings.hpp
Normal file
@ -0,0 +1,45 @@
|
||||
//
|
||||
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2024
|
||||
//
|
||||
// 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/NotificationSound.h"
|
||||
#include "td/telegram/ReactionNotificationSettings.h"
|
||||
#include "td/telegram/ReactionNotificationsFrom.hpp"
|
||||
|
||||
#include "td/utils/tl_helpers.h"
|
||||
|
||||
namespace td {
|
||||
|
||||
template <class StorerT>
|
||||
void ReactionNotificationSettings::store(StorerT &storer) const {
|
||||
bool has_sound = sound_ != nullptr;
|
||||
BEGIN_STORE_FLAGS();
|
||||
STORE_FLAG(has_sound);
|
||||
STORE_FLAG(show_preview_);
|
||||
END_STORE_FLAGS();
|
||||
td::store(message_reactions_, storer);
|
||||
td::store(story_reactions_, storer);
|
||||
if (has_sound) {
|
||||
td::store(sound_, storer);
|
||||
}
|
||||
}
|
||||
|
||||
template <class ParserT>
|
||||
void ReactionNotificationSettings::parse(ParserT &parser) {
|
||||
bool has_sound;
|
||||
BEGIN_PARSE_FLAGS();
|
||||
PARSE_FLAG(has_sound);
|
||||
PARSE_FLAG(show_preview_);
|
||||
END_PARSE_FLAGS();
|
||||
td::parse(message_reactions_, parser);
|
||||
td::parse(story_reactions_, parser);
|
||||
if (has_sound) {
|
||||
parse_notification_sound(sound_, parser);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace td
|
98
td/telegram/ReactionNotificationsFrom.cpp
Normal file
98
td/telegram/ReactionNotificationsFrom.cpp
Normal file
@ -0,0 +1,98 @@
|
||||
//
|
||||
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2024
|
||||
//
|
||||
// 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/ReactionNotificationsFrom.h"
|
||||
|
||||
namespace td {
|
||||
|
||||
ReactionNotificationsFrom::ReactionNotificationsFrom(
|
||||
td_api::object_ptr<td_api::ReactionNotificationSource> &¬ification_source) {
|
||||
if (notification_source == nullptr) {
|
||||
type_ = Type::None;
|
||||
return;
|
||||
}
|
||||
switch (notification_source->get_id()) {
|
||||
case td_api::reactionNotificationSourceNone::ID:
|
||||
type_ = Type::None;
|
||||
break;
|
||||
case td_api::reactionNotificationSourceContacts::ID:
|
||||
type_ = Type::Contacts;
|
||||
break;
|
||||
case td_api::reactionNotificationSourceAll::ID:
|
||||
type_ = Type::All;
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
ReactionNotificationsFrom::ReactionNotificationsFrom(
|
||||
telegram_api::object_ptr<telegram_api::ReactionNotificationsFrom> &¬ifications_from) {
|
||||
if (notifications_from == nullptr) {
|
||||
type_ = Type::None;
|
||||
return;
|
||||
}
|
||||
switch (notifications_from->get_id()) {
|
||||
case telegram_api::reactionNotificationsFromContacts::ID:
|
||||
type_ = Type::Contacts;
|
||||
break;
|
||||
case telegram_api::reactionNotificationsFromAll::ID:
|
||||
type_ = Type::All;
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::ReactionNotificationSource>
|
||||
ReactionNotificationsFrom::get_reaction_notification_source_object() const {
|
||||
switch (type_) {
|
||||
case Type::None:
|
||||
return td_api::make_object<td_api::reactionNotificationSourceNone>();
|
||||
case Type::Contacts:
|
||||
return td_api::make_object<td_api::reactionNotificationSourceContacts>();
|
||||
case Type::All:
|
||||
return td_api::make_object<td_api::reactionNotificationSourceAll>();
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
telegram_api::object_ptr<telegram_api::ReactionNotificationsFrom>
|
||||
ReactionNotificationsFrom::get_input_reaction_notifications_from() const {
|
||||
switch (type_) {
|
||||
case Type::None:
|
||||
return nullptr;
|
||||
case Type::Contacts:
|
||||
return telegram_api::make_object<telegram_api::reactionNotificationsFromContacts>();
|
||||
case Type::All:
|
||||
return telegram_api::make_object<telegram_api::reactionNotificationsFromAll>();
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
bool operator==(const ReactionNotificationsFrom &lhs, const ReactionNotificationsFrom &rhs) {
|
||||
return lhs.type_ == rhs.type_;
|
||||
}
|
||||
|
||||
StringBuilder &operator<<(StringBuilder &string_builder, const ReactionNotificationsFrom ¬ifications_from) {
|
||||
switch (notifications_from.type_) {
|
||||
case ReactionNotificationsFrom::Type::None:
|
||||
return string_builder << "disabled";
|
||||
case ReactionNotificationsFrom::Type::Contacts:
|
||||
return string_builder << "contacts";
|
||||
case ReactionNotificationsFrom::Type::All:
|
||||
return string_builder << "all";
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return string_builder;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace td
|
52
td/telegram/ReactionNotificationsFrom.h
Normal file
52
td/telegram/ReactionNotificationsFrom.h
Normal file
@ -0,0 +1,52 @@
|
||||
//
|
||||
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2024
|
||||
//
|
||||
// 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/td_api.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
|
||||
#include "td/utils/common.h"
|
||||
#include "td/utils/StringBuilder.h"
|
||||
|
||||
namespace td {
|
||||
|
||||
class ReactionNotificationsFrom {
|
||||
enum class Type : int32 { None, Contacts, All };
|
||||
Type type_ = Type::Contacts;
|
||||
|
||||
friend bool operator==(const ReactionNotificationsFrom &lhs, const ReactionNotificationsFrom &rhs);
|
||||
|
||||
friend StringBuilder &operator<<(StringBuilder &string_builder, const ReactionNotificationsFrom ¬ifications_from);
|
||||
|
||||
public:
|
||||
ReactionNotificationsFrom() = default;
|
||||
|
||||
explicit ReactionNotificationsFrom(td_api::object_ptr<td_api::ReactionNotificationSource> &¬ification_source);
|
||||
|
||||
explicit ReactionNotificationsFrom(
|
||||
telegram_api::object_ptr<telegram_api::ReactionNotificationsFrom> &¬ifications_from);
|
||||
|
||||
td_api::object_ptr<td_api::ReactionNotificationSource> get_reaction_notification_source_object() const;
|
||||
|
||||
telegram_api::object_ptr<telegram_api::ReactionNotificationsFrom> get_input_reaction_notifications_from() const;
|
||||
|
||||
template <class StorerT>
|
||||
void store(StorerT &storer) const;
|
||||
|
||||
template <class ParserT>
|
||||
void parse(ParserT &parser);
|
||||
};
|
||||
|
||||
bool operator==(const ReactionNotificationsFrom &lhs, const ReactionNotificationsFrom &rhs);
|
||||
|
||||
inline bool operator!=(const ReactionNotificationsFrom &lhs, const ReactionNotificationsFrom &rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
StringBuilder &operator<<(StringBuilder &string_builder, const ReactionNotificationsFrom ¬ifications_from);
|
||||
|
||||
} // namespace td
|
29
td/telegram/ReactionNotificationsFrom.hpp
Normal file
29
td/telegram/ReactionNotificationsFrom.hpp
Normal file
@ -0,0 +1,29 @@
|
||||
//
|
||||
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2024
|
||||
//
|
||||
// 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/ReactionNotificationsFrom.h"
|
||||
|
||||
#include "td/utils/tl_helpers.h"
|
||||
|
||||
namespace td {
|
||||
|
||||
template <class StorerT>
|
||||
void ReactionNotificationsFrom::store(StorerT &storer) const {
|
||||
BEGIN_STORE_FLAGS();
|
||||
END_STORE_FLAGS();
|
||||
td::store(type_, storer);
|
||||
}
|
||||
|
||||
template <class ParserT>
|
||||
void ReactionNotificationsFrom::parse(ParserT &parser) {
|
||||
BEGIN_PARSE_FLAGS();
|
||||
END_PARSE_FLAGS();
|
||||
td::parse(type_, parser);
|
||||
}
|
||||
|
||||
} // namespace td
|
Loading…
Reference in New Issue
Block a user