Skip to content

Commit 01d6cbd

Browse files
authored
appstate: add support for starring messages (#515)
1 parent 94acb10 commit 01d6cbd

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

appstate/encode.go

+30
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,36 @@ func BuildSettingPushName(pushName string) PatchInfo {
213213
}
214214
}
215215

216+
func newStarMutation(targetJID, senderJID string, messageID types.MessageID, fromMe string, starred bool) MutationInfo {
217+
return MutationInfo{
218+
Index: []string{IndexStar, targetJID, messageID, fromMe, senderJID},
219+
Version: 2,
220+
Value: &waProto.SyncActionValue{
221+
StarAction: &waProto.StarAction{
222+
Starred: &starred,
223+
},
224+
},
225+
}
226+
}
227+
228+
// BuildStar builds an app state patch for starring or unstarring a message.
229+
func BuildStar(target, sender types.JID, messageID types.MessageID, fromMe, starred bool) PatchInfo {
230+
isFromMe := "0"
231+
if fromMe {
232+
isFromMe = "1"
233+
}
234+
targetJID, senderJID := target.String(), sender.String()
235+
if target.User == sender.User {
236+
senderJID = "0"
237+
}
238+
return PatchInfo{
239+
Type: WAPatchRegularHigh,
240+
Mutations: []MutationInfo{
241+
newStarMutation(targetJID, senderJID, messageID, isFromMe, starred),
242+
},
243+
}
244+
}
245+
216246
func (proc *Processor) EncodePatch(keyID []byte, state HashState, patchInfo PatchInfo) ([]byte, error) {
217247
keys, err := proc.getAppStateKey(keyID)
218248
if err != nil {

0 commit comments

Comments
 (0)