1
0
Fork 0
mirror of https://github.com/anyproto/any-sync.git synced 2025-06-07 21:47:02 +09:00

Update request to join logic to include cases with two invite links

This commit is contained in:
Mikhail Rakhmanov 2025-05-22 13:28:13 +02:00
parent 3b9880eff8
commit 20f79ee139
No known key found for this signature in database
GPG key ID: DED12CFEF5B8396B
3 changed files with 16 additions and 3 deletions

View file

@ -681,6 +681,13 @@ func (st *AclState) applyInviteJoin(ch *aclrecordproto.AclAccountInviteJoin, rec
}),
}
}
for _, rec := range st.requestRecords {
if rec.RequestIdentity.Equals(identity) {
delete(st.pendingRequests, mapKeyFromPubKey(rec.RequestIdentity))
delete(st.requestRecords, rec.RecordId)
break
}
}
if st.pubKey.Equals(identity) {
return st.unpackAllKeys(ch.EncryptedReadKey)
}

View file

@ -218,7 +218,7 @@ func (a *AclTestExecutor) buildBatchRequest(args []string, acl AclList, getPerm
}
}
if recId == "" {
return nil, fmt.Errorf("no join records for approve")
return nil, fmt.Errorf("no join records to approve")
}
perms := getPerm(argParts[1])
afterAll = append(afterAll, func() {
@ -461,7 +461,7 @@ func (a *AclTestExecutor) Execute(cmd string) (err error) {
}
}
if recId == "" {
return fmt.Errorf("no join records for approve")
return fmt.Errorf("no join records to approve")
}
perms := getPerm(argParts[1])
res, err := acl.RecordBuilder().BuildRequestAccept(RequestAcceptPayload{

View file

@ -90,7 +90,7 @@ func TestAclExecutor(t *testing.T) {
{"g.join::inv1Id", nil},
{"g.cancel::g", nil},
// e cannot approve cancelled request
{"e.approve::g,rw", fmt.Errorf("no join records for approve")},
{"e.approve::g,rw", fmt.Errorf("no join records to approve")},
{"g.join::inv1Id", nil},
{"e.decline::g", nil},
// g cannot cancel declined request
@ -144,6 +144,12 @@ func TestAclExecutor(t *testing.T) {
{"new4.add::super,r,superm", nil},
// check that users can't join using request to join for anyone can join links
{"new5.join::someId", ErrNoSuchInvite},
{"a.invite::requestJoinId", nil},
{"joiner.join::requestJoinId", nil},
// check that users can join under a different link even after they created a request to join
{"joiner.invite_join::someId", nil},
// check that they can't be approved after they joined under a different link
{"a.approve::joiner,rw", fmt.Errorf("no join records to approve")},
}
for _, cmd := range cmds {
err := a.Execute(cmd.cmd)