From af075e15fb0327c74cf68242660314750e71edf1 Mon Sep 17 00:00:00 2001 From: tzagim <2285958+tzagim@users.noreply.github.com> Date: Tue, 21 May 2024 20:20:55 +0300 Subject: [PATCH] 2/3 --- vendor/go.mau.fi/whatsmeow/appstate/encode.go | 90 +++++++++++++++++++ vendor/go.mau.fi/whatsmeow/appstate/keys.go | 27 +++--- 2 files changed, 105 insertions(+), 12 deletions(-) diff --git a/vendor/go.mau.fi/whatsmeow/appstate/encode.go b/vendor/go.mau.fi/whatsmeow/appstate/encode.go index 1cb7d659..2358c903 100644 --- a/vendor/go.mau.fi/whatsmeow/appstate/encode.go +++ b/vendor/go.mau.fi/whatsmeow/appstate/encode.go @@ -123,6 +123,96 @@ func BuildArchive(target types.JID, archive bool, lastMessageTimestamp time.Time return result } +func newLabelChatMutation(target types.JID, labelID string, labeled bool) MutationInfo { + return MutationInfo{ + Index: []string{IndexLabelAssociationChat, labelID, target.String()}, + Version: 3, + Value: &waProto.SyncActionValue{ + LabelAssociationAction: &waProto.LabelAssociationAction{ + Labeled: &labeled, + }, + }, + } +} + +// BuildLabelChat builds an app state patch for labeling or un(labeling) a chat. +func BuildLabelChat(target types.JID, labelID string, labeled bool) PatchInfo { + return PatchInfo{ + Type: WAPatchRegular, + Mutations: []MutationInfo{ + newLabelChatMutation(target, labelID, labeled), + }, + } +} + +func newLabelMessageMutation(target types.JID, labelID, messageID string, labeled bool) MutationInfo { + return MutationInfo{ + Index: []string{IndexLabelAssociationMessage, labelID, target.String(), messageID, "0", "0"}, + Version: 3, + Value: &waProto.SyncActionValue{ + LabelAssociationAction: &waProto.LabelAssociationAction{ + Labeled: &labeled, + }, + }, + } +} + +// BuildLabelMessage builds an app state patch for labeling or un(labeling) a message. +func BuildLabelMessage(target types.JID, labelID, messageID string, labeled bool) PatchInfo { + return PatchInfo{ + Type: WAPatchRegular, + Mutations: []MutationInfo{ + newLabelMessageMutation(target, labelID, messageID, labeled), + }, + } +} + +func newLabelEditMutation(labelID string, labelName string, labelColor int32, deleted bool) MutationInfo { + return MutationInfo{ + Index: []string{IndexLabelEdit, labelID}, + Version: 3, + Value: &waProto.SyncActionValue{ + LabelEditAction: &waProto.LabelEditAction{ + Name: &labelName, + Color: &labelColor, + Deleted: &deleted, + }, + }, + } +} + +// BuildLabelEdit builds an app state patch for editing a label. +func BuildLabelEdit(labelID string, labelName string, labelColor int32, deleted bool) PatchInfo { + return PatchInfo{ + Type: WAPatchRegular, + Mutations: []MutationInfo{ + newLabelEditMutation(labelID, labelName, labelColor, deleted), + }, + } +} + +func newSettingPushNameMutation(pushName string) MutationInfo { + return MutationInfo{ + Index: []string{IndexSettingPushName}, + Version: 1, + Value: &waProto.SyncActionValue{ + PushNameSetting: &waProto.PushNameSetting{ + Name: &pushName, + }, + }, + } +} + +// BuildSettingPushName builds an app state patch for setting the push name. +func BuildSettingPushName(pushName string) PatchInfo { + return PatchInfo{ + Type: WAPatchCriticalBlock, + Mutations: []MutationInfo{ + newSettingPushNameMutation(pushName), + }, + } +} + func (proc *Processor) EncodePatch(keyID []byte, state HashState, patchInfo PatchInfo) ([]byte, error) { keys, err := proc.getAppStateKey(keyID) if err != nil { diff --git a/vendor/go.mau.fi/whatsmeow/appstate/keys.go b/vendor/go.mau.fi/whatsmeow/appstate/keys.go index 95f7d134..98d38c2c 100644 --- a/vendor/go.mau.fi/whatsmeow/appstate/keys.go +++ b/vendor/go.mau.fi/whatsmeow/appstate/keys.go @@ -37,18 +37,21 @@ var AllPatchNames = [...]WAPatchName{WAPatchCriticalBlock, WAPatchCriticalUnbloc // Constants for the first part of app state indexes. const ( - IndexMute = "mute" - IndexPin = "pin_v1" - IndexArchive = "archive" - IndexContact = "contact" - IndexClearChat = "clearChat" - IndexDeleteChat = "deleteChat" - IndexStar = "star" - IndexDeleteMessageForMe = "deleteMessageForMe" - IndexMarkChatAsRead = "markChatAsRead" - IndexSettingPushName = "setting_pushName" - IndexSettingUnarchiveChats = "setting_unarchiveChats" - IndexUserStatusMute = "userStatusMute" + IndexMute = "mute" + IndexPin = "pin_v1" + IndexArchive = "archive" + IndexContact = "contact" + IndexClearChat = "clearChat" + IndexDeleteChat = "deleteChat" + IndexStar = "star" + IndexDeleteMessageForMe = "deleteMessageForMe" + IndexMarkChatAsRead = "markChatAsRead" + IndexSettingPushName = "setting_pushName" + IndexSettingUnarchiveChats = "setting_unarchiveChats" + IndexUserStatusMute = "userStatusMute" + IndexLabelEdit = "label_edit" + IndexLabelAssociationChat = "label_jid" + IndexLabelAssociationMessage = "label_message" ) type Processor struct {