Skip to content

Commit

Permalink
revocation for removed members
Browse files Browse the repository at this point in the history
  • Loading branch information
insipx committed Apr 25, 2024
1 parent f084fc7 commit e26ee33
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
10 changes: 10 additions & 0 deletions pkg/mls/store/queries.sql
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ INSERT INTO inbox_log (inbox_id, server_timestamp_ns, identity_update_proto)
VALUES ($1, $2, $3)
RETURNING sequence_id;

-- name: RevokeAddressFromLog :exec
UPDATE address_log
SET revocation_sequence_id = $1
WHERE (address, inbox_id, association_sequence_id) = (
SELECT address, inbox_id, MAX(association_sequence_id)
FROM address_log AS a
WHERE a.address = $2 AND a.inbox_id = $3
GROUP BY address, inbox_id
);

-- name: CreateInstallation :exec
INSERT INTO installations (id, wallet_address, created_at, updated_at, credential_identity, key_package, expiration)
VALUES ($1, $2, $3, $3, $4, $5, $6);
Expand Down
22 changes: 22 additions & 0 deletions pkg/mls/store/queries/queries.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion pkg/mls/store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,16 @@ func (s *Store) PublishIdentityUpdate(ctx context.Context, req *identity.Publish

// Update address log table
for _, removed_member := range state.StateDiff.RemovedMembers {

if address, ok := removed_member.Kind.(*associations.MemberIdentifier_Address); ok {
err = txQueries.RevokeAddressFromLog(ctx, queries.RevokeAddressFromLogParams{
Address: address.Address,
InboxID: state.AssociationState.InboxId,
RevocationSequenceID: sql.NullInt64{Valid: true, Int64: sequence_id},
})
if err != nil {
return err
}
}
}

return nil
Expand Down

0 comments on commit e26ee33

Please sign in to comment.