Remove class AvailableReactionType.
This commit is contained in:
parent
81159edcd9
commit
ac5e8e7eda
@ -289,7 +289,6 @@ set(TDLIB_SOURCE
|
||||
td/telegram/AudiosManager.cpp
|
||||
td/telegram/AuthManager.cpp
|
||||
td/telegram/AutoDownloadSettings.cpp
|
||||
td/telegram/AvailableReaction.cpp
|
||||
td/telegram/BackgroundManager.cpp
|
||||
td/telegram/BackgroundType.cpp
|
||||
td/telegram/BotCommand.cpp
|
||||
@ -493,7 +492,6 @@ set(TDLIB_SOURCE
|
||||
td/telegram/AudiosManager.h
|
||||
td/telegram/AuthManager.h
|
||||
td/telegram/AutoDownloadSettings.h
|
||||
td/telegram/AvailableReaction.h
|
||||
td/telegram/BackgroundId.h
|
||||
td/telegram/BackgroundManager.h
|
||||
td/telegram/BackgroundType.h
|
||||
|
@ -1,23 +0,0 @@
|
||||
//
|
||||
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
|
||||
//
|
||||
// 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/AvailableReaction.h"
|
||||
|
||||
#include "td/utils/algorithm.h"
|
||||
|
||||
namespace td {
|
||||
|
||||
AvailableReactionType get_reaction_type(const vector<string> &available_reactions, const string &reaction) {
|
||||
if (reaction[0] == '#') {
|
||||
return AvailableReactionType::NeedsPremium;
|
||||
}
|
||||
if (contains(available_reactions, reaction)) {
|
||||
return AvailableReactionType::Available;
|
||||
}
|
||||
return AvailableReactionType::Unavailable;
|
||||
}
|
||||
|
||||
} // namespace td
|
@ -1,20 +0,0 @@
|
||||
//
|
||||
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
|
||||
//
|
||||
// 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/ChatReactions.h"
|
||||
#include "td/telegram/td_api.h"
|
||||
|
||||
#include "td/utils/common.h"
|
||||
|
||||
namespace td {
|
||||
|
||||
enum class AvailableReactionType : int32 { Unavailable, Available, NeedsPremium };
|
||||
|
||||
AvailableReactionType get_reaction_type(const vector<string> &reactions, const string &reaction);
|
||||
|
||||
} // namespace td
|
@ -7,7 +7,6 @@
|
||||
#include "td/telegram/MessagesManager.h"
|
||||
|
||||
#include "td/telegram/AuthManager.h"
|
||||
#include "td/telegram/AvailableReaction.h"
|
||||
#include "td/telegram/ChainId.h"
|
||||
#include "td/telegram/ChannelType.h"
|
||||
#include "td/telegram/ChatId.h"
|
||||
@ -24508,10 +24507,8 @@ vector<string> MessagesManager::get_message_available_reactions(const Dialog *d,
|
||||
}
|
||||
if (m->reactions != nullptr) {
|
||||
for (const auto &reaction : m->reactions->reactions_) {
|
||||
if (reaction.is_chosen() &&
|
||||
get_reaction_type(result, reaction.get_reaction()) == AvailableReactionType::Unavailable) {
|
||||
CHECK(!can_use_reactions ||
|
||||
get_reaction_type(active_reactions_, reaction.get_reaction()) == AvailableReactionType::Unavailable);
|
||||
if (reaction.is_chosen() && !td::contains(result, reaction.get_reaction())) {
|
||||
CHECK(!can_use_reactions || !td::contains(active_reactions_, reaction.get_reaction()));
|
||||
result.push_back(reaction.get_reaction());
|
||||
}
|
||||
}
|
||||
@ -24532,15 +24529,9 @@ void MessagesManager::set_message_reaction(FullMessageId full_message_id, string
|
||||
return promise.set_error(Status::Error(400, "Message not found"));
|
||||
}
|
||||
|
||||
if (!reaction.empty()) {
|
||||
auto reaction_type = get_reaction_type(get_message_available_reactions(d, m), reaction);
|
||||
if (reaction_type == AvailableReactionType::Unavailable) {
|
||||
if (!reaction.empty() && !td::contains(get_message_available_reactions(d, m), reaction)) {
|
||||
return promise.set_error(Status::Error(400, "The reaction isn't available for the message"));
|
||||
}
|
||||
if (reaction_type == AvailableReactionType::NeedsPremium) {
|
||||
return promise.set_error(Status::Error(400, "The reaction is available only for Telegram Premium users"));
|
||||
}
|
||||
}
|
||||
|
||||
bool can_get_added_reactions = !is_broadcast_channel(dialog_id) && dialog_id.get_type() != DialogType::User &&
|
||||
!is_discussion_message(dialog_id, m);
|
||||
|
Loading…
Reference in New Issue
Block a user