Remove class AvailableReactionType.

This commit is contained in:
levlam 2022-09-08 18:25:12 +03:00
parent 81159edcd9
commit ac5e8e7eda
4 changed files with 4 additions and 58 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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,14 +24529,8 @@ 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) {
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"));
}
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"));
}
bool can_get_added_reactions = !is_broadcast_channel(dialog_id) && dialog_id.get_type() != DialogType::User &&