userops

package
v0.0.0-...-0b73fe9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 30, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoConnectionRequest = errors.Errorf("No such connection request")
View Source
var ErrUserNotSignedIn = errors.Errorf("One of the users is not signed in")

Functions

func CanSeeProfile

func CanSeeProfile(profile *core.User, visitor *core.User, connRadius ConnectionRadius) bool

func CannotSeeProfileLite

func CannotSeeProfileLite(profile *core.User, visitor *core.User) bool

func CreateConnection

func CreateConnection(ctx context.Context, db boil.ContextExecutor, user1ID string, user2ID string) (*core.UserConnection, *core.UserConnection, error)

CreateConnection assumes it's run in transaction Since connections form an undirected graph, we insert user ids in both combinations to simplify queries with a tradeoff that we need to monitor data for consistency and use twice the size needed

func DecideConnectionRequest

func DecideConnectionRequest(ctx context.Context, exec *sqlx.DB, targetUserID string, requestID string, decision core.ConnectionRequestDecision, note string) error

func DecideForwardMediationRequest

func DecideForwardMediationRequest(ctx context.Context, exec *sqlx.DB, whoUserID string, requestID string, decision core.ConnectionMediationDecision, note string) error

func DropConnection

func DropConnection(ctx context.Context, exec *sqlx.DB, sourceUserID string, targetUserID string) error

func DropConnectionGrant

func DropConnectionGrant(ctx context.Context, exec boil.ContextExecutor, whoUserID string, allowsWhoUserID string) error

func EstablishConnection

func EstablishConnection(ctx context.Context, exec *sqlx.DB, sourceUserID string, targetUserID string) error

func GetDirectAndSecondDegreeUserIDs

func GetDirectAndSecondDegreeUserIDs(ctx context.Context, db boil.ContextExecutor, userID string) (directUserIDs []string, secondDegreeUserIDs []string, via map[string][]string, err error)

func GetDirectUserIDs

func GetDirectUserIDs(ctx context.Context, db boil.ContextExecutor, userID string) ([]string, error)

func GetMediationRequest

func GetMediationRequest(ctx context.Context, exec boil.ContextExecutor, sourceUserID string, targetUserID string) (*core.UserConnectionMediationRequest, error)

func IsConnectionAllowed

func IsConnectionAllowed(ctx context.Context, exec boil.ContextExecutor, sourceUserID string, targetUserID string) (bool, error)

IsConnectionAllowed is used to determine whether sourceUserID is allowed to connect with targetUserID

func RequestMediation

func RequestMediation(ctx context.Context, exec *sqlx.DB, sourceUserID string, targetUserID string, mediationNote string) error

func RevokeMediationRequest

func RevokeMediationRequest(ctx context.Context, exec *sqlx.DB, whoUserID string, targetUserID string) error

Types

type ConnectionRadius

type ConnectionRadius int
const (
	ConnectionRadiusSameUser ConnectionRadius = iota
	ConnectionRadiusDirect
	ConnectionRadiusSecondDegree
	ConnectionRadiusUnrelated
	ConnectionRadiusUnknown
)

func GetConnectionRadius

func GetConnectionRadius(ctx context.Context, db boil.ContextExecutor, fromUserID string, toUserID string) (ConnectionRadius, error)

func (ConnectionRadius) IsDirect

func (cr ConnectionRadius) IsDirect() bool

func (ConnectionRadius) IsSameUser

func (cr ConnectionRadius) IsSameUser() bool

func (ConnectionRadius) IsSecondDegree

func (cr ConnectionRadius) IsSecondDegree() bool

func (ConnectionRadius) IsUnrelated

func (cr ConnectionRadius) IsUnrelated() bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL