mirror of
https://github.com/anyproto/any-sync.git
synced 2025-06-08 05:57:03 +09:00
31 lines
904 B
Go
31 lines
904 B
Go
package syncacl
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"github.com/anyproto/any-sync/commonspace/object/acl/aclrecordproto"
|
|
"github.com/anyproto/any-sync/commonspace/object/acl/list"
|
|
"github.com/anyproto/any-sync/commonspace/spacesyncproto"
|
|
)
|
|
|
|
type syncAclHandler struct {
|
|
acl list.AclList
|
|
}
|
|
|
|
func (s *syncAclHandler) HandleMessage(ctx context.Context, senderId string, req *spacesyncproto.ObjectSyncMessage) (err error) {
|
|
aclMsg := &aclrecordproto.AclSyncMessage{}
|
|
if err = aclMsg.Unmarshal(req.Payload); err != nil {
|
|
return
|
|
}
|
|
content := aclMsg.GetContent()
|
|
switch {
|
|
case content.GetAddRecords() != nil:
|
|
return s.handleAddRecords(ctx, senderId, content.GetAddRecords())
|
|
default:
|
|
return fmt.Errorf("unexpected aclSync message: %T", content.Value)
|
|
}
|
|
}
|
|
|
|
func (s *syncAclHandler) handleAddRecords(ctx context.Context, senderId string, addRecord *aclrecordproto.AclAddRecords) (err error) {
|
|
return
|
|
}
|