Use Chat as owner of stories in td_api.

This commit is contained in:
levlam 2023-06-27 21:51:36 +03:00
parent 34161cd627
commit d3e0372b14
9 changed files with 88 additions and 100 deletions

View File

@ -1137,8 +1137,8 @@ messageSendingStateFailed error_code:int32 error_message:string can_retry:Bool n
//@message_id The identifier of the replied message //@message_id The identifier of the replied message
messageReplyToMessage chat_id:int53 message_id:int53 = MessageReplyTo; messageReplyToMessage chat_id:int53 message_id:int53 = MessageReplyTo;
//@description Describes a replied story @story_sender_user_id The identifier of the sender of the replied story. Currently, stories can be replied only in the corresponding private chats @story_id The identifier of the replied story //@description Describes a replied story @story_sender_chat_id The identifier of the sender of the replied story. Currently, stories can be replied only in the sender's chat @story_id The identifier of the replied story
messageReplyToStory story_sender_user_id:int53 story_id:int32 = MessageReplyTo; messageReplyToStory story_sender_chat_id:int53 story_id:int32 = MessageReplyTo;
//@description Describes a message //@description Describes a message
@ -1993,10 +1993,10 @@ webPageInstantView page_blocks:vector<PageBlock> view_count:int32 version:int32
//@video Preview of the content as a video, if available; may be null //@video Preview of the content as a video, if available; may be null
//@video_note Preview of the content as a video note, if available; may be null //@video_note Preview of the content as a video note, if available; may be null
//@voice_note Preview of the content as a voice note, if available; may be null //@voice_note Preview of the content as a voice note, if available; may be null
//@story_sender_user_id The identifier of the sender of the previewed story; 0 if none //@story_sender_chat_id The identifier of the sender of the previewed story; 0 if none
//@story_id The identifier of the previewed story; 0 if none //@story_id The identifier of the previewed story; 0 if none
//@instant_view_version Version of web page instant view (currently, can be 1 or 2); 0 if none //@instant_view_version Version of web page instant view (currently, can be 1 or 2); 0 if none
webPage url:string display_url:string type:string site_name:string title:string description:formattedText photo:photo embed_url:string embed_type:string embed_width:int32 embed_height:int32 duration:int32 author:string animation:animation audio:audio document:document sticker:sticker video:video video_note:videoNote voice_note:voiceNote story_sender_user_id:int53 story_id:int32 instant_view_version:int32 = WebPage; webPage url:string display_url:string type:string site_name:string title:string description:formattedText photo:photo embed_url:string embed_type:string embed_width:int32 embed_height:int32 duration:int32 author:string animation:animation audio:audio document:document sticker:sticker video:video video_note:videoNote voice_note:voiceNote story_sender_chat_id:int53 story_id:int32 instant_view_version:int32 = WebPage;
//@description Contains information about a country //@description Contains information about a country
@ -2543,10 +2543,10 @@ messageGame game:game = MessageContent;
messagePoll poll:poll = MessageContent; messagePoll poll:poll = MessageContent;
//@description A message with a forwarded story //@description A message with a forwarded story
//@story_sender_user_id Identifier of the user that created the story //@story_sender_chat_id Identifier of the chat that posted the story
//@story_id Story identifier //@story_id Story identifier
//@via_mention True, if the story was forwarded because of a mention of the user //@via_mention True, if the story was automatically forwarded because of a mention of the user
messageStory story_sender_user_id:int53 story_id:int32 via_mention:Bool = MessageContent; messageStory story_sender_chat_id:int53 story_id:int32 via_mention:Bool = MessageContent;
//@description A message with an invoice from a bot. Use getInternalLink with internalLinkTypeBotStart to share the invoice //@description A message with an invoice from a bot. Use getInternalLink with internalLinkTypeBotStart to share the invoice
//@title Product title //@title Product title
@ -2934,10 +2934,10 @@ inputMessageInvoice invoice:invoice title:string description:string photo_url:st
//@is_closed True, if the poll needs to be sent already closed; for bots only //@is_closed True, if the poll needs to be sent already closed; for bots only
inputMessagePoll question:string options:vector<string> is_anonymous:Bool type:PollType open_period:int32 close_date:int32 is_closed:Bool = InputMessageContent; inputMessagePoll question:string options:vector<string> is_anonymous:Bool type:PollType open_period:int32 close_date:int32 is_closed:Bool = InputMessageContent;
//@description A message with a forwarded story. Stories can't be sent to secret chats. A story can be forwarded only story.can_be_forwarded //@description A message with a forwarded story. Stories can't be sent to secret chats. A story can be forwarded only if story.can_be_forwarded
//@story_sender_user_id Identifier of the user that created the story //@story_sender_chat_id Identifier of the chat that posted the story
//@story_id Story identifier //@story_id Story identifier
inputMessageStory story_sender_user_id:int53 story_id:int32 = InputMessageContent; inputMessageStory story_sender_chat_id:int53 story_id:int32 = InputMessageContent;
//@description A forwarded message //@description A forwarded message
//@from_chat_id Identifier for the chat this forwarded message came from //@from_chat_id Identifier for the chat this forwarded message came from
@ -4829,10 +4829,10 @@ internalLinkTypeSettings = InternalLinkType;
//@expect_custom_emoji True, if the sticker set is expected to contain custom emoji //@expect_custom_emoji True, if the sticker set is expected to contain custom emoji
internalLinkTypeStickerSet sticker_set_name:string expect_custom_emoji:Bool = InternalLinkType; internalLinkTypeStickerSet sticker_set_name:string expect_custom_emoji:Bool = InternalLinkType;
//@description The link is a link to a story. Call searchPublicChat with the given sender username, check that a user is returned, then call getStory with the received user identifier and the given story identifier //@description The link is a link to a story. Call searchPublicChat with the given sender username, then call getStory with the received chat identifier and the given story identifier
//@sender_username Username of the sender of the story //@story_sender_username Username of the sender of the story
//@story_id Story identifier //@story_id Story identifier
internalLinkTypeStory sender_username:string story_id:int32 = InternalLinkType; internalLinkTypeStory story_sender_username:string story_id:int32 = InternalLinkType;
//@description The link is a link to a theme. TDLib has no theme support yet @theme_name Name of the theme //@description The link is a link to a theme. TDLib has no theme support yet @theme_name Name of the theme
internalLinkTypeTheme theme_name:string = InternalLinkType; internalLinkTypeTheme theme_name:string = InternalLinkType;
@ -4926,18 +4926,18 @@ storyInteractionInfo view_count:int32 recent_viewer_user_ids:vector<int53> = Sto
//@description Represents a story //@description Represents a story
//@id Unique story identifier among stories of the given sender //@id Unique story identifier among stories of the given sender
//@sender_user_id Identifier of the user that created the story //@sender_chat_id Identifier of the chat that posted the story
//@date Point in time (Unix timestamp) when the story was published //@date Point in time (Unix timestamp) when the story was published
//@is_pinned True, if the story is saved in the sender's profile and will be available there after expiration //@is_pinned True, if the story is saved in the sender's profile and will be available there after expiration
//@is_visible_only_for_self True, if the story is visible only for the current user //@is_visible_only_for_self True, if the story is visible only for the current user
//@can_be_forwarded True, if the story can be forwarded as a message. Otherwise, screenshots and saving of the story content must be also forbidden //@can_be_forwarded True, if the story can be forwarded as a message. Otherwise, screenshots and saving of the story content must be also forbidden
//@can_be_replied True, if the story can be replied in the chat with the story sender //@can_be_replied True, if the story can be replied in the chat with the story sender
//@can_get_viewers True, users viewed the story can be received through getStoryViewers //@can_get_viewers True, if users viewed the story can be received through getStoryViewers
//@interaction_info Information about interactions with the story; may be null if the story isn't owned or there were no interactions //@interaction_info Information about interactions with the story; may be null if the story isn't owned or there were no interactions
//@privacy_rules Privacy rules affecting story visibility; may be null if the story isn't owned //@privacy_rules Privacy rules affecting story visibility; may be null if the story isn't owned
//@content Content of the story //@content Content of the story
//@caption Caption of the story //@caption Caption of the story
story id:int32 sender_user_id:int53 date:int32 is_pinned:Bool is_visible_only_for_self:Bool can_be_forwarded:Bool can_be_replied:Bool can_get_viewers:Bool interaction_info:storyInteractionInfo privacy_rules:userPrivacySettingRules content:StoryContent caption:formattedText = Story; story id:int32 sender_chat_id:int53 date:int32 is_pinned:Bool is_visible_only_for_self:Bool can_be_forwarded:Bool can_be_replied:Bool can_get_viewers:Bool interaction_info:storyInteractionInfo privacy_rules:userPrivacySettingRules content:StoryContent caption:formattedText = Story;
//@description Represents a list of stories @total_count Approximate total number of stories found @stories The list of stories //@description Represents a list of stories @total_count Approximate total number of stories found @stories The list of stories
stories total_count:int32 stories:vector<story> = Stories; stories total_count:int32 stories:vector<story> = Stories;
@ -4946,10 +4946,10 @@ stories total_count:int32 stories:vector<story> = Stories;
storyInfo story_id:int32 date:int32 = StoryInfo; storyInfo story_id:int32 date:int32 = StoryInfo;
//@description Describes active stories sent by the same sender //@description Describes active stories sent by the same sender
//@story_sender_user_id Identifier of the sender of the stories //@story_sender_chat_id Identifier of the sender of the stories
//@max_read_story_id Identifier of the last read active story //@max_read_story_id Identifier of the last read active story
//@stories Basic information about the stories; use getStory to get full information about the stories //@stories Basic information about the stories; use getStory to get full information about the stories
activeStories story_sender_user_id:int53 max_read_story_id:int32 stories:vector<storyInfo> = ActiveStories; activeStories story_sender_chat_id:int53 max_read_story_id:int32 stories:vector<storyInfo> = ActiveStories;
//@description Contains a part of a file @data File bytes //@description Contains a part of a file @data File bytes
@ -5710,8 +5710,8 @@ updateUnreadChatCount chat_list:ChatList total_count:int32 unread_count:int32 un
//@description A story was changed @story The new information about the story //@description A story was changed @story The new information about the story
updateStory story:story = Update; updateStory story:story = Update;
//@description A story became inaccessible @story_sender_user_id Identifier of the user that created the story @story_id Story identifier //@description A story became inaccessible @story_sender_chat_id Identifier of the chat that posted the story @story_id Story identifier
updateStoryDeleted story_sender_user_id:int53 story_id:int32 = Update; updateStoryDeleted story_sender_chat_id:int53 story_id:int32 = Update;
//@description The list of active stories of a specific sender has changed @active_stories The new list of active stories //@description The list of active stories of a specific sender has changed @active_stories The new list of active stories
updateActiveStories active_stories:activeStories = Update; updateActiveStories active_stories:activeStories = Update;
@ -7242,8 +7242,8 @@ setPinnedChats chat_list:ChatList chat_ids:vector<int53> = Ok;
readChatList chat_list:ChatList = Ok; readChatList chat_list:ChatList = Ok;
//@description Returns a story @user_id Identifier of the user, which sent the story @story_id Story identifier //@description Returns a story @story_sender_chat_id Identifier of the chat that posted the story @story_id Story identifier
getStory user_id:int53 story_id:int32 = Story; getStory story_sender_chat_id:int53 story_id:int32 = Story;
//@description Sends a new story. Returns a temporary story with identifier 0 //@description Sends a new story. Returns a temporary story with identifier 0
//@content Content of the story //@content Content of the story
@ -7291,14 +7291,14 @@ getUserPinnedStories user_id:int53 from_story_id:int32 limit:int32 = Stories;
getArchivedStories from_story_id:int32 limit:int32 = Stories; getArchivedStories from_story_id:int32 limit:int32 = Stories;
//@description Informs TDLib that a story is opened and is being viewed by the user //@description Informs TDLib that a story is opened and is being viewed by the user
//@story_sender_user_id The identifier of the sender of the opened story //@story_sender_chat_id The identifier of the sender of the opened story
//@story_id The identifier of the story //@story_id The identifier of the story
openStory story_sender_user_id:int53 story_id:int32 = Ok; openStory story_sender_chat_id:int53 story_id:int32 = Ok;
//@description Informs TDLib that a story is closed by the user //@description Informs TDLib that a story is closed by the user
//@story_sender_user_id The identifier of the sender of the story to close //@story_sender_chat_id The identifier of the sender of the story to close
//@story_id The identifier of the story //@story_id The identifier of the story
closeStory story_sender_user_id:int53 story_id:int32 = Ok; closeStory story_sender_chat_id:int53 story_id:int32 = Ok;
//@description Returns viewers of a recent outgoing story. The method can be called if story.can_get_viewers == true. The views are returned in a reverse chronological order (i.e., in order of decreasing view_date) //@description Returns viewers of a recent outgoing story. The method can be called if story.can_get_viewers == true. The views are returned in a reverse chronological order (i.e., in order of decreasing view_date)
//-For optimal performance, the number of returned stories is chosen by TDLib //-For optimal performance, the number of returned stories is chosen by TDLib
@ -7309,11 +7309,11 @@ closeStory story_sender_user_id:int53 story_id:int32 = Ok;
getStoryViewers story_id:int32 offset_viewer:messageViewer limit:int32 = MessageViewers; getStoryViewers story_id:int32 offset_viewer:messageViewer limit:int32 = MessageViewers;
//@description Reports a story to the Telegram moderators //@description Reports a story to the Telegram moderators
//@story_sender_user_id The identifier of the sender of the story to report //@story_sender_chat_id The identifier of the sender of the story to report
//@story_id The identifier of the story to report //@story_id The identifier of the story to report
//@reason The reason for reporting the story //@reason The reason for reporting the story
//@text Additional report details; 0-1024 characters //@text Additional report details; 0-1024 characters
reportStory story_sender_user_id:int53 story_id:int32 reason:ReportReason text:string = Ok; reportStory story_sender_chat_id:int53 story_id:int32 reason:ReportReason text:string = Ok;
//@description Returns information about a bot that can be added to attachment menu @bot_user_id Bot's user identifier //@description Returns information about a bot that can be added to attachment menu @bot_user_id Bot's user identifier

View File

@ -612,16 +612,16 @@ class LinkManager::InternalLinkStickerSet final : public InternalLink {
}; };
class LinkManager::InternalLinkStory final : public InternalLink { class LinkManager::InternalLinkStory final : public InternalLink {
string sender_username_; string story_sender_username_;
StoryId story_id_; StoryId story_id_;
td_api::object_ptr<td_api::InternalLinkType> get_internal_link_type_object() const final { td_api::object_ptr<td_api::InternalLinkType> get_internal_link_type_object() const final {
return td_api::make_object<td_api::internalLinkTypeStory>(sender_username_, story_id_.get()); return td_api::make_object<td_api::internalLinkTypeStory>(story_sender_username_, story_id_.get());
} }
public: public:
InternalLinkStory(string sender_username, StoryId story_id) InternalLinkStory(string story_sender_username, StoryId story_id)
: sender_username_(std::move(sender_username)), story_id_(story_id) { : story_sender_username_(std::move(story_sender_username)), story_id_(story_id) {
} }
}; };
@ -2097,16 +2097,16 @@ Result<string> LinkManager::get_internal_link_impl(const td_api::InternalLinkTyp
} }
case td_api::internalLinkTypeStory::ID: { case td_api::internalLinkTypeStory::ID: {
auto link = static_cast<const td_api::internalLinkTypeStory *>(type_ptr); auto link = static_cast<const td_api::internalLinkTypeStory *>(type_ptr);
if (!is_valid_username(link->sender_username_)) { if (!is_valid_username(link->story_sender_username_)) {
return Status::Error(400, "Invalid sender username specified"); return Status::Error(400, "Invalid story sender username specified");
} }
if (!StoryId(link->story_id_).is_server()) { if (!StoryId(link->story_id_).is_server()) {
return Status::Error(400, "Invalid story identifier specified"); return Status::Error(400, "Invalid story identifier specified");
} }
if (is_internal) { if (is_internal) {
return PSTRING() << "tg://resolve?domain=" << link->sender_username_ << "&story=" << link->story_id_; return PSTRING() << "tg://resolve?domain=" << link->story_sender_username_ << "&story=" << link->story_id_;
} else { } else {
return PSTRING() << get_t_me_url() << link->sender_username_ << "/s/" << link->story_id_; return PSTRING() << get_t_me_url() << link->story_sender_username_ << "/s/" << link->story_id_;
} }
} }
case td_api::internalLinkTypeTheme::ID: { case td_api::internalLinkTypeTheme::ID: {

View File

@ -2284,13 +2284,13 @@ static Result<InputMessageContent> create_input_message_content(
} }
case td_api::inputMessageStory::ID: { case td_api::inputMessageStory::ID: {
auto input_story = static_cast<td_api::inputMessageStory *>(input_message_content.get()); auto input_story = static_cast<td_api::inputMessageStory *>(input_message_content.get());
UserId user_id(input_story->story_sender_user_id_); DialogId story_sender_dialog_id(input_story->story_sender_chat_id_);
StoryId story_id(input_story->story_id_); StoryId story_id(input_story->story_id_);
StoryFullId story_full_id(DialogId(user_id), story_id); StoryFullId story_full_id(story_sender_dialog_id, story_id);
if (!td->story_manager_->have_story(story_full_id)) { if (!td->story_manager_->have_story(story_full_id) || story_sender_dialog_id.get_type() != DialogType::User) {
return Status::Error(400, "Story not found"); return Status::Error(400, "Story not found");
} }
if (td->contacts_manager_->get_input_user(user_id).is_error()) { if (td->contacts_manager_->get_input_user(story_sender_dialog_id.get_user_id()).is_error()) {
return Status::Error(400, "Can't access the user"); return Status::Error(400, "Can't access the user");
} }
content = make_unique<MessageStory>(story_full_id, false); content = make_unique<MessageStory>(story_full_id, false);
@ -6006,10 +6006,8 @@ tl_object_ptr<td_api::MessageContent> get_message_content_object(const MessageCo
} }
case MessageContentType::Story: { case MessageContentType::Story: {
const auto *m = static_cast<const MessageStory *>(content); const auto *m = static_cast<const MessageStory *>(content);
auto story_sender_dialog_id = m->story_full_id.get_dialog_id();
CHECK(story_sender_dialog_id.get_type() == DialogType::User);
return td_api::make_object<td_api::messageStory>( return td_api::make_object<td_api::messageStory>(
td->contacts_manager_->get_user_id_object(story_sender_dialog_id.get_user_id(), "messageStory"), td->messages_manager_->get_chat_id_object(m->story_full_id.get_dialog_id(), "messageStory"),
m->story_full_id.get_story_id().get(), m->via_mention); m->story_full_id.get_story_id().get(), m->via_mention);
} }
default: default:
@ -6739,7 +6737,7 @@ void add_message_content_dependencies(Dependencies &dependencies, const MessageC
break; break;
case MessageContentType::Story: { case MessageContentType::Story: {
const auto *content = static_cast<const MessageStory *>(message_content); const auto *content = static_cast<const MessageStory *>(message_content);
dependencies.add_message_sender_dependencies(content->story_full_id.get_dialog_id()); dependencies.add_dialog_and_dependencies(content->story_full_id.get_dialog_id());
break; break;
} }
default: default:

View File

@ -23,7 +23,7 @@ MessageInputReplyTo::MessageInputReplyTo(const td_api::object_ptr<td_api::Messag
} }
case td_api::messageReplyToStory::ID: { case td_api::messageReplyToStory::ID: {
auto reply_to = static_cast<const td_api::messageReplyToStory *>(reply_to_ptr.get()); auto reply_to = static_cast<const td_api::messageReplyToStory *>(reply_to_ptr.get());
story_full_id_ = {DialogId(reply_to->story_sender_user_id_), StoryId(reply_to->story_id_)}; story_full_id_ = {DialogId(reply_to->story_sender_chat_id_), StoryId(reply_to->story_id_)};
break; break;
} }
default: default:

View File

@ -24211,10 +24211,8 @@ tl_object_ptr<td_api::message> MessagesManager::get_message_object(DialogId dial
m->reply_to_message_id.get()); m->reply_to_message_id.get());
} }
if (m->reply_to_story_full_id.get_story_id() != StoryId()) { if (m->reply_to_story_full_id.get_story_id() != StoryId()) {
CHECK(m->reply_to_story_full_id.get_dialog_id().get_type() == DialogType::User);
return td_api::make_object<td_api::messageReplyToStory>( return td_api::make_object<td_api::messageReplyToStory>(
td_->contacts_manager_->get_user_id_object(m->reply_to_story_full_id.get_dialog_id().get_user_id(), get_chat_id_object(m->reply_to_story_full_id.get_dialog_id(), "messageReplyToStory"),
"messageReplyToStory"),
m->reply_to_story_full_id.get_story_id().get()); m->reply_to_story_full_id.get_story_id().get());
} }
return nullptr; return nullptr;
@ -24568,16 +24566,16 @@ MessageInputReplyTo MessagesManager::get_message_input_reply_to(Dialog *d, Messa
CHECK(!for_draft); CHECK(!for_draft);
auto reply_to_story = td_api::move_object_as<td_api::messageReplyToStory>(reply_to); auto reply_to_story = td_api::move_object_as<td_api::messageReplyToStory>(reply_to);
auto story_id = StoryId(reply_to_story->story_id_); auto story_id = StoryId(reply_to_story->story_id_);
auto sender_user_id = UserId(reply_to_story->story_sender_user_id_); auto sender_dialog_id = DialogId(reply_to_story->story_sender_chat_id_);
if (d->dialog_id != DialogId(sender_user_id)) { if (d->dialog_id != sender_dialog_id) {
LOG(INFO) << "Ignore reply to story from " << sender_user_id << " in a wrong " << d->dialog_id; LOG(INFO) << "Ignore reply to story from " << sender_dialog_id << " in a wrong " << d->dialog_id;
return {}; return {};
} }
if (!story_id.is_server()) { if (!story_id.is_server()) {
LOG(INFO) << "Ignore reply to invalid " << story_id; LOG(INFO) << "Ignore reply to invalid " << story_id;
return {}; return {};
} }
return {MessageId(), StoryFullId(DialogId(sender_user_id), story_id)}; return {MessageId(), StoryFullId(sender_dialog_id, story_id)};
} }
MessageId message_id; MessageId message_id;
if (reply_to != nullptr && reply_to->get_id() == td_api::messageReplyToMessage::ID) { if (reply_to != nullptr && reply_to->get_id() == td_api::messageReplyToMessage::ID) {
@ -24787,6 +24785,7 @@ void MessagesManager::add_message_dependencies(Dependencies &dependencies, const
dependencies.add(m->sender_user_id); dependencies.add(m->sender_user_id);
dependencies.add_dialog_and_dependencies(m->sender_dialog_id); dependencies.add_dialog_and_dependencies(m->sender_dialog_id);
dependencies.add_dialog_and_dependencies(m->reply_in_dialog_id); dependencies.add_dialog_and_dependencies(m->reply_in_dialog_id);
dependencies.add_dialog_and_dependencies(m->reply_to_story_full_id.get_dialog_id());
dependencies.add_dialog_and_dependencies(m->real_forward_from_dialog_id); dependencies.add_dialog_and_dependencies(m->real_forward_from_dialog_id);
dependencies.add(m->via_bot_user_id); dependencies.add(m->via_bot_user_id);
if (m->forward_info != nullptr) { if (m->forward_info != nullptr) {

View File

@ -847,7 +847,7 @@ void StoryManager::on_synchronized_archive_all_stories(bool set_archive_all_stor
} }
void StoryManager::toggle_dialog_stories_hidden(DialogId dialog_id, bool are_hidden, Promise<Unit> &&promise) { 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)) { if (!td_->messages_manager_->have_dialog_force(dialog_id, "toggle_dialog_stories_hidden")) {
return promise.set_error(Status::Error(400, "Story sender not found")); return promise.set_error(Status::Error(400, "Story sender not found"));
} }
if (!td_->messages_manager_->have_input_peer(dialog_id, AccessRights::Read)) { if (!td_->messages_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
@ -866,7 +866,7 @@ void StoryManager::get_dialog_pinned_stories(DialogId owner_dialog_id, StoryId f
return promise.set_error(Status::Error(400, "Parameter limit must be positive")); return promise.set_error(Status::Error(400, "Parameter limit must be positive"));
} }
if (!td_->messages_manager_->have_dialog_info_force(owner_dialog_id)) { if (!td_->messages_manager_->have_dialog_force(owner_dialog_id, "get_dialog_pinned_stories")) {
return promise.set_error(Status::Error(400, "Story sender not found")); return promise.set_error(Status::Error(400, "Story sender not found"));
} }
if (!td_->messages_manager_->have_input_peer(owner_dialog_id, AccessRights::Read)) { if (!td_->messages_manager_->have_input_peer(owner_dialog_id, AccessRights::Read)) {
@ -939,7 +939,7 @@ void StoryManager::on_get_story_archive(telegram_api::object_ptr<telegram_api::s
void StoryManager::get_dialog_expiring_stories(DialogId owner_dialog_id, void StoryManager::get_dialog_expiring_stories(DialogId owner_dialog_id,
Promise<td_api::object_ptr<td_api::activeStories>> &&promise) { Promise<td_api::object_ptr<td_api::activeStories>> &&promise) {
if (!td_->messages_manager_->have_dialog_info_force(owner_dialog_id)) { if (!td_->messages_manager_->have_dialog_force(owner_dialog_id, "get_dialog_expiring_stories")) {
return promise.set_error(Status::Error(400, "Story sender not found")); return promise.set_error(Status::Error(400, "Story sender not found"));
} }
if (!td_->messages_manager_->have_input_peer(owner_dialog_id, AccessRights::Read)) { if (!td_->messages_manager_->have_input_peer(owner_dialog_id, AccessRights::Read)) {
@ -977,7 +977,7 @@ void StoryManager::on_get_dialog_expiring_stories(DialogId owner_dialog_id,
} }
void StoryManager::open_story(DialogId owner_dialog_id, StoryId story_id, Promise<Unit> &&promise) { void StoryManager::open_story(DialogId owner_dialog_id, StoryId story_id, Promise<Unit> &&promise) {
if (!td_->messages_manager_->have_dialog_info_force(owner_dialog_id)) { if (!td_->messages_manager_->have_dialog_force(owner_dialog_id, "open_story")) {
return promise.set_error(Status::Error(400, "Story sender not found")); return promise.set_error(Status::Error(400, "Story sender not found"));
} }
if (!td_->messages_manager_->have_input_peer(owner_dialog_id, AccessRights::Read)) { if (!td_->messages_manager_->have_input_peer(owner_dialog_id, AccessRights::Read)) {
@ -1040,7 +1040,7 @@ void StoryManager::open_story(DialogId owner_dialog_id, StoryId story_id, Promis
} }
void StoryManager::close_story(DialogId owner_dialog_id, StoryId story_id, Promise<Unit> &&promise) { void StoryManager::close_story(DialogId owner_dialog_id, StoryId story_id, Promise<Unit> &&promise) {
if (!td_->messages_manager_->have_dialog_info_force(owner_dialog_id)) { if (!td_->messages_manager_->have_dialog_force(owner_dialog_id, "close_story")) {
return promise.set_error(Status::Error(400, "Story sender not found")); return promise.set_error(Status::Error(400, "Story sender not found"));
} }
if (!td_->messages_manager_->have_input_peer(owner_dialog_id, AccessRights::Read)) { if (!td_->messages_manager_->have_input_peer(owner_dialog_id, AccessRights::Read)) {
@ -1421,11 +1421,9 @@ td_api::object_ptr<td_api::story> StoryManager::get_story_object(StoryFullId sto
story->is_update_sent_ = true; story->is_update_sent_ = true;
CHECK(dialog_id.get_type() == DialogType::User);
return td_api::make_object<td_api::story>( return td_api::make_object<td_api::story>(
story_full_id.get_story_id().get(), story_full_id.get_story_id().get(), td_->messages_manager_->get_chat_id_object(dialog_id, "get_story_object"),
td_->contacts_manager_->get_user_id_object(dialog_id.get_user_id(), "get_story_object"), story->date_, story->date_, story->is_pinned_, is_visible_only_for_self, can_be_forwarded, can_be_replied,
story->is_pinned_, is_visible_only_for_self, can_be_forwarded, can_be_replied,
can_get_story_viewers(story_full_id, story).is_ok(), can_get_story_viewers(story_full_id, story).is_ok(),
story->interaction_info_.get_story_interaction_info_object(td_), std::move(privacy_rules), story->interaction_info_.get_story_interaction_info_object(td_), std::move(privacy_rules),
get_story_content_object(td_, content), get_story_content_object(td_, content),
@ -1455,10 +1453,9 @@ td_api::object_ptr<td_api::activeStories> StoryManager::get_active_stories_objec
} }
} }
} }
CHECK(owner_dialog_id.get_type() == DialogType::User);
return td_api::make_object<td_api::activeStories>( return td_api::make_object<td_api::activeStories>(
td_->contacts_manager_->get_user_id_object(owner_dialog_id.get_user_id(), "get_active_stories_object"), td_->messages_manager_->get_chat_id_object(owner_dialog_id, "get_active_stories_object"), max_read_story_id.get(),
max_read_story_id.get(), std::move(stories)); std::move(stories));
} }
vector<FileId> StoryManager::get_story_file_ids(const Story *story) const { vector<FileId> StoryManager::get_story_file_ids(const Story *story) const {
@ -1683,11 +1680,10 @@ void StoryManager::on_delete_story(StoryFullId story_full_id) {
} }
auto owner_dialog_id = story_full_id.get_dialog_id(); auto owner_dialog_id = story_full_id.get_dialog_id();
if (story->is_update_sent_) { if (story->is_update_sent_) {
CHECK(owner_dialog_id.get_type() == DialogType::User); send_closure(
send_closure(G()->td(), &Td::send_update, G()->td(), &Td::send_update,
td_api::make_object<td_api::updateStoryDeleted>( td_api::make_object<td_api::updateStoryDeleted>(
td_->contacts_manager_->get_user_id_object(owner_dialog_id.get_user_id(), "updateStoryDeleted"), td_->messages_manager_->get_chat_id_object(owner_dialog_id, "updateStoryDeleted"), story_id.get()));
story_id.get()));
} }
delete_story_files(story); delete_story_files(story);
unregister_story_global_id(story); unregister_story_global_id(story);
@ -2011,7 +2007,7 @@ void StoryManager::on_reload_story(StoryFullId story_full_id, Result<Unit> &&res
void StoryManager::get_story(DialogId owner_dialog_id, StoryId story_id, void StoryManager::get_story(DialogId owner_dialog_id, StoryId story_id,
Promise<td_api::object_ptr<td_api::story>> &&promise) { Promise<td_api::object_ptr<td_api::story>> &&promise) {
if (!td_->messages_manager_->have_dialog_info_force(owner_dialog_id)) { if (!td_->messages_manager_->have_dialog_force(owner_dialog_id, "get_story")) {
return promise.set_error(Status::Error(400, "Story sender not found")); return promise.set_error(Status::Error(400, "Story sender not found"));
} }
if (!td_->messages_manager_->have_input_peer(owner_dialog_id, AccessRights::Read)) { if (!td_->messages_manager_->have_input_peer(owner_dialog_id, AccessRights::Read)) {
@ -2436,7 +2432,7 @@ void StoryManager::on_binlog_events(vector<BinlogEvent> &&events) {
break; break;
} }
td_->messages_manager_->have_dialog_info_force(dialog_id); td_->messages_manager_->have_dialog_force(dialog_id, "DeleteStoryOnServerLogEvent");
delete_story_on_server(log_event.story_full_id_, event.id_, Auto()); delete_story_on_server(log_event.story_full_id_, event.id_, Auto());
break; break;
} }
@ -2445,7 +2441,7 @@ void StoryManager::on_binlog_events(vector<BinlogEvent> &&events) {
log_event_parse(log_event, event.get_data()).ensure(); log_event_parse(log_event, event.get_data()).ensure();
auto dialog_id = log_event.dialog_id_; auto dialog_id = log_event.dialog_id_;
if (!td_->messages_manager_->have_dialog_info_force(dialog_id)) { if (!td_->messages_manager_->have_dialog_force(dialog_id, "ReadStoriesOnServerLogEvent")) {
binlog_erase(G()->td_db()->get_binlog(), event.id_); binlog_erase(G()->td_db()->get_binlog(), event.id_);
break; break;
} }

View File

@ -5623,7 +5623,7 @@ void Td::on_request(uint64 id, td_api::editMessageSchedulingState &request) {
void Td::on_request(uint64 id, const td_api::getStory &request) { void Td::on_request(uint64 id, const td_api::getStory &request) {
CHECK_IS_USER(); CHECK_IS_USER();
CREATE_REQUEST_PROMISE(); CREATE_REQUEST_PROMISE();
story_manager_->get_story(DialogId(UserId(request.user_id_)), StoryId(request.story_id_), std::move(promise)); story_manager_->get_story(DialogId(request.story_sender_chat_id_), StoryId(request.story_id_), std::move(promise));
} }
void Td::on_request(uint64 id, td_api::sendStory &request) { void Td::on_request(uint64 id, td_api::sendStory &request) {
@ -6446,15 +6446,13 @@ void Td::on_request(uint64 id, const td_api::getArchivedStories &request) {
void Td::on_request(uint64 id, const td_api::openStory &request) { void Td::on_request(uint64 id, const td_api::openStory &request) {
CHECK_IS_USER(); CHECK_IS_USER();
CREATE_OK_REQUEST_PROMISE(); CREATE_OK_REQUEST_PROMISE();
story_manager_->open_story(DialogId(UserId(request.story_sender_user_id_)), StoryId(request.story_id_), story_manager_->open_story(DialogId(request.story_sender_chat_id_), StoryId(request.story_id_), std::move(promise));
std::move(promise));
} }
void Td::on_request(uint64 id, const td_api::closeStory &request) { void Td::on_request(uint64 id, const td_api::closeStory &request) {
CHECK_IS_USER(); CHECK_IS_USER();
CREATE_OK_REQUEST_PROMISE(); CREATE_OK_REQUEST_PROMISE();
story_manager_->close_story(DialogId(UserId(request.story_sender_user_id_)), StoryId(request.story_id_), story_manager_->close_story(DialogId(request.story_sender_chat_id_), StoryId(request.story_id_), std::move(promise));
std::move(promise));
} }
void Td::on_request(uint64 id, const td_api::getStoryViewers &request) { void Td::on_request(uint64 id, const td_api::getStoryViewers &request) {
@ -6471,7 +6469,7 @@ void Td::on_request(uint64 id, td_api::reportStory &request) {
return send_error_raw(id, r_report_reason.error().code(), r_report_reason.error().message()); return send_error_raw(id, r_report_reason.error().code(), r_report_reason.error().message());
} }
CREATE_OK_REQUEST_PROMISE(); CREATE_OK_REQUEST_PROMISE();
story_manager_->report_story({DialogId(UserId(request.story_sender_user_id_)), StoryId(request.story_id_)}, story_manager_->report_story({DialogId(request.story_sender_chat_id_), StoryId(request.story_id_)},
r_report_reason.move_as_ok(), std::move(promise)); r_report_reason.move_as_ok(), std::move(promise));
} }

View File

@ -587,8 +587,7 @@ void WebPagesManager::update_web_page(unique_ptr<WebPage> web_page, WebPageId we
if (!web_page->story_full_ids.empty()) { if (!web_page->story_full_ids.empty()) {
Dependencies dependencies; Dependencies dependencies;
for (auto story_full_id : web_page->story_full_ids) { for (auto story_full_id : web_page->story_full_ids) {
auto story_sender_dialog_id = story_full_id.get_dialog_id(); dependencies.add_dialog_and_dependencies(story_full_id.get_dialog_id());
dependencies.add_message_sender_dependencies(story_sender_dialog_id);
} }
if (!dependencies.resolve_force(td_, "update_web_page")) { if (!dependencies.resolve_force(td_, "update_web_page")) {
web_page->story_full_ids = {}; web_page->story_full_ids = {};
@ -1293,12 +1292,10 @@ tl_object_ptr<td_api::webPage> WebPagesManager::get_web_page_object(WebPageId we
} }
auto duration = get_web_page_media_duration(web_page); auto duration = get_web_page_media_duration(web_page);
UserId story_sender_user_id; DialogId story_sender_dialog_id;
StoryId story_id; StoryId story_id;
if (web_page->story_full_ids.size() == 1) { if (web_page->story_full_ids.size() == 1) {
DialogId story_sender_dialog_id = web_page->story_full_ids[0].get_dialog_id(); story_sender_dialog_id = web_page->story_full_ids[0].get_dialog_id();
CHECK(story_sender_dialog_id.get_type() == DialogType::User);
story_sender_user_id = story_sender_dialog_id.get_user_id();
story_id = web_page->story_full_ids[0].get_story_id(); story_id = web_page->story_full_ids[0].get_story_id();
} }
return make_tl_object<td_api::webPage>( return make_tl_object<td_api::webPage>(
@ -1327,7 +1324,7 @@ tl_object_ptr<td_api::webPage> WebPagesManager::get_web_page_object(WebPageId we
web_page->document.type == Document::Type::VoiceNote web_page->document.type == Document::Type::VoiceNote
? td_->voice_notes_manager_->get_voice_note_object(web_page->document.file_id) ? td_->voice_notes_manager_->get_voice_note_object(web_page->document.file_id)
: nullptr, : nullptr,
td_->contacts_manager_->get_user_id_object(story_sender_user_id, "webPage"), story_id.get(), td_->messages_manager_->get_chat_id_object(story_sender_dialog_id, "webPage"), story_id.get(),
instant_view_version); instant_view_version);
} }

View File

@ -3969,10 +3969,10 @@ class CliClient final : public Actor {
} else if (op == "rcl" || op == "rcla" || begins_with(op, "rcl-")) { } else if (op == "rcl" || op == "rcla" || begins_with(op, "rcl-")) {
send_request(td_api::make_object<td_api::readChatList>(as_chat_list(op))); send_request(td_api::make_object<td_api::readChatList>(as_chat_list(op)));
} else if (op == "gst") { } else if (op == "gst") {
UserId user_id; ChatId story_sender_chat_id;
StoryId story_id; StoryId story_id;
get_args(args, user_id, story_id); get_args(args, story_sender_chat_id, story_id);
send_request(td_api::make_object<td_api::getStory>(user_id, story_id)); send_request(td_api::make_object<td_api::getStory>(story_sender_chat_id, story_id));
} else if (op == "ssp" || op == "sspp") { } else if (op == "ssp" || op == "sspp") {
string photo; string photo;
string caption; string caption;
@ -4061,15 +4061,15 @@ class CliClient final : public Actor {
get_args(args, user_id); get_args(args, user_id);
send_request(td_api::make_object<td_api::getUserActiveStories>(user_id)); send_request(td_api::make_object<td_api::getUserActiveStories>(user_id));
} else if (op == "os") { } else if (op == "os") {
UserId story_sender_user_id; ChatId story_sender_chat_id;
StoryId story_id; StoryId story_id;
get_args(args, story_sender_user_id, story_id); get_args(args, story_sender_chat_id, story_id);
send_request(td_api::make_object<td_api::openStory>(story_sender_user_id, story_id)); send_request(td_api::make_object<td_api::openStory>(story_sender_chat_id, story_id));
} else if (op == "cs") { } else if (op == "cs") {
UserId story_sender_user_id; ChatId story_sender_chat_id;
StoryId story_id; StoryId story_id;
get_args(args, story_sender_user_id, story_id); get_args(args, story_sender_chat_id, story_id);
send_request(td_api::make_object<td_api::closeStory>(story_sender_user_id, story_id)); send_request(td_api::make_object<td_api::closeStory>(story_sender_chat_id, story_id));
} else if (op == "gsv") { } else if (op == "gsv") {
StoryId story_id; StoryId story_id;
string limit; string limit;
@ -4079,13 +4079,13 @@ class CliClient final : public Actor {
send_request(td_api::make_object<td_api::getStoryViewers>( send_request(td_api::make_object<td_api::getStoryViewers>(
story_id, td_api::make_object<td_api::messageViewer>(offset_user_id, offset_date), as_limit(limit))); story_id, td_api::make_object<td_api::messageViewer>(offset_user_id, offset_date), as_limit(limit)));
} else if (op == "rst") { } else if (op == "rst") {
UserId story_sender_user_id; ChatId story_sender_chat_id;
StoryId story_id; StoryId story_id;
string reason; string reason;
string text; string text;
get_args(args, story_sender_user_id, story_id, reason, text); get_args(args, story_sender_chat_id, story_id, reason, text);
send_request( send_request(
td_api::make_object<td_api::reportStory>(story_sender_user_id, story_id, as_report_reason(reason), text)); td_api::make_object<td_api::reportStory>(story_sender_chat_id, story_id, as_report_reason(reason), text));
} else if (op == "gamb") { } else if (op == "gamb") {
UserId user_id; UserId user_id;
get_args(args, user_id); get_args(args, user_id);
@ -4714,10 +4714,10 @@ class CliClient final : public Actor {
td_api::make_object<td_api::inputMessageSticker>(as_input_file_id(file_id), nullptr, 0, 0, emoji)); td_api::make_object<td_api::inputMessageSticker>(as_input_file_id(file_id), nullptr, 0, 0, emoji));
} else if (op == "sstory") { } else if (op == "sstory") {
ChatId chat_id; ChatId chat_id;
UserId story_sender_user_id; ChatId story_sender_chat_id;
StoryId story_id; StoryId story_id;
get_args(args, chat_id, story_sender_user_id, story_id); get_args(args, chat_id, story_sender_chat_id, story_id);
send_message(chat_id, td_api::make_object<td_api::inputMessageStory>(story_sender_user_id, story_id)); send_message(chat_id, td_api::make_object<td_api::inputMessageStory>(story_sender_chat_id, story_id));
} else if (op == "sv") { } else if (op == "sv") {
ChatId chat_id; ChatId chat_id;
string video_path; string video_path;