2/3
This commit is contained in:
parent
0cf7c09ed5
commit
af075e15fb
90
vendor/go.mau.fi/whatsmeow/appstate/encode.go
vendored
90
vendor/go.mau.fi/whatsmeow/appstate/encode.go
vendored
@ -123,6 +123,96 @@ func BuildArchive(target types.JID, archive bool, lastMessageTimestamp time.Time
|
|||||||
return result
|
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) {
|
func (proc *Processor) EncodePatch(keyID []byte, state HashState, patchInfo PatchInfo) ([]byte, error) {
|
||||||
keys, err := proc.getAppStateKey(keyID)
|
keys, err := proc.getAppStateKey(keyID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
27
vendor/go.mau.fi/whatsmeow/appstate/keys.go
vendored
27
vendor/go.mau.fi/whatsmeow/appstate/keys.go
vendored
@ -37,18 +37,21 @@ var AllPatchNames = [...]WAPatchName{WAPatchCriticalBlock, WAPatchCriticalUnbloc
|
|||||||
|
|
||||||
// Constants for the first part of app state indexes.
|
// Constants for the first part of app state indexes.
|
||||||
const (
|
const (
|
||||||
IndexMute = "mute"
|
IndexMute = "mute"
|
||||||
IndexPin = "pin_v1"
|
IndexPin = "pin_v1"
|
||||||
IndexArchive = "archive"
|
IndexArchive = "archive"
|
||||||
IndexContact = "contact"
|
IndexContact = "contact"
|
||||||
IndexClearChat = "clearChat"
|
IndexClearChat = "clearChat"
|
||||||
IndexDeleteChat = "deleteChat"
|
IndexDeleteChat = "deleteChat"
|
||||||
IndexStar = "star"
|
IndexStar = "star"
|
||||||
IndexDeleteMessageForMe = "deleteMessageForMe"
|
IndexDeleteMessageForMe = "deleteMessageForMe"
|
||||||
IndexMarkChatAsRead = "markChatAsRead"
|
IndexMarkChatAsRead = "markChatAsRead"
|
||||||
IndexSettingPushName = "setting_pushName"
|
IndexSettingPushName = "setting_pushName"
|
||||||
IndexSettingUnarchiveChats = "setting_unarchiveChats"
|
IndexSettingUnarchiveChats = "setting_unarchiveChats"
|
||||||
IndexUserStatusMute = "userStatusMute"
|
IndexUserStatusMute = "userStatusMute"
|
||||||
|
IndexLabelEdit = "label_edit"
|
||||||
|
IndexLabelAssociationChat = "label_jid"
|
||||||
|
IndexLabelAssociationMessage = "label_message"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Processor struct {
|
type Processor struct {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user