From c916566e76c8fe1d27e8ecac0e50dc0068cfdabc Mon Sep 17 00:00:00 2001 From: levlam Date: Sat, 3 Oct 2020 21:47:12 +0300 Subject: [PATCH 1/4] Fix MessagesManager::get_chat_object. GitOrigin-RevId: a5dddba5f844b8064fe7083c8532f9d2286b9dba --- td/telegram/MessagesManager.cpp | 14 +++++--------- td/telegram/MessagesManager.h | 4 ++-- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 62d3f7f08..becb6fa96 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -18848,15 +18848,11 @@ td_api::object_ptr MessagesManager::get_chat_action_bar_o return nullptr; } -td_api::object_ptr MessagesManager::get_chat_object(const Dialog *d, int64 real_order) const { +td_api::object_ptr MessagesManager::get_chat_object(const Dialog *d) const { CHECK(d != nullptr); auto chat_source = is_dialog_sponsored(d) ? sponsored_dialog_source_.get_chat_source_object() : nullptr; - if (real_order == DEFAULT_ORDER) { - real_order = d->order; - } - bool can_delete_for_self = false; bool can_delete_for_all_users = false; if (chat_source != nullptr) { @@ -18869,7 +18865,7 @@ td_api::object_ptr MessagesManager::get_chat_object(const Dialog * // can't delete break; } - } else if (!td_->auth_manager_->is_bot() && real_order != DEFAULT_ORDER) { + } else if (!td_->auth_manager_->is_bot() && have_input_peer(d->dialog_id, AccessRights::Read)) { switch (d->dialog_id.get_type()) { case DialogType::User: can_delete_for_self = true; @@ -26891,10 +26887,10 @@ void MessagesManager::send_update_delete_messages(DialogId dialog_id, vector(dialog_id.get(), std::move(message_ids), is_permanent, from_cache)); } -void MessagesManager::send_update_new_chat(Dialog *d, int64 real_order) { +void MessagesManager::send_update_new_chat(Dialog *d) { CHECK(d != nullptr); CHECK(d->messages == nullptr); - auto chat_object = get_chat_object(d, real_order); + auto chat_object = get_chat_object(d); bool has_action_bar = chat_object->action_bar_ != nullptr; d->last_sent_has_scheduled_messages = chat_object->has_scheduled_messages_; send_closure(G()->td(), &Td::send_update, make_tl_object(std::move(chat_object))); @@ -32339,7 +32335,7 @@ MessagesManager::Dialog *MessagesManager::add_new_dialog(unique_ptr &&d, fix_dialog_action_bar(dialog); - send_update_new_chat(dialog, order); + send_update_new_chat(dialog); fix_new_dialog(dialog, std::move(last_database_message), last_database_message_id, order, last_clear_history_date, last_clear_history_message_id, is_loaded_from_database); diff --git a/td/telegram/MessagesManager.h b/td/telegram/MessagesManager.h index 16315dd61..2b2fbb28e 100644 --- a/td/telegram/MessagesManager.h +++ b/td/telegram/MessagesManager.h @@ -2187,7 +2187,7 @@ class MessagesManager : public Actor { void send_update_delete_messages(DialogId dialog_id, vector &&message_ids, bool is_permanent, bool from_cache) const; - void send_update_new_chat(Dialog *d, int64 real_order); + void send_update_new_chat(Dialog *d); void send_update_chat_draft_message(const Dialog *d); @@ -2388,7 +2388,7 @@ class MessagesManager : public Actor { td_api::object_ptr get_chat_action_bar_object(const Dialog *d, bool hide_unarchive = false) const; - td_api::object_ptr get_chat_object(const Dialog *d, int64 real_order = DEFAULT_ORDER) const; + td_api::object_ptr get_chat_object(const Dialog *d) const; bool have_dialog_info(DialogId dialog_id) const; bool have_dialog_info_force(DialogId dialog_id) const; From 7c7804ff9e90dba3b19873a01fa194b010d54e8a Mon Sep 17 00:00:00 2001 From: levlam Date: Sat, 3 Oct 2020 21:52:19 +0300 Subject: [PATCH 2/4] Document that getMessageStatistics and getMessagePublicForwards shouldn't be used yet. GitOrigin-RevId: 64181ec55a95c06f3b93da7262ad76ee546abde5 --- td/generate/scheme/td_api.tl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 2b4f8a2be..214c01ab9 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -3698,7 +3698,7 @@ getChatMessageCount chat_id:int53 filter:SearchMessagesFilter return_local:Bool //@description Returns all scheduled messages in a chat. The messages are returned in a reverse chronological order (i.e., in order of decreasing message_id) @chat_id Chat identifier getChatScheduledMessages chat_id:int53 = Messages; -//@description Returns forwarded copies of a channel message to another public channels. For optimal performance the number of returned messages is chosen by the library +//@description Returns forwarded copies of a channel message to another public channels. For optimal performance the number of returned messages is chosen by the library. The method is under development and may or may not work //@chat_id Chat identifier of the message //@message_id Message identifier //@offset Offset of the first entry to return as received from the previous request; use empty string to get first chunk of results @@ -4569,7 +4569,7 @@ getChatStatisticsUrl chat_id:int53 parameters:string is_dark:Bool = HttpUrl; //@description Returns detailed statistics about a chat. Currently this method can be used only for supergroups and channels. Can be used only if SupergroupFullInfo.can_get_statistics == true @chat_id Chat identifier @is_dark Pass true if a dark theme is used by the application getChatStatistics chat_id:int53 is_dark:Bool = ChatStatistics; -//@description Returns detailed statistics about a message. Can be used only if Message.can_get_statistics == true @chat_id Chat identifier @message_id Message identifier @is_dark Pass true if a dark theme is used by the application +//@description Returns detailed statistics about a message. Can be used only if Message.can_get_statistics == true. The method is under development and may or may not work @chat_id Chat identifier @message_id Message identifier @is_dark Pass true if a dark theme is used by the application getMessageStatistics chat_id:int53 message_id:int53 is_dark:Bool = MessageStatistics; //@description Loads asynchronous or zoomed in chat or message statistics graph @chat_id Chat identifier @token The token for graph loading @x X-value for zoomed in graph or 0 otherwise From e104766de3c899b1dcd8155791cf72f0357df30f Mon Sep 17 00:00:00 2001 From: LionZXY Date: Sat, 3 Oct 2020 22:01:29 +0300 Subject: [PATCH 3/4] Fix java example build (#1225) --- example/java/org/drinkless/tdlib/example/Example.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/java/org/drinkless/tdlib/example/Example.java b/example/java/org/drinkless/tdlib/example/Example.java index c6e3f8e8e..7c4ae4b03 100644 --- a/example/java/org/drinkless/tdlib/example/Example.java +++ b/example/java/org/drinkless/tdlib/example/Example.java @@ -305,7 +305,7 @@ public final class Example { public static void main(String[] args) throws InterruptedException { // disable TDLib log Client.execute(new TdApi.SetLogVerbosityLevel(0)); - if (Client.execute(new TdApi.SetLogStream(new TdApi.LogStreamFile("tdlib.log", 1 << 27))) instanceof TdApi.Error) { + if (Client.execute(new TdApi.SetLogStream(new TdApi.LogStreamFile("tdlib.log", 1 << 27, true))) instanceof TdApi.Error) { throw new IOError(new IOException("Write access to the current directory is required")); } From 62d7423bc3f1925eb777e4f5e43de8c48ebf3191 Mon Sep 17 00:00:00 2001 From: levlam Date: Sat, 3 Oct 2020 22:05:55 +0300 Subject: [PATCH 4/4] Fix TdApi.LogStreamFile usage in examples. GitOrigin-RevId: 25af774fee360bd1071ef911d78e50a25b78372a --- example/csharp/TdExample.cs | 2 +- example/java/org/drinkless/tdlib/example/Example.java | 2 +- example/uwp/app/MainPage.xaml.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/example/csharp/TdExample.cs b/example/csharp/TdExample.cs index d544799be..960e81d8a 100644 --- a/example/csharp/TdExample.cs +++ b/example/csharp/TdExample.cs @@ -216,7 +216,7 @@ namespace TdExample { // disable TDLib log Td.Client.Execute(new TdApi.SetLogVerbosityLevel(0)); - if (Td.Client.Execute(new TdApi.SetLogStream(new TdApi.LogStreamFile("tdlib.log", 1 << 27))) is TdApi.Error) + if (Td.Client.Execute(new TdApi.SetLogStream(new TdApi.LogStreamFile("tdlib.log", 1 << 27, false))) is TdApi.Error) { throw new System.IO.IOException("Write access to the current directory is required"); } diff --git a/example/java/org/drinkless/tdlib/example/Example.java b/example/java/org/drinkless/tdlib/example/Example.java index 7c4ae4b03..484c90208 100644 --- a/example/java/org/drinkless/tdlib/example/Example.java +++ b/example/java/org/drinkless/tdlib/example/Example.java @@ -305,7 +305,7 @@ public final class Example { public static void main(String[] args) throws InterruptedException { // disable TDLib log Client.execute(new TdApi.SetLogVerbosityLevel(0)); - if (Client.execute(new TdApi.SetLogStream(new TdApi.LogStreamFile("tdlib.log", 1 << 27, true))) instanceof TdApi.Error) { + if (Client.execute(new TdApi.SetLogStream(new TdApi.LogStreamFile("tdlib.log", 1 << 27, false))) instanceof TdApi.Error) { throw new IOError(new IOException("Write access to the current directory is required")); } diff --git a/example/uwp/app/MainPage.xaml.cs b/example/uwp/app/MainPage.xaml.cs index 02897ef64..21d382625 100644 --- a/example/uwp/app/MainPage.xaml.cs +++ b/example/uwp/app/MainPage.xaml.cs @@ -28,7 +28,7 @@ namespace TdApp _handler = new MyClientResultHandler(this); Td.Client.Execute(new TdApi.SetLogVerbosityLevel(0)); - Td.Client.Execute(new TdApi.SetLogStream(new TdApi.LogStreamFile(Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "log"), 1 << 27))); + Td.Client.Execute(new TdApi.SetLogStream(new TdApi.LogStreamFile(Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "log"), 1 << 27, false))); System.Threading.Tasks.Task.Run(() => {