Add td_api::suggestedActionConvertToBroadcastGroup.
This commit is contained in:
parent
a14c9071f1
commit
b67bafb23c
@ -3153,6 +3153,9 @@ suggestedActionCheckPhoneNumber = SuggestedAction;
|
||||
//@description Suggests the user to see a hint about meaning of one and two ticks on sent message
|
||||
suggestedActionSeeTicksHint = SuggestedAction;
|
||||
|
||||
//@description Suggests the user to convert specified supergroup to a broadcast group @supergroup_id Supergroup identifier
|
||||
suggestedActionConvertToBroadcastGroup supergroup_id:int32 = SuggestedAction;
|
||||
|
||||
|
||||
//@description Contains a counter @count Count
|
||||
count count:int32 = Count;
|
||||
|
Binary file not shown.
@ -11,6 +11,7 @@
|
||||
#include "td/telegram/telegram_api.hpp"
|
||||
|
||||
#include "td/telegram/AuthManager.h"
|
||||
#include "td/telegram/ConfigManager.h"
|
||||
#include "td/telegram/ConfigShared.h"
|
||||
#include "td/telegram/Dependencies.h"
|
||||
#include "td/telegram/DeviceTokenManager.h"
|
||||
@ -7438,6 +7439,14 @@ void ContactsManager::remove_inactive_channel(ChannelId channel_id) {
|
||||
}
|
||||
}
|
||||
|
||||
void ContactsManager::dismiss_suggested_action(SuggestedAction action, Promise<Unit> &&promise) {
|
||||
if (!action.dialog_id_.is_valid()) {
|
||||
send_closure_later(G()->config_manager(), &ConfigManager::dismiss_suggested_action, std::move(action),
|
||||
std::move(promise));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void ContactsManager::on_imported_contacts(int64 random_id, vector<UserId> imported_contact_user_ids,
|
||||
vector<int32> unimported_contact_invites) {
|
||||
LOG(INFO) << "Contacts import with random_id " << random_id
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "td/telegram/RestrictionReason.h"
|
||||
#include "td/telegram/SecretChatId.h"
|
||||
#include "td/telegram/StickerSetId.h"
|
||||
#include "td/telegram/SuggestedAction.h"
|
||||
#include "td/telegram/UserId.h"
|
||||
|
||||
#include "td/actor/actor.h"
|
||||
@ -429,6 +430,8 @@ class ContactsManager : public Actor {
|
||||
|
||||
vector<DialogId> get_inactive_channels(Promise<Unit> &&promise);
|
||||
|
||||
void dismiss_suggested_action(SuggestedAction action, Promise<Unit> &&promise);
|
||||
|
||||
bool is_user_contact(UserId user_id, bool is_mutual = false) const;
|
||||
|
||||
bool is_user_deleted(UserId user_id) const;
|
||||
|
@ -6,6 +6,8 @@
|
||||
//
|
||||
#include "td/telegram/SuggestedAction.h"
|
||||
|
||||
#include "td/telegram/ChannelId.h"
|
||||
|
||||
#include "td/utils/algorithm.h"
|
||||
|
||||
namespace td {
|
||||
@ -22,11 +24,19 @@ SuggestedAction::SuggestedAction(Slice action_str) {
|
||||
}
|
||||
}
|
||||
|
||||
SuggestedAction::SuggestedAction(const td_api::object_ptr<td_api::SuggestedAction> &action_object) {
|
||||
if (action_object == nullptr) {
|
||||
SuggestedAction::SuggestedAction(Slice action_str, DialogId dialog_id) {
|
||||
CHECK(dialog_id.is_valid());
|
||||
if (action_str == Slice("CONVERT_GIGAGROUP")) {
|
||||
type_ = Type::ConvertToGigagroup;
|
||||
dialog_id_ = dialog_id;
|
||||
}
|
||||
}
|
||||
|
||||
SuggestedAction::SuggestedAction(const td_api::object_ptr<td_api::SuggestedAction> &suggested_action) {
|
||||
if (suggested_action == nullptr) {
|
||||
return;
|
||||
}
|
||||
switch (action_object->get_id()) {
|
||||
switch (suggested_action->get_id()) {
|
||||
case td_api::suggestedActionEnableArchiveAndMuteNewChats::ID:
|
||||
init(Type::EnableArchiveAndMuteNewChats);
|
||||
break;
|
||||
@ -36,6 +46,12 @@ SuggestedAction::SuggestedAction(const td_api::object_ptr<td_api::SuggestedActio
|
||||
case td_api::suggestedActionSeeTicksHint::ID:
|
||||
init(Type::SeeTicksHint);
|
||||
break;
|
||||
case td_api::suggestedActionConvertToBroadcastGroup::ID: {
|
||||
auto action = static_cast<const td_api::suggestedActionConvertToBroadcastGroup *>(suggested_action.get());
|
||||
type_ = Type::ConvertToGigagroup;
|
||||
dialog_id_ = DialogId(ChannelId(action->supergroup_id_));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
@ -47,6 +63,8 @@ string SuggestedAction::get_suggested_action_str() const {
|
||||
return "AUTOARCHIVE_POPULAR";
|
||||
case Type::SeeTicksHint:
|
||||
return "NEWCOMER_TICKS";
|
||||
case Type::ConvertToGigagroup:
|
||||
return "CONVERT_GIGAGROUP";
|
||||
default:
|
||||
return string();
|
||||
}
|
||||
@ -62,6 +80,8 @@ td_api::object_ptr<td_api::SuggestedAction> SuggestedAction::get_suggested_actio
|
||||
return td_api::make_object<td_api::suggestedActionCheckPhoneNumber>();
|
||||
case Type::SeeTicksHint:
|
||||
return td_api::make_object<td_api::suggestedActionSeeTicksHint>();
|
||||
case Type::ConvertToGigagroup:
|
||||
return td_api::make_object<td_api::suggestedActionConvertToBroadcastGroup>(dialog_id_.get_channel_id().get());
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return nullptr;
|
||||
|
@ -6,6 +6,7 @@
|
||||
//
|
||||
#pragma once
|
||||
|
||||
#include "td/telegram/DialogId.h"
|
||||
#include "td/telegram/td_api.h"
|
||||
|
||||
#include "td/utils/common.h"
|
||||
@ -14,8 +15,9 @@
|
||||
namespace td {
|
||||
|
||||
struct SuggestedAction {
|
||||
enum class Type : int32 { Empty, EnableArchiveAndMuteNewChats, CheckPhoneNumber, SeeTicksHint };
|
||||
enum class Type : int32 { Empty, EnableArchiveAndMuteNewChats, CheckPhoneNumber, SeeTicksHint, ConvertToGigagroup };
|
||||
Type type_ = Type::Empty;
|
||||
DialogId dialog_id_;
|
||||
|
||||
void init(Type type);
|
||||
|
||||
@ -26,7 +28,9 @@ struct SuggestedAction {
|
||||
|
||||
explicit SuggestedAction(Slice action_str);
|
||||
|
||||
explicit SuggestedAction(const td_api::object_ptr<td_api::SuggestedAction> &action_object);
|
||||
SuggestedAction(Slice action_str, DialogId dialog_id);
|
||||
|
||||
explicit SuggestedAction(const td_api::object_ptr<td_api::SuggestedAction> &suggested_action);
|
||||
|
||||
string get_suggested_action_str() const;
|
||||
|
||||
|
@ -7530,8 +7530,7 @@ void Td::on_request(uint64 id, td_api::stopPoll &request) {
|
||||
void Td::on_request(uint64 id, const td_api::hideSuggestedAction &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_OK_REQUEST_PROMISE();
|
||||
send_closure_later(config_manager_, &ConfigManager::dismiss_suggested_action, SuggestedAction(request.action_),
|
||||
std::move(promise));
|
||||
contacts_manager_->dismiss_suggested_action(SuggestedAction(request.action_), std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::getLoginUrlInfo &request) {
|
||||
|
@ -568,13 +568,17 @@ class CliClient final : public Actor {
|
||||
return result;
|
||||
}
|
||||
|
||||
int32 as_supergroup_id(Slice str) {
|
||||
int32 as_supergroup_id(Slice str) const {
|
||||
str = trim(str);
|
||||
if (str[0] == '@') {
|
||||
str.remove_prefix(1);
|
||||
}
|
||||
if (is_alpha(str[0])) {
|
||||
return username_to_supergroup_id_[to_lower(str)];
|
||||
auto it = username_to_supergroup_id_.find(to_lower(str));
|
||||
if (it == username_to_supergroup_id_.end()) {
|
||||
return 0;
|
||||
}
|
||||
return it->second;
|
||||
}
|
||||
auto result = to_integer<int64>(str);
|
||||
int64 shift = static_cast<int64>(-1000000000000ll);
|
||||
@ -1374,7 +1378,7 @@ class CliClient final : public Actor {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static td_api::object_ptr<td_api::SuggestedAction> as_suggested_action(Slice action) {
|
||||
td_api::object_ptr<td_api::SuggestedAction> as_suggested_action(Slice action) const {
|
||||
if (action == "unarchive") {
|
||||
return td_api::make_object<td_api::suggestedActionEnableArchiveAndMuteNewChats>();
|
||||
}
|
||||
@ -1384,6 +1388,9 @@ class CliClient final : public Actor {
|
||||
if (action == "ticks") {
|
||||
return td_api::make_object<td_api::suggestedActionSeeTicksHint>();
|
||||
}
|
||||
if (begins_with(action, "giga")) {
|
||||
return td_api::make_object<td_api::suggestedActionConvertToBroadcastGroup>(as_supergroup_id(action.substr(4)));
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user