forked from tulir/whatsmeow
-
Notifications
You must be signed in to change notification settings - Fork 1
/
appstate.go
155 lines (124 loc) · 6.78 KB
/
appstate.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
// Copyright (c) 2021 Tulir Asokan
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
package events
import (
"time"
"github.com/LoL-Human/whatsmeow/appstate"
waProto "github.com/LoL-Human/whatsmeow/binary/proto"
"github.com/LoL-Human/whatsmeow/types"
)
// Contact is emitted when an entry in the user's contact list is modified from another device.
type Contact struct {
JID types.JID // The contact who was modified.
Timestamp time.Time // The time when the modification happened.'
Action *waProto.ContactAction // The new contact info.
FromFullSync bool // Whether the action is emitted because of a fullSync
}
// PushName is emitted when a message is received with a different push name than the previous value cached for the same user.
type PushName struct {
JID types.JID // The user whose push name changed.
Message *types.MessageInfo // The message where this change was first noticed.
OldPushName string // The previous push name from the local cache.
NewPushName string // The new push name that was included in the message.
}
// BusinessName is emitted when a message is received with a different verified business name than the previous value cached for the same user.
type BusinessName struct {
JID types.JID
Message *types.MessageInfo // This is only present if the change was detected in a message.
OldBusinessName string
NewBusinessName string
}
// Pin is emitted when a chat is pinned or unpinned from another device.
type Pin struct {
JID types.JID // The chat which was pinned or unpinned.
Timestamp time.Time // The time when the (un)pinning happened.
Action *waProto.PinAction // Whether the chat is now pinned or not.
FromFullSync bool // Whether the action is emitted because of a fullSync
}
// Star is emitted when a message is starred or unstarred from another device.
type Star struct {
ChatJID types.JID // The chat where the message was pinned.
SenderJID types.JID // In group chats, the user who sent the message (except if the message was sent by the user).
IsFromMe bool // Whether the message was sent by the user.
MessageID string // The message which was starred or unstarred.
Timestamp time.Time // The time when the (un)starring happened.
Action *waProto.StarAction // Whether the message is now starred or not.
FromFullSync bool // Whether the action is emitted because of a fullSync
}
// DeleteForMe is emitted when a message is deleted (for the current user only) from another device.
type DeleteForMe struct {
ChatJID types.JID // The chat where the message was deleted.
SenderJID types.JID // In group chats, the user who sent the message (except if the message was sent by the user).
IsFromMe bool // Whether the message was sent by the user.
MessageID string // The message which was deleted.
Timestamp time.Time // The time when the deletion happened.
Action *waProto.DeleteMessageForMeAction // Additional information for the deletion.
FromFullSync bool // Whether the action is emitted because of a fullSync
}
// Mute is emitted when a chat is muted or unmuted from another device.
type Mute struct {
JID types.JID // The chat which was muted or unmuted.
Timestamp time.Time // The time when the (un)muting happened.
Action *waProto.MuteAction // The current mute status of the chat.
FromFullSync bool // Whether the action is emitted because of a fullSync
}
// Archive is emitted when a chat is archived or unarchived from another device.
type Archive struct {
JID types.JID // The chat which was archived or unarchived.
Timestamp time.Time // The time when the (un)archiving happened.
Action *waProto.ArchiveChatAction // The current archival status of the chat.
FromFullSync bool // Whether the action is emitted because of a fullSync
}
// MarkChatAsRead is emitted when a whole chat is marked as read or unread from another device.
type MarkChatAsRead struct {
JID types.JID // The chat which was marked as read or unread.
Timestamp time.Time // The time when the marking happened.
Action *waProto.MarkChatAsReadAction // Whether the chat was marked as read or unread, and info about the most recent messages.
FromFullSync bool // Whether the action is emitted because of a fullSync
}
// ClearChat is emitted when a chat is cleared on another device. This is different from DeleteChat.
type ClearChat struct {
JID types.JID // The chat which was cleared.
Timestamp time.Time // The time when the clear happened.
Action *waProto.ClearChatAction // Information about the clear.
FromFullSync bool // Whether the action is emitted because of a fullSync
}
// DeleteChat is emitted when a chat is deleted on another device.
type DeleteChat struct {
JID types.JID // The chat which was deleted.
Timestamp time.Time // The time when the deletion happened.
Action *waProto.DeleteChatAction // Information about the deletion.
FromFullSync bool // Whether the action is emitted because of a fullSync
}
// PushNameSetting is emitted when the user's push name is changed from another device.
type PushNameSetting struct {
Timestamp time.Time // The time when the push name was changed.
Action *waProto.PushNameSetting // The new push name for the user.
FromFullSync bool // Whether the action is emitted because of a fullSync
}
// UnarchiveChatsSetting is emitted when the user changes the "Keep chats archived" setting from another device.
type UnarchiveChatsSetting struct {
Timestamp time.Time // The time when the setting was changed.
Action *waProto.UnarchiveChatsSetting // The new settings.
FromFullSync bool // Whether the action is emitted because of a fullSync
}
// UserStatusMute is emitted when the user mutes or unmutes another user's status updates.
type UserStatusMute struct {
JID types.JID // The user who was muted or unmuted
Timestamp time.Time // The timestamp when the action happened
Action *waProto.UserStatusMuteAction // The new mute status
FromFullSync bool // Whether the action is emitted because of a fullSync
}
// AppState is emitted directly for new data received from app state syncing.
// You should generally use the higher-level events like events.Contact and events.Mute.
type AppState struct {
Index []string
*waProto.SyncActionValue
}
// AppStateSyncComplete is emitted when app state is resynced.
type AppStateSyncComplete struct {
Name appstate.WAPatchName
}