1
0
Fork 0
mirror of https://github.com/anyproto/anytype-heart.git synced 2025-06-09 09:35:00 +09:00

GO-2966 Add revoke invite method

This commit is contained in:
mcrakhman 2024-02-27 19:20:49 +01:00
parent d45756d154
commit 83b6bc312c
No known key found for this signature in database
GPG key ID: DED12CFEF5B8396B
4 changed files with 30 additions and 5 deletions

View file

@ -49,6 +49,7 @@ type AccountPermissions struct {
type AclService interface {
app.Component
GenerateInvite(ctx context.Context, spaceId string) (*InviteInfo, error)
RevokeInvite(ctx context.Context, spaceId string) error
GetCurrentInvite(spaceId string) (*InviteInfo, error)
ViewInvite(ctx context.Context, inviteCid cid.Cid, inviteFileKey crypto.SymKey) (*InviteView, error)
Join(ctx context.Context, spaceId string, inviteCid cid.Cid, inviteFileKey crypto.SymKey) error
@ -139,6 +140,23 @@ func (a *aclService) Decline(ctx context.Context, spaceId string, identity crypt
return nil
}
func (a *aclService) RevokeInvite(ctx context.Context, spaceId string) error {
sp, err := a.spaceService.Get(ctx, spaceId)
if err != nil {
return err
}
cl := sp.CommonSpace().AclClient()
err = cl.RevokeAllInvites(ctx)
if err != nil {
return fmt.Errorf("%w, %w", ErrAclRequestFailed, err)
}
spaceViewId, err := a.spaceService.SpaceViewId(spaceId)
if err != nil {
return fmt.Errorf("get space view id: %w", err)
}
return a.removeExistingInviteFileInfo(ctx, spaceViewId)
}
func (a *aclService) ChangePermissions(ctx context.Context, spaceId string, perms []AccountPermissions) error {
sp, err := a.spaceService.Get(ctx, spaceId)
if err != nil {

View file

@ -82,10 +82,17 @@ func (mw *Middleware) SpaceInviteGetCurrent(cctx context.Context, req *pb.RpcSpa
}
func (mw *Middleware) SpaceInviteRevoke(cctx context.Context, req *pb.RpcSpaceInviteRevokeRequest) *pb.RpcSpaceInviteRevokeResponse {
aclService := mw.applicationService.GetApp().MustComponent(acl.CName).(acl.AclService)
err := aclService.RevokeInvite(cctx, req.SpaceId)
code := mapErrorCode(err,
errToCode(space.ErrSpaceDeleted, pb.RpcSpaceInviteRevokeResponseError_SPACE_IS_DELETED),
errToCode(space.ErrSpaceNotExists, pb.RpcSpaceInviteRevokeResponseError_NO_SUCH_SPACE),
errToCode(acl.ErrAclRequestFailed, pb.RpcSpaceInviteRevokeResponseError_REQUEST_FAILED),
)
return &pb.RpcSpaceInviteRevokeResponse{
Error: &pb.RpcSpaceInviteRevokeResponseError{
Code: 1,
Description: getErrorDescription(fmt.Errorf("not implemented")),
Code: code,
Description: getErrorDescription(err),
},
}
}

2
go.mod
View file

@ -7,7 +7,7 @@ require (
github.com/PuerkitoBio/goquery v1.8.1
github.com/VividCortex/ewma v1.2.0
github.com/adrium/goheif v0.0.0-20230113233934-ca402e77a786
github.com/anyproto/any-sync v0.3.26
github.com/anyproto/any-sync v0.3.27
github.com/anyproto/go-naturaldate/v2 v2.0.2-0.20230524105841-9829cfd13438
github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de
github.com/blevesearch/bleve/v2 v2.3.10

4
go.sum
View file

@ -108,8 +108,8 @@ github.com/andybalholm/cascadia v1.2.0/go.mod h1:YCyR8vOZT9aZ1CHEd8ap0gMVm2aFgxB
github.com/andybalholm/cascadia v1.3.1/go.mod h1:R4bJ1UQfqADjvDa4P6HZHLh/3OxWWEqc0Sk8XGwHqvA=
github.com/andybalholm/cascadia v1.3.2 h1:3Xi6Dw5lHF15JtdcmAHD3i1+T8plmv7BQ/nsViSLyss=
github.com/andybalholm/cascadia v1.3.2/go.mod h1:7gtRlve5FxPPgIgX36uWBX58OdBsSS6lUvCFb+h7KvU=
github.com/anyproto/any-sync v0.3.26 h1:LhLc7e4EDb02l0jNqCnbxczk2Xh8RiUtXQE2P/mHD0E=
github.com/anyproto/any-sync v0.3.26/go.mod h1:xAzQ+njdF1FM1SD5nw1aUbhLh0tiOmzY0hrFajuY6Ik=
github.com/anyproto/any-sync v0.3.27 h1:acT5oSqLXpAbEGHeAbkMDVbV8iHzLAd3Q+1ugLVlBBY=
github.com/anyproto/any-sync v0.3.27/go.mod h1:xAzQ+njdF1FM1SD5nw1aUbhLh0tiOmzY0hrFajuY6Ik=
github.com/anyproto/badger/v4 v4.2.1-0.20240110160636-80743fa3d580 h1:Ba80IlCCxkZ9H1GF+7vFu/TSpPvbpDCxXJ5ogc4euYc=
github.com/anyproto/badger/v4 v4.2.1-0.20240110160636-80743fa3d580/go.mod h1:T/uWAYxrXdaXw64ihI++9RMbKTCpKd/yE9+saARew7k=
github.com/anyproto/go-chash v0.1.0 h1:I9meTPjXFRfXZHRJzjOHC/XF7Q5vzysKkiT/grsogXY=