service

package
v0.0.0-...-0494513 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2023 License: AGPL-3.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAppNotFound           = status.Error(codes.NotFound, "app not found")
	ErrAppDeleted            = status.Error(codes.NotFound, "app was deleted")
	ErrNotAllowedToModifyApp = status.Errorf(
		codes.PermissionDenied,
		"you are not allowed to modify this application",
	)

	ErrAppReviewNotFound           = status.Error(codes.NotFound, "app review not found")
	ErrAppReviewDeleted            = status.Error(codes.NotFound, "app review was deleted")
	ErrNotAllowedToModifyAppReview = status.Errorf(
		codes.PermissionDenied,
		"you are not allowed to modify this app review",
	)

	ErrWebhookURLNotSpecified = status.Errorf(
		codes.InvalidArgument,
		"WebhookURL not specified",
	)

	ErrAppTokenNotFound                = status.Error(codes.NotFound, "app token not found")
	ErrUserNotAllowedToManageAppTokens = status.Errorf(
		codes.PermissionDenied,
		"user not allowed to manage app tokens",
	)

	ErrAppRoleNotSet = status.Error(codes.FailedPrecondition, "app role not set")
)

Functions

func Between

func Between(v, from, to int64) bool

func ErrInvalidParam

func ErrInvalidParam(param string) error

func ErrRequiredParam

func ErrRequiredParam(param string) error

func ErrUnsupported

func ErrUnsupported[T any](param string, value T) error

func HandlePayload

func HandlePayload[M any](ctx context.Context, evt *event.Event, f func(ctx context.Context, payload M) error) error

func Truncate

func Truncate(s string, n int) string

Types

type Publisher

type Publisher interface {
	PublishEvents(context.Context, ...*event.Event) error
}

type Service

type Service struct {
	bgmngr.Manager
	// contains filtered or unexported fields
}

func New

func New(
	ctx context.Context,
	repo repo.Repository,
	eventBus Publisher,
	circleClient circle.CircleAPIClient,
	authClient authV1.AuthAPIClient,
	roleClient role.RoleAPIClient,
	httpClient *http.Client,
	appScopedTokenLifespan time.Duration,
	userScopedTokenLifespan time.Duration,
) (*Service, error)

func (*Service) AddAppPermission

func (s *Service) AddAppPermission(ctx context.Context, appID, permissionID string) error

func (*Service) AddAppScore

func (s *Service) AddAppScore(ctx context.Context, appID string, score int64) error

func (*Service) AddAppSubscription

func (s *Service) AddAppSubscription(ctx context.Context, appID, subscriptionID string) error

func (*Service) AddAppTag

func (s *Service) AddAppTag(ctx context.Context, appID, tagID string) error

func (*Service) CreateApp

func (s *Service) CreateApp(ctx context.Context, in model.CreateAppInput) (model.App, error)

func (*Service) CreateAppReview

func (s *Service) CreateAppReview(ctx context.Context, in model.CreateAppReviewInput) (model.AppReview, error)

func (*Service) DeleteApp

func (s *Service) DeleteApp(ctx context.Context, appID string) error

func (*Service) DeleteAppReview

func (s *Service) DeleteAppReview(ctx context.Context, reviewID string) error

func (*Service) DeleteAppToken

func (s *Service) DeleteAppToken(ctx context.Context, tokenID string) error

func (*Service) DisableAppByDefault

func (s *Service) DisableAppByDefault(ctx context.Context, appID string) error

func (*Service) DisableAppInCircle

func (s *Service) DisableAppInCircle(ctx context.Context, circleID, appID string) (err error)

func (*Service) DownvoteAppReview

func (s *Service) DownvoteAppReview(ctx context.Context, reviewID string) error

func (*Service) EnableAppByDefault

func (s *Service) EnableAppByDefault(ctx context.Context, appID string) error

func (*Service) EnableAppInCircle

func (s *Service) EnableAppInCircle(ctx context.Context, appID, circleID string) error

func (*Service) EnableAppInCircles

func (s *Service) EnableAppInCircles(ctx context.Context, appID string, circleIDs ...string) error

func (*Service) EnableAppsInCircle

func (s *Service) EnableAppsInCircle(ctx context.Context, circleID string, appIDs ...string) error

func (*Service) FeatureApp

func (s *Service) FeatureApp(ctx context.Context, appID string) error

func (*Service) GenerateAppToken

func (s *Service) GenerateAppToken(ctx context.Context, appID, name string) (model.GeneratedToken, error)

func (*Service) GenerateUserScopedAppToken

func (s *Service) GenerateUserScopedAppToken(ctx context.Context, appID string) (model.GeneratedToken, error)

func (*Service) GetApp

func (s *Service) GetApp(ctx context.Context, id string) (model.App, error)

func (*Service) GetAppCounters

func (s *Service) GetAppCounters(ctx context.Context, id string) (model.AppCounters, error)

func (*Service) GetAppLastUsedAt

func (s *Service) GetAppLastUsedAt(ctx context.Context, appID string) (*time.Time, error)

func (*Service) GetAppPermissions

func (s *Service) GetAppPermissions(ctx context.Context, appID string) ([]model.Permission, error)

func (*Service) GetAppReview

func (s *Service) GetAppReview(ctx context.Context, id string) (model.AppReview, error)

func (*Service) GetAppReviews

func (s *Service) GetAppReviews(
	ctx context.Context,
	appID string,
	c model.Cursor,
) ([]model.AppReview, cursor.Page, error)

func (*Service) GetAppReviewsByUser

func (s *Service) GetAppReviewsByUser(ctx context.Context, appID string) ([]model.AppReview, error)

func (*Service) GetAppSavedAt

func (s *Service) GetAppSavedAt(ctx context.Context, appID string) (*time.Time, error)

func (*Service) GetAppSubscriptions

func (s *Service) GetAppSubscriptions(ctx context.Context, appID string) ([]model.Subscription, error)

func (*Service) GetAppTags

func (s *Service) GetAppTags(ctx context.Context, appID string) ([]model.Tag, error)

func (*Service) GetAppTokens

func (s *Service) GetAppTokens(ctx context.Context, appID string) ([]model.AppToken, error)

func (*Service) GetAppUpvotedAt

func (s *Service) GetAppUpvotedAt(ctx context.Context, appID string) (*time.Time, error)

func (*Service) GetApps

func (s *Service) GetApps(ctx context.Context, ids ...string) ([]model.App, error)

func (*Service) GetAppsEnabledByDefault

func (s *Service) GetAppsEnabledByDefault(
	ctx context.Context,
	f model.GetDefaultAppsFilter,
) ([]model.App, cursor.Page, error)

func (*Service) GetCircleApps

func (s *Service) GetCircleApps(
	ctx context.Context,
	appID, circleID string,
	c *model.Cursor,
) ([]model.CircleApp, cursor.Page, error)

func (*Service) GetDefaultPermissions

func (s *Service) GetDefaultPermissions() []model.Permission

func (*Service) GetEnabledApps

func (s *Service) GetEnabledApps(ctx context.Context, ids ...string) ([]model.App, error)

func (*Service) GetFeaturedApps

func (s *Service) GetFeaturedApps(
	ctx context.Context,
	f model.GetFeaturedAppsFilter,
) ([]model.App, cursor.Page, error)

func (*Service) GetLastUsedApps

func (s *Service) GetLastUsedApps(ctx context.Context, c model.Cursor) ([]model.App, cursor.Page, error)

func (*Service) GetMyApps

func (s *Service) GetMyApps(ctx context.Context) ([]model.App, error)

func (*Service) GetPermissions

func (s *Service) GetPermissions(ctx context.Context, ids ...string) ([]model.Permission, error)

func (*Service) GetSavedApps

func (s *Service) GetSavedApps(ctx context.Context, f model.GetSavedAppsFilter) ([]model.App, cursor.Page, error)

func (*Service) GetSubscriptions

func (s *Service) GetSubscriptions(ctx context.Context, ids ...string) ([]model.Subscription, error)

func (*Service) GetTags

func (s *Service) GetTags(ctx context.Context, ids ...string) ([]model.Tag, error)

func (*Service) GrantAppPermissionsInCircle

func (s *Service) GrantAppPermissionsInCircle(
	ctx context.Context,
	appID, circleID string,
	permIDs ...string,
) (err error)

func (*Service) GrantAppSubscriptionsInCircle

func (s *Service) GrantAppSubscriptionsInCircle(
	ctx context.Context,
	appID, circleID string,
	subIDs ...string,
) (err error)

func (*Service) HandleAppEvent

func (s *Service) HandleAppEvent(ctx context.Context, evt *event.Event) error

func (*Service) HandleAppPermissionAdded

func (s *Service) HandleAppPermissionAdded(ctx context.Context, appID, permissionID, userID string) (err error)

func (*Service) HandleAppSubscription

func (s *Service) HandleAppSubscription(ctx context.Context, e model.AppSubscriptionEvent) error

func (*Service) HandleAppSubscriptionAdded

func (s *Service) HandleAppSubscriptionAdded(ctx context.Context, appID, subscriptionID, userID string) error

func (*Service) HandleChatEvent

func (s *Service) HandleChatEvent(ctx context.Context, evt *event.Event) error

func (*Service) HandleCircleCommentCreated

func (s *Service) HandleCircleCommentCreated(ctx context.Context, eventID, circleID, commentID, userID string) error

func (*Service) HandleCircleCreated

func (s *Service) HandleCircleCreated(ctx context.Context, circleID, userID string) (err error)

func (*Service) HandleCircleDeleted

func (s *Service) HandleCircleDeleted(ctx context.Context, circleID, userID string, deletedAt time.Time) error

func (*Service) HandleCircleEvent

func (s *Service) HandleCircleEvent(ctx context.Context, evt *event.Event) error

func (*Service) HandleCircleMessageSent

func (s *Service) HandleCircleMessageSent(ctx context.Context, eventID, circleID, messageID, userID string) error

func (*Service) HandleCirclePostCreated

func (s *Service) HandleCirclePostCreated(ctx context.Context, eventID, circleID, postID, userID string) error

func (*Service) HandleCommentEvent

func (s *Service) HandleCommentEvent(ctx context.Context, evt *event.Event) error

func (*Service) HandleContentEvent

func (s *Service) HandleContentEvent(ctx context.Context, evt *event.Event) error

func (*Service) HandleDefaultAppCreated

func (s *Service) HandleDefaultAppCreated(ctx context.Context, appID, userID string) error

func (*Service) HandleUserJoinedCircle

func (s *Service) HandleUserJoinedCircle(ctx context.Context, eventID, circleID, userID string) error

func (*Service) HandleUserLeftCircle

func (s *Service) HandleUserLeftCircle(ctx context.Context, eventID, circleID, userID string) error

func (*Service) IssueAppToken

func (s *Service) IssueAppToken(ctx context.Context, tokenID string) (model.IssuedToken, error)

func (*Service) RemoveAppPermission

func (s *Service) RemoveAppPermission(ctx context.Context, appID, permissionID string) error

func (*Service) RemoveAppSubscription

func (s *Service) RemoveAppSubscription(ctx context.Context, appID, subscriptionID string) error

func (*Service) RemoveAppTag

func (s *Service) RemoveAppTag(ctx context.Context, appID, tagID string) error

func (*Service) RevokeAppPermissionsInCircle

func (s *Service) RevokeAppPermissionsInCircle(
	ctx context.Context,
	appID, circleID string,
	permIDs ...string,
) (err error)

func (*Service) RevokeAppSubscriptionsInCircle

func (s *Service) RevokeAppSubscriptionsInCircle(
	ctx context.Context,
	appID, circleID string,
	subIDs ...string,
) (err error)

func (*Service) RevokeAppToken

func (s *Service) RevokeAppToken(ctx context.Context, tokenID string) error

func (*Service) SaveApp

func (s *Service) SaveApp(ctx context.Context, appID string) error

func (*Service) SearchApps

func (s *Service) SearchApps(ctx context.Context, f model.SearchAppsFilter) ([]model.App, cursor.Page, error)

func (*Service) Subscribe

func (s *Service) Subscribe(ctx context.Context, client eventbus.Client) error

func (*Service) UndownvoteAppReview

func (s *Service) UndownvoteAppReview(ctx context.Context, reviewID string) error

func (*Service) UnfeatureApp

func (s *Service) UnfeatureApp(ctx context.Context, appID string) error

func (*Service) UnsaveApp

func (s *Service) UnsaveApp(ctx context.Context, appID string) error

func (*Service) UnupvoteApp

func (s *Service) UnupvoteApp(ctx context.Context, appID string) error

func (*Service) UnupvoteAppReview

func (s *Service) UnupvoteAppReview(ctx context.Context, reviewID string) error

func (*Service) UpdateApp

func (s *Service) UpdateApp(ctx context.Context, appID string, in model.UpdateAppInput) error

func (*Service) UpvoteApp

func (s *Service) UpvoteApp(ctx context.Context, appID string) error

func (*Service) UpvoteAppReview

func (s *Service) UpvoteAppReview(ctx context.Context, reviewID string) error

func (*Service) ValidateAppCreateInput

func (s *Service) ValidateAppCreateInput(ctx context.Context, input model.CreateAppInput) (err error)

func (*Service) ValidateAppDescription

func (s *Service) ValidateAppDescription(_ context.Context, name string) error

func (*Service) ValidateAppImageURL

func (s *Service) ValidateAppImageURL(_ context.Context, u string) error

func (*Service) ValidateAppName

func (s *Service) ValidateAppName(_ context.Context, name string) error

func (*Service) ValidateAppReviewRating

func (s *Service) ValidateAppReviewRating(_ context.Context, rating int64) error

func (*Service) ValidateAppURL

func (s *Service) ValidateAppURL(_ context.Context, u string) error

func (*Service) ValidateAppWebhookURL

func (s *Service) ValidateAppWebhookURL(_ context.Context, u string) error

func (*Service) ValidateCreateAppReviewInput

func (s *Service) ValidateCreateAppReviewInput(ctx context.Context, in model.CreateAppReviewInput) (err error)

func (*Service) ValidatePermissionID

func (s *Service) ValidatePermissionID(_ context.Context, id string) error

func (*Service) ValidateSubscriptionID

func (s *Service) ValidateSubscriptionID(_ context.Context, id string) error

func (*Service) ValidateTagID

func (s *Service) ValidateTagID(_ context.Context, id string) error

func (*Service) ValidateUpdateInput

func (s *Service) ValidateUpdateInput(ctx context.Context, in model.UpdateAppInput) (err error)

Source Files

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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