Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Add support for more group action decryptions
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed Aug 28, 2022
1 parent 3d843c9 commit 70cf775
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 6 deletions.
10 changes: 6 additions & 4 deletions groupsv2/decrypt.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ func (g *GroupV2) decryptMember(member *signalservice.Member) (*signalservice.De
if err != nil {
return nil, err
}

}

return decryptedMember, nil
Expand Down Expand Up @@ -150,15 +149,18 @@ func (g *GroupV2) decryptPendingMembers(pendingMembers []*signalservice.GroupCha
return decryptedPendingMembers
}
func (g *GroupV2) decryptDeletePendingMembers(deletedPendingMembers []*signalservice.GroupChange_Actions_DeletePendingMemberAction,
) []*signalservice.DecryptedPendingMember {
) []*signalservice.DecryptedPendingMemberRemoval {
pendingMembersRemoval := []*signalservice.DecryptedPendingMemberRemoval{}
for _, deletedPendingMember := range deletedPendingMembers {

uuid, err := g.cipher.DecryptUUID(deletedPendingMember.DeletedUserId)
if err != nil {
log.Errorln(err)
}
log.Debugln("[textsecure][groupsv2] deletePendingMember", idToHex(uuid))

pendingMembersRemoval = append(pendingMembersRemoval, &signalservice.DecryptedPendingMemberRemoval{
Uuid: uuid,
})
}
return nil
return pendingMembersRemoval
}
34 changes: 32 additions & 2 deletions groupsv2/groupActions.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,51 @@ func (g *GroupV2) decryptGroupChangeActions(groupActions *signalservice.GroupCha
if err != nil {
return nil
}
decryptedGroupChange := &signalservice.DecryptedGroupChange{}
decryptedGroupChange := &signalservice.DecryptedGroupChange{
Revision: groupActions.GetRevision(),
}
if groupActions.SourceUuid != nil {
uuid, err := g.cipher.DecryptUUID(groupActions.SourceUuid)
log.Debugln("[textsecure][groupsv2] SourceUuid", idToHex(uuid), err)
}
log.Debugln("[textsecure][groupsv2] Revision", groupActions.Revision)
if groupActions.AddMembers != nil {
log.Debugln("[textsecure][groupsv2] AddMembers")
decryptedAddMembers := []*signalservice.DecryptedMember{}
for _, member := range groupActions.AddMembers {
decryptedMember, err := g.decryptMember(member.Added)
if err == nil {
decryptedAddMembers = append(decryptedAddMembers, decryptedMember)
}
}
decryptedGroupChange.NewMembers = decryptedAddMembers
}
if groupActions.DeleteMembers != nil {
log.Debugln("[textsecure][groupsv2] DeleteMembers")
g.decryptDeletePendingMembers(groupActions.DeletePendingMembers)
decryptedDeleteMembers := [][]byte{}
for _, member := range groupActions.DeleteMembers {
decryptedMember, err := g.decryptUUID(member.DeletedUserId)
if err == nil {
decryptedDeleteMembers = append(decryptedDeleteMembers, decryptedMember)
}
}
decryptedGroupChange.DeleteMembers = decryptedDeleteMembers
}
if groupActions.ModifyMemberRoles != nil {
log.Debugln("[textsecure][groupsv2] ModifyMemberRoles")
decryptedModifyMemberRoles := []*signalservice.DecryptedModifyMemberRole{}
for _, member := range groupActions.ModifyMemberRoles {
decryptedMember, err := g.decryptUUID(member.UserId)

if err == nil {
decryptedModifyMemberRole := signalservice.DecryptedModifyMemberRole{
Uuid: decryptedMember,
Role: member.Role,
}
decryptedModifyMemberRoles = append(decryptedModifyMemberRoles, &decryptedModifyMemberRole)
}
}
decryptedGroupChange.ModifyMemberRoles = decryptedModifyMemberRoles
}
if groupActions.ModifyMemberProfileKeys != nil {
log.Debugln("[textsecure][groupsv2] ModifyMemberProfileKeys")
Expand Down

0 comments on commit 70cf775

Please sign in to comment.