Skip to content

Commit f9ac25a

Browse files
arugazcrazycodezombie
authored andcommittedSep 30, 2024
appstate: add support for starring messages (tulir#515)
1 parent 6365b40 commit f9ac25a

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
@@ -217,6 +217,36 @@ func BuildSettingPushName(pushName string) PatchInfo {
217217
}
218218
}
219219

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

0 commit comments

Comments
 (0)
Please sign in to comment.