Add td_api::toggleUserStoriesAreArchived.
This commit is contained in:
parent
3adf6294dc
commit
11c353dc7f
@ -7202,6 +7202,9 @@ toggleStoryIsPinned story_id:int32 is_pinned:Bool = Ok;
|
||||
//@description Deletes a previously sent story @story_id Identifier of the story to delete
|
||||
deleteStory story_id:int32 = Ok;
|
||||
|
||||
//@description Toggles whether stories of the user are available on the main chat list @user_id Identifier of the user @are_archived Pass true to make the story unavailable on the main chat list; pass false to make them available
|
||||
toggleUserStoriesAreArchived user_id:int53 are_archived:Bool = Ok;
|
||||
|
||||
//@description Returns the list of pinned stories of a given user. The stories are returned in a reverse chronological order (i.e., in order of decreasing story_id).
|
||||
//-For optimal performance, the number of returned stories is chosen by TDLib
|
||||
//@user_id User identifier
|
||||
|
@ -10348,11 +10348,13 @@ void ContactsManager::on_get_user(tl_object_ptr<telegram_api::User> &&user_ptr,
|
||||
LOG(DEBUG) << "Info has changed for " << user_id;
|
||||
u->is_changed = true;
|
||||
}
|
||||
if (is_received && (attach_menu_enabled != u->attach_menu_enabled || stories_hidden != u->stories_hidden)) {
|
||||
if (is_received && attach_menu_enabled != u->attach_menu_enabled) {
|
||||
u->attach_menu_enabled = attach_menu_enabled;
|
||||
u->stories_hidden = stories_hidden;
|
||||
u->is_changed = true;
|
||||
}
|
||||
if (is_received) {
|
||||
on_update_user_stories_hidden(u, user_id, stories_hidden);
|
||||
}
|
||||
if (is_premium != u->is_premium) {
|
||||
u->is_premium = is_premium;
|
||||
u->is_changed = true;
|
||||
@ -13403,6 +13405,30 @@ void ContactsManager::on_update_user_emoji_status(User *u, UserId user_id, Emoji
|
||||
}
|
||||
}
|
||||
|
||||
void ContactsManager::on_update_user_stories_hidden(UserId user_id, bool stories_hidden) {
|
||||
if (!user_id.is_valid()) {
|
||||
LOG(ERROR) << "Receive invalid " << user_id;
|
||||
return;
|
||||
}
|
||||
|
||||
User *u = get_user_force(user_id);
|
||||
if (u != nullptr) {
|
||||
on_update_user_stories_hidden(u, user_id, stories_hidden);
|
||||
update_user(u, user_id);
|
||||
} else {
|
||||
LOG(INFO) << "Ignore update user stories are archived about unknown " << user_id;
|
||||
}
|
||||
}
|
||||
|
||||
void ContactsManager::on_update_user_stories_hidden(User *u, UserId user_id, bool stories_hidden) {
|
||||
if (u->stories_hidden != stories_hidden) {
|
||||
LOG(DEBUG) << "Change stories are archived of " << user_id << " from " << u->stories_hidden << " to "
|
||||
<< stories_hidden;
|
||||
u->stories_hidden = stories_hidden;
|
||||
u->is_changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
void ContactsManager::on_update_user_is_contact(User *u, UserId user_id, bool is_contact, bool is_mutual_contact,
|
||||
bool is_close_friend) {
|
||||
UserId my_id = get_my_id();
|
||||
|
@ -184,6 +184,7 @@ class ContactsManager final : public Actor {
|
||||
void on_update_user_name(UserId user_id, string &&first_name, string &&last_name, Usernames &&usernames);
|
||||
void on_update_user_phone_number(UserId user_id, string &&phone_number);
|
||||
void on_update_user_emoji_status(UserId user_id, tl_object_ptr<telegram_api::EmojiStatus> &&emoji_status);
|
||||
void on_update_user_stories_hidden(UserId user_id, bool stories_hidden);
|
||||
void on_update_user_online(UserId user_id, tl_object_ptr<telegram_api::UserStatus> &&status);
|
||||
void on_update_user_local_was_online(UserId user_id, int32 local_was_online);
|
||||
void on_update_user_is_blocked(UserId user_id, bool is_blocked);
|
||||
@ -1387,6 +1388,7 @@ class ContactsManager final : public Actor {
|
||||
void on_update_user_photo(User *u, UserId user_id, tl_object_ptr<telegram_api::UserProfilePhoto> &&photo,
|
||||
const char *source);
|
||||
void on_update_user_emoji_status(User *u, UserId user_id, EmojiStatus emoji_status);
|
||||
void on_update_user_stories_hidden(User *u, UserId user_id, bool stories_hidden);
|
||||
void on_update_user_is_contact(User *u, UserId user_id, bool is_contact, bool is_mutual_contact,
|
||||
bool is_close_friend);
|
||||
void on_update_user_online(User *u, UserId user_id, tl_object_ptr<telegram_api::UserStatus> &&status);
|
||||
|
@ -31,6 +31,45 @@
|
||||
|
||||
namespace td {
|
||||
|
||||
class ToggleStoriesHiddenQuery final : public Td::ResultHandler {
|
||||
Promise<Unit> promise_;
|
||||
UserId user_id_;
|
||||
bool are_hidden_ = false;
|
||||
|
||||
public:
|
||||
explicit ToggleStoriesHiddenQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
|
||||
}
|
||||
|
||||
void send(UserId user_id, bool are_hidden) {
|
||||
user_id_ = user_id;
|
||||
are_hidden_ = are_hidden;
|
||||
auto r_input_user = td_->contacts_manager_->get_input_user(user_id_);
|
||||
if (r_input_user.is_error()) {
|
||||
return on_error(r_input_user.move_as_error());
|
||||
}
|
||||
send_query(G()->net_query_creator().create(
|
||||
telegram_api::contacts_toggleStoriesHidden(r_input_user.move_as_ok(), are_hidden)));
|
||||
}
|
||||
|
||||
void on_result(BufferSlice packet) final {
|
||||
auto result_ptr = fetch_result<telegram_api::contacts_toggleStoriesHidden>(packet);
|
||||
if (result_ptr.is_error()) {
|
||||
return on_error(result_ptr.move_as_error());
|
||||
}
|
||||
|
||||
auto result = result_ptr.move_as_ok();
|
||||
LOG(DEBUG) << "Receive result for ToggleStoriesHiddenQuery: " << result;
|
||||
if (result) {
|
||||
td_->contacts_manager_->on_update_user_stories_hidden(user_id_, are_hidden_);
|
||||
}
|
||||
promise_.set_value(Unit());
|
||||
}
|
||||
|
||||
void on_error(Status status) final {
|
||||
promise_.set_error(std::move(status));
|
||||
}
|
||||
};
|
||||
|
||||
class GetStoriesByIDQuery final : public Td::ResultHandler {
|
||||
Promise<Unit> promise_;
|
||||
UserId user_id_;
|
||||
@ -402,6 +441,20 @@ StoryManager::Story *StoryManager::get_story_editable(StoryFullId story_full_id)
|
||||
return stories_.get_pointer(story_full_id);
|
||||
}
|
||||
|
||||
void StoryManager::toggle_dialog_stories_hidden(DialogId dialog_id, bool are_hidden, Promise<Unit> &&promise) {
|
||||
if (!td_->messages_manager_->have_dialog_info_force(dialog_id)) {
|
||||
return promise.set_error(Status::Error(400, "Story sender not found"));
|
||||
}
|
||||
if (!td_->messages_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
|
||||
return promise.set_error(Status::Error(400, "Can't access the story sender"));
|
||||
}
|
||||
if (dialog_id.get_type() != DialogType::User) {
|
||||
return promise.set_error(Status::Error(400, "Can't archive sender stories"));
|
||||
}
|
||||
|
||||
td_->create_handler<ToggleStoriesHiddenQuery>(std::move(promise))->send(dialog_id.get_user_id(), are_hidden);
|
||||
}
|
||||
|
||||
void StoryManager::get_dialog_pinned_stories(DialogId owner_dialog_id, StoryId from_story_id, int32 limit,
|
||||
Promise<td_api::object_ptr<td_api::stories>> &&promise) {
|
||||
if (limit <= 0) {
|
||||
|
@ -92,6 +92,8 @@ class StoryManager final : public Actor {
|
||||
|
||||
void delete_story(StoryId story_id, Promise<Unit> &&promise);
|
||||
|
||||
void toggle_dialog_stories_hidden(DialogId dialog_id, bool are_hidden, Promise<Unit> &&promise);
|
||||
|
||||
void get_dialog_pinned_stories(DialogId owner_dialog_id, StoryId from_story_id, int32 limit,
|
||||
Promise<td_api::object_ptr<td_api::stories>> &&promise);
|
||||
|
||||
|
@ -5652,6 +5652,13 @@ void Td::on_request(uint64 id, const td_api::deleteStory &request) {
|
||||
story_manager_->delete_story(StoryId(request.story_id_), std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::toggleUserStoriesAreArchived &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_OK_REQUEST_PROMISE();
|
||||
story_manager_->toggle_dialog_stories_hidden(DialogId(UserId(request.user_id_)), request.are_archived_,
|
||||
std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::getForumTopicDefaultIcons &request) {
|
||||
CREATE_REQUEST_PROMISE();
|
||||
stickers_manager_->get_default_topic_icons(false, std::move(promise));
|
||||
|
@ -796,6 +796,8 @@ class Td final : public Actor {
|
||||
|
||||
void on_request(uint64 id, const td_api::deleteStory &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::toggleUserStoriesAreArchived &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::getForumTopicDefaultIcons &request);
|
||||
|
||||
void on_request(uint64 id, td_api::createForumTopic &request);
|
||||
|
@ -3998,6 +3998,11 @@ class CliClient final : public Actor {
|
||||
StoryId story_id;
|
||||
get_args(args, story_id);
|
||||
send_request(td_api::make_object<td_api::deleteStory>(story_id));
|
||||
} else if (op == "tusaa") {
|
||||
UserId user_id;
|
||||
bool are_archived;
|
||||
get_args(args, user_id, are_archived);
|
||||
send_request(td_api::make_object<td_api::toggleUserStoriesAreArchived>(user_id, are_archived));
|
||||
} else if (op == "gups") {
|
||||
UserId user_id;
|
||||
StoryId from_story_id;
|
||||
|
Loading…
Reference in New Issue
Block a user