From a0a025bffe3c3fd8f4973b09c89939b4e9092809 Mon Sep 17 00:00:00 2001 From: Victor Neznaykin Date: Wed, 21 Dec 2022 12:59:22 +0400 Subject: [PATCH 01/11] added new fields to chat for manage messages history --- chat.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/chat.go b/chat.go index 49e9fe0c..5a4d4a22 100644 --- a/chat.go +++ b/chat.go @@ -13,6 +13,9 @@ type ChatShort struct { // Icon data Icons IconData `json:"icons"` + + // MessagesFromGentime show messages from this gentime for this chat + MessagesFromGentime *int64 `json:"messages_from_gentime,omitempty"` } // Minimal chat representation for deletion @@ -250,6 +253,15 @@ type Chat struct { //Meeting duration MeetingDuration int32 `json:"meeting_duration,omitempty"` + + // Can I delete local messages history in this chat + CanDeleteLocalHistory bool `json:"can_delete_local_history,omitempty"` + + // Can I delete all messages history in this chat + CanDeleteGlobalHistory bool `json:"can_delete_global_history,omitempty"` + + // MessagesFromGentime show messages from this gentime for this chat + MessagesFromGentime *int64 `json:"messages_from_gentime,omitempty"` } // Link to sub/sup task From 344a708e1054e68a713f6577e5756d7871ba3ea7 Mon Sep 17 00:00:00 2001 From: Victor Neznaykin Date: Mon, 9 Jan 2023 14:23:15 +0400 Subject: [PATCH 02/11] added new ServerChatHistoryCleared event removed messageHistoryFromGentime field from chat object --- chat.go | 6 ------ server_chat_history_cleared.go | 23 +++++++++++++++++++++++ 2 files changed, 23 insertions(+), 6 deletions(-) create mode 100644 server_chat_history_cleared.go diff --git a/chat.go b/chat.go index 5a4d4a22..a00faeee 100644 --- a/chat.go +++ b/chat.go @@ -13,9 +13,6 @@ type ChatShort struct { // Icon data Icons IconData `json:"icons"` - - // MessagesFromGentime show messages from this gentime for this chat - MessagesFromGentime *int64 `json:"messages_from_gentime,omitempty"` } // Minimal chat representation for deletion @@ -259,9 +256,6 @@ type Chat struct { // Can I delete all messages history in this chat CanDeleteGlobalHistory bool `json:"can_delete_global_history,omitempty"` - - // MessagesFromGentime show messages from this gentime for this chat - MessagesFromGentime *int64 `json:"messages_from_gentime,omitempty"` } // Link to sub/sup task diff --git a/server_chat_history_cleared.go b/server_chat_history_cleared.go new file mode 100644 index 00000000..2b75ee10 --- /dev/null +++ b/server_chat_history_cleared.go @@ -0,0 +1,23 @@ +package tdproto + +func NewServerChatHistoryCleared(jid JID) (r ServerChatHistoryCleared) { + r.Name = r.GetName() + r.Params.JID = jid + return r +} + +// ServerChatHistoryCleared +type ServerChatHistoryCleared struct { + BaseEvent + Params serverChatHistoryClearedParams `json:"params"` +} + +func (p ServerChatHistoryCleared) GetName() string { return "server.chat.history.cleared" } + +// Params of the server.chat.history.cleared event +type serverChatHistoryClearedParams struct { + // chat jid + JID JID `json:"jid"` + + LastCleared *string `json:"last_cleared,omitempty"` +} From 977ca404882a312a8fb65f3bc66a3a7e4113d1cf Mon Sep 17 00:00:00 2001 From: Victor Neznaykin Date: Mon, 9 Jan 2023 14:25:40 +0400 Subject: [PATCH 03/11] added LastCleared filed for serverChatHistoryClearedParams struct --- server_chat_history_cleared.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/server_chat_history_cleared.go b/server_chat_history_cleared.go index 2b75ee10..eb4d2927 100644 --- a/server_chat_history_cleared.go +++ b/server_chat_history_cleared.go @@ -1,8 +1,11 @@ package tdproto -func NewServerChatHistoryCleared(jid JID) (r ServerChatHistoryCleared) { +func NewServerChatHistoryCleared(jid JID, lastCleared *string) (r ServerChatHistoryCleared) { r.Name = r.GetName() r.Params.JID = jid + if lastCleared != nil { + r.Params.LastCleared = lastCleared + } return r } From 6e0405898ad599b13dde5a721e8d6dd41022608a Mon Sep 17 00:00:00 2001 From: Victor Neznaykin Date: Mon, 9 Jan 2023 14:34:18 +0400 Subject: [PATCH 04/11] added comment for LastCleared serverChatHistoryClearedParams struct field --- server_chat_history_cleared.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server_chat_history_cleared.go b/server_chat_history_cleared.go index eb4d2927..c4ebe2d8 100644 --- a/server_chat_history_cleared.go +++ b/server_chat_history_cleared.go @@ -19,8 +19,9 @@ func (p ServerChatHistoryCleared) GetName() string { return "server.chat.history // Params of the server.chat.history.cleared event type serverChatHistoryClearedParams struct { - // chat jid + // Chat jid JID JID `json:"jid"` + // Last clear chat history LastCleared *string `json:"last_cleared,omitempty"` } From a2a8a7e4364abe193babe198d8c27b00102e6389 Mon Sep 17 00:00:00 2001 From: Victor Neznaykin Date: Mon, 9 Jan 2023 15:11:28 +0400 Subject: [PATCH 05/11] some refactoring --- chat.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/chat.go b/chat.go index a00faeee..fa17fed4 100644 --- a/chat.go +++ b/chat.go @@ -251,11 +251,11 @@ type Chat struct { //Meeting duration MeetingDuration int32 `json:"meeting_duration,omitempty"` - // Can I delete local messages history in this chat - CanDeleteLocalHistory bool `json:"can_delete_local_history,omitempty"` - // Can I delete all messages history in this chat CanDeleteGlobalHistory bool `json:"can_delete_global_history,omitempty"` + + // Can I delete local messages history in this chat + CanDeleteLocalHistory bool `json:"can_delete_local_history,omitempty"` } // Link to sub/sup task From 4f8ae322f1dd5e0dffb047a8d47b09a6edc8541e Mon Sep 17 00:00:00 2001 From: Victor Neznaykin Date: Mon, 9 Jan 2023 15:22:40 +0400 Subject: [PATCH 06/11] try to update go.mod cache --- ...ory_cleared.go => server_chat_messages_history_cleared.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) rename server_chat_history_cleared.go => server_chat_messages_history_cleared.go (72%) diff --git a/server_chat_history_cleared.go b/server_chat_messages_history_cleared.go similarity index 72% rename from server_chat_history_cleared.go rename to server_chat_messages_history_cleared.go index c4ebe2d8..cb0bf814 100644 --- a/server_chat_history_cleared.go +++ b/server_chat_messages_history_cleared.go @@ -1,20 +1,23 @@ package tdproto +// NewServerChatHistoryCleared returns the new ServerChatHistoryCleared instance. func NewServerChatHistoryCleared(jid JID, lastCleared *string) (r ServerChatHistoryCleared) { r.Name = r.GetName() r.Params.JID = jid if lastCleared != nil { r.Params.LastCleared = lastCleared } + return r } -// ServerChatHistoryCleared +// ServerChatHistoryCleared represents the event about clearing the chat messages history for user. type ServerChatHistoryCleared struct { BaseEvent Params serverChatHistoryClearedParams `json:"params"` } +// GetName returns the name of ServerChatHistoryCleared instance. func (p ServerChatHistoryCleared) GetName() string { return "server.chat.history.cleared" } // Params of the server.chat.history.cleared event From 5a6f41d0f2f96b3fbdf8f85cb8d8b76d93a0dc65 Mon Sep 17 00:00:00 2001 From: Victor Neznaykin Date: Mon, 9 Jan 2023 15:23:43 +0400 Subject: [PATCH 07/11] try to update go.mod cache --- server_chat_messages_history_cleared.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server_chat_messages_history_cleared.go b/server_chat_messages_history_cleared.go index cb0bf814..8b97a487 100644 --- a/server_chat_messages_history_cleared.go +++ b/server_chat_messages_history_cleared.go @@ -14,14 +14,14 @@ func NewServerChatHistoryCleared(jid JID, lastCleared *string) (r ServerChatHist // ServerChatHistoryCleared represents the event about clearing the chat messages history for user. type ServerChatHistoryCleared struct { BaseEvent - Params serverChatHistoryClearedParams `json:"params"` + Params serverChatMessagesHistoryClearedParams `json:"params"` } // GetName returns the name of ServerChatHistoryCleared instance. func (p ServerChatHistoryCleared) GetName() string { return "server.chat.history.cleared" } // Params of the server.chat.history.cleared event -type serverChatHistoryClearedParams struct { +type serverChatMessagesHistoryClearedParams struct { // Chat jid JID JID `json:"jid"` From f5eaeeee588786babe08380121f91a0302682e54 Mon Sep 17 00:00:00 2001 From: Victor Neznaykin Date: Mon, 9 Jan 2023 15:26:01 +0400 Subject: [PATCH 08/11] revert --- ...sages_history_cleared.go => server_chat_history_cleared.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename server_chat_messages_history_cleared.go => server_chat_history_cleared.go (87%) diff --git a/server_chat_messages_history_cleared.go b/server_chat_history_cleared.go similarity index 87% rename from server_chat_messages_history_cleared.go rename to server_chat_history_cleared.go index 8b97a487..cb0bf814 100644 --- a/server_chat_messages_history_cleared.go +++ b/server_chat_history_cleared.go @@ -14,14 +14,14 @@ func NewServerChatHistoryCleared(jid JID, lastCleared *string) (r ServerChatHist // ServerChatHistoryCleared represents the event about clearing the chat messages history for user. type ServerChatHistoryCleared struct { BaseEvent - Params serverChatMessagesHistoryClearedParams `json:"params"` + Params serverChatHistoryClearedParams `json:"params"` } // GetName returns the name of ServerChatHistoryCleared instance. func (p ServerChatHistoryCleared) GetName() string { return "server.chat.history.cleared" } // Params of the server.chat.history.cleared event -type serverChatMessagesHistoryClearedParams struct { +type serverChatHistoryClearedParams struct { // Chat jid JID JID `json:"jid"` From a2f26dfe008ec9d7abd196e7763f7488a3e2ef95 Mon Sep 17 00:00:00 2001 From: Victor Neznaykin Date: Mon, 9 Jan 2023 15:33:35 +0400 Subject: [PATCH 09/11] try to update go.mod cache --- server_chat_history_cleared.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/server_chat_history_cleared.go b/server_chat_history_cleared.go index cb0bf814..a5c9d56a 100644 --- a/server_chat_history_cleared.go +++ b/server_chat_history_cleared.go @@ -11,6 +11,17 @@ func NewServerChatHistoryCleared(jid JID, lastCleared *string) (r ServerChatHist return r } +// NewServerChatHistoryCleared2 returns the new ServerChatHistoryCleared instance. +func NewServerChatHistoryCleared2(jid JID, lastCleared *string) (r ServerChatHistoryCleared) { + r.Name = r.GetName() + r.Params.JID = jid + if lastCleared != nil { + r.Params.LastCleared = lastCleared + } + + return r +} + // ServerChatHistoryCleared represents the event about clearing the chat messages history for user. type ServerChatHistoryCleared struct { BaseEvent From 928c83abbb4ae8131dd232525b100788bba9d380 Mon Sep 17 00:00:00 2001 From: Victor Neznaykin Date: Mon, 9 Jan 2023 15:37:57 +0400 Subject: [PATCH 10/11] revert --- server_chat_history_cleared.go | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/server_chat_history_cleared.go b/server_chat_history_cleared.go index a5c9d56a..cb0bf814 100644 --- a/server_chat_history_cleared.go +++ b/server_chat_history_cleared.go @@ -11,17 +11,6 @@ func NewServerChatHistoryCleared(jid JID, lastCleared *string) (r ServerChatHist return r } -// NewServerChatHistoryCleared2 returns the new ServerChatHistoryCleared instance. -func NewServerChatHistoryCleared2(jid JID, lastCleared *string) (r ServerChatHistoryCleared) { - r.Name = r.GetName() - r.Params.JID = jid - if lastCleared != nil { - r.Params.LastCleared = lastCleared - } - - return r -} - // ServerChatHistoryCleared represents the event about clearing the chat messages history for user. type ServerChatHistoryCleared struct { BaseEvent From a527d20a6bbdb4e6fd6442906a69e69a706a1c51 Mon Sep 17 00:00:00 2001 From: Victor Neznaykin Date: Mon, 9 Jan 2023 17:34:12 +0400 Subject: [PATCH 11/11] omitempty removed for LastClear field --- server_chat_history_cleared.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server_chat_history_cleared.go b/server_chat_history_cleared.go index cb0bf814..36ca7aed 100644 --- a/server_chat_history_cleared.go +++ b/server_chat_history_cleared.go @@ -5,7 +5,7 @@ func NewServerChatHistoryCleared(jid JID, lastCleared *string) (r ServerChatHist r.Name = r.GetName() r.Params.JID = jid if lastCleared != nil { - r.Params.LastCleared = lastCleared + r.Params.LastClear = lastCleared } return r @@ -25,6 +25,6 @@ type serverChatHistoryClearedParams struct { // Chat jid JID JID `json:"jid"` - // Last clear chat history - LastCleared *string `json:"last_cleared,omitempty"` + // LastClear last clear chat history + LastClear *string `json:"last_clear"` }