github.com/cs3org/reva/v2@v2.27.7/pkg/ocm/invite/invite.go (about)

     1  // Copyright 2018-2023 CERN
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  //
    15  // In applying this license, CERN does not waive the privileges and immunities
    16  // granted to it by virtue of its status as an Intergovernmental Organization
    17  // or submit itself to any jurisdiction.
    18  
    19  package invite
    20  
    21  import (
    22  	"context"
    23  	"errors"
    24  
    25  	userpb "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
    26  	invitepb "github.com/cs3org/go-cs3apis/cs3/ocm/invite/v1beta1"
    27  )
    28  
    29  // Repository is the interfaces used to store the tokens and the invited users.
    30  type Repository interface {
    31  	// AddToken stores the token in the repository.
    32  	AddToken(ctx context.Context, token *invitepb.InviteToken) error
    33  
    34  	// GetToken gets the token from the repository.
    35  	GetToken(ctx context.Context, token string) (*invitepb.InviteToken, error)
    36  
    37  	// ListTokens gets the valid tokens from the repository (i.e. not expired).
    38  	ListTokens(ctx context.Context, initiator *userpb.UserId) ([]*invitepb.InviteToken, error)
    39  
    40  	// AddRemoteUser stores the remote user.
    41  	AddRemoteUser(ctx context.Context, initiator *userpb.UserId, remoteUser *userpb.User) error
    42  
    43  	// GetRemoteUser retrieves details about a remote user who has accepted an invite to share.
    44  	GetRemoteUser(ctx context.Context, initiator *userpb.UserId, remoteUserID *userpb.UserId) (*userpb.User, error)
    45  
    46  	// FindRemoteUsers finds remote users who have accepted invites based on their attributes.
    47  	FindRemoteUsers(ctx context.Context, initiator *userpb.UserId, query string) ([]*userpb.User, error)
    48  
    49  	// DeleteRemoteUser removes from the remote user from the initiator's list.
    50  	DeleteRemoteUser(ctx context.Context, initiator *userpb.UserId, remoteUser *userpb.UserId) error
    51  }
    52  
    53  // ErrTokenNotFound is the error returned when the token does not exist.
    54  var ErrTokenNotFound = errors.New("token not found")
    55  
    56  // ErrUserAlreadyAccepted is the error returned when the user was
    57  // already added to the accepted users list.
    58  var ErrUserAlreadyAccepted = errors.New("user already added to accepted users")