actions

package
v0.0.0-...-acda5ee Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2023 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Actionable

type Actionable interface {
	IsAuthorized(ctx context.Context, user *entity.User) bool
	Validate(ctx context.Context, user *entity.User) *validate.Result
}

Actionable is any action that the user can perform using the web app

type AddNewComment

type AddNewComment struct {
	Number      int                `route:"number"`
	Content     string             `json:"content"`
	Attachments []*dto.ImageUpload `json:"attachments"`
}

AddNewComment represents a new comment to be added

func (*AddNewComment) IsAuthorized

func (action *AddNewComment) IsAuthorized(ctx context.Context, user *entity.User) bool

IsAuthorized returns true if current user is authorized to perform this action

func (*AddNewComment) Validate

func (action *AddNewComment) Validate(ctx context.Context, user *entity.User) *validate.Result

Validate if current model is valid

type AssignUnassignTag

type AssignUnassignTag struct {
	Slug   string `route:"slug"`
	Number int    `route:"number"`

	Tag  *entity.Tag
	Post *entity.Post
}

AssignUnassignTag is used to assign or remove a tag to/from an post

func (*AssignUnassignTag) IsAuthorized

func (action *AssignUnassignTag) IsAuthorized(ctx context.Context, user *entity.User) bool

IsAuthorized returns true if current user is authorized to perform this action

func (*AssignUnassignTag) Validate

func (action *AssignUnassignTag) Validate(ctx context.Context, user *entity.User) *validate.Result

Validate if current model is valid

type ChangeUserEmail

type ChangeUserEmail struct {
	Email           string `json:"email" format:"lower"`
	VerificationKey string
	Requestor       *entity.User
}

ChangeUserEmail is the action used to change current user's email

func NewChangeUserEmail

func NewChangeUserEmail() *ChangeUserEmail

func (*ChangeUserEmail) GetEmail

func (action *ChangeUserEmail) GetEmail() string

GetEmail returns the email being verified

func (*ChangeUserEmail) GetKind

func (action *ChangeUserEmail) GetKind() enum.EmailVerificationKind

GetKind returns EmailVerificationKindSignIn

func (*ChangeUserEmail) GetName

func (action *ChangeUserEmail) GetName() string

GetName returns empty for this kind of process

func (*ChangeUserEmail) GetUser

func (action *ChangeUserEmail) GetUser() *entity.User

GetUser returns the current user performing this action

func (*ChangeUserEmail) IsAuthorized

func (action *ChangeUserEmail) IsAuthorized(ctx context.Context, user *entity.User) bool

IsAuthorized returns true if current user is authorized to perform this action

func (*ChangeUserEmail) Validate

func (action *ChangeUserEmail) Validate(ctx context.Context, user *entity.User) *validate.Result

Validate if current model is valid

type ChangeUserRole

type ChangeUserRole struct {
	Role   enum.Role `route:"role"`
	UserID int       `json:"userID"`
}

ChangeUserRole is the input model change role of an user

func (*ChangeUserRole) IsAuthorized

func (action *ChangeUserRole) IsAuthorized(ctx context.Context, user *entity.User) bool

IsAuthorized returns true if current user is authorized to perform this action

func (*ChangeUserRole) Validate

func (action *ChangeUserRole) Validate(ctx context.Context, user *entity.User) *validate.Result

Validate if current model is valid

type CompleteProfile

type CompleteProfile struct {
	Kind enum.EmailVerificationKind `json:"kind"`
	Key  string                     `json:"key"`
	Name string                     `json:"name"`
}

CompleteProfile happens when users completes their profile during first time sign in

func (*CompleteProfile) IsAuthorized

func (action *CompleteProfile) IsAuthorized(ctx context.Context, user *entity.User) bool

IsAuthorized returns true if current user is authorized to perform this action

func (*CompleteProfile) Validate

func (action *CompleteProfile) Validate(ctx context.Context, user *entity.User) *validate.Result

Validate if current model is valid

type CreateEditOAuthConfig

type CreateEditOAuthConfig struct {
	ID                int
	Provider          string           `json:"provider"`
	Status            int              `json:"status"`
	DisplayName       string           `json:"displayName"`
	ClientID          string           `json:"clientID"`
	ClientSecret      string           `json:"clientSecret"`
	AuthorizeURL      string           `json:"authorizeURL"`
	ImageURL          string           `json:"imageURL"`
	TokenURL          string           `json:"tokenURL"`
	Scope             string           `json:"scope"`
	ProfileURL        string           `json:"profileURL"`
	IsTrusted         bool             `json:"isTrusted"`
	JSONUserIDPath    string           `json:"jsonUserIDPath"`
	JSONUserNamePath  string           `json:"jsonUserNamePath"`
	JSONUserEmailPath string           `json:"jsonUserEmailPath"`
}

CreateEditOAuthConfig is used to create/edit OAuth config

func NewCreateEditOAuthConfig

func NewCreateEditOAuthConfig() *CreateEditOAuthConfig

func (*CreateEditOAuthConfig) IsAuthorized

func (action *CreateEditOAuthConfig) IsAuthorized(ctx context.Context, user *entity.User) bool

IsAuthorized returns true if current user is authorized to perform this action

func (*CreateEditOAuthConfig) Validate

func (action *CreateEditOAuthConfig) Validate(ctx context.Context, user *entity.User) *validate.Result

Validate if current model is valid

type CreateEditTag

type CreateEditTag struct {
	Slug     string `route:"slug"`
	Name     string `json:"name"`
	Color    string `json:"color" format:"upper"`
	IsPublic bool   `json:"isPublic"`

	Tag *entity.Tag
}

CreateEditTag is used to create a new tag or edit existing

func (*CreateEditTag) IsAuthorized

func (action *CreateEditTag) IsAuthorized(ctx context.Context, user *entity.User) bool

IsAuthorized returns true if current user is authorized to perform this action

func (*CreateEditTag) Validate

func (action *CreateEditTag) Validate(ctx context.Context, user *entity.User) *validate.Result

Validate if current model is valid

type CreateEditWebhook

type CreateEditWebhook struct {
	Name        string             `json:"name"`
	Type        enum.WebhookType   `json:"type"`
	Status      enum.WebhookStatus `json:"status"`
	Url         string             `json:"url"`
	Content     string             `json:"content"`
	HttpMethod  string             `json:"http_method"`
	HttpHeaders entity.HttpHeaders `json:"http_headers"`
}

func (*CreateEditWebhook) IsAuthorized

func (action *CreateEditWebhook) IsAuthorized(_ context.Context, user *entity.User) bool

IsAuthorized returns true if current user is authorized to perform this action

func (*CreateEditWebhook) Validate

func (action *CreateEditWebhook) Validate(ctx context.Context, _ *entity.User) *validate.Result

Validate if current model is valid

type CreateNewPost

type CreateNewPost struct {
	Title       string             `json:"title"`
	Description string             `json:"description"`
	Attachments []*dto.ImageUpload `json:"attachments"`
}

CreateNewPost is used to create a new post

func (*CreateNewPost) IsAuthorized

func (action *CreateNewPost) IsAuthorized(ctx context.Context, user *entity.User) bool

IsAuthorized returns true if current user is authorized to perform this action

func (*CreateNewPost) Validate

func (action *CreateNewPost) Validate(ctx context.Context, user *entity.User) *validate.Result

Validate if current model is valid

type CreateTenant

type CreateTenant struct {
	Token           string `json:"token"`
	Name            string `json:"name"`
	Email           string `json:"email" format:"lower"`
	VerificationKey string
	TenantName      string `json:"tenantName"`
	LegalAgreement  bool   `json:"legalAgreement"`
	Subdomain       string `json:"subdomain" format:"lower"`
	UserClaims      *jwt.OAuthClaims
}

CreateTenant is the input model used to create a tenant

func NewCreateTenant

func NewCreateTenant() *CreateTenant

func (*CreateTenant) GetEmail

func (action *CreateTenant) GetEmail() string

GetEmail returns the email being verified

func (*CreateTenant) GetKind

func (action *CreateTenant) GetKind() enum.EmailVerificationKind

GetKind returns EmailVerificationKindSignUp

func (*CreateTenant) GetName

func (action *CreateTenant) GetName() string

GetName returns the name of the email owner

func (*CreateTenant) GetUser

func (action *CreateTenant) GetUser() *entity.User

GetUser returns the current user performing this action

func (*CreateTenant) IsAuthorized

func (action *CreateTenant) IsAuthorized(ctx context.Context, user *entity.User) bool

IsAuthorized returns true if current user is authorized to perform this action

func (*CreateTenant) Validate

func (action *CreateTenant) Validate(ctx context.Context, user *entity.User) *validate.Result

Validate if current model is valid

type CreateUser

type CreateUser struct {
	Name      string `json:"name"`
	Email     string `json:"email"`
	Reference string `json:"reference"`
}

CreateUser is the action to create a new user

func (*CreateUser) IsAuthorized

func (action *CreateUser) IsAuthorized(ctx context.Context, user *entity.User) bool

IsAuthorized returns true if current user is authorized to perform this action

func (*CreateUser) Validate

func (action *CreateUser) Validate(ctx context.Context, user *entity.User) *validate.Result

Validate if current model is valid

type DeleteComment

type DeleteComment struct {
	PostNumber int `route:"number"`
	CommentID  int `route:"id"`
}

DeleteComment represents the action of deleting an existing comment

func (*DeleteComment) IsAuthorized

func (action *DeleteComment) IsAuthorized(ctx context.Context, user *entity.User) bool

IsAuthorized returns true if current user is authorized to perform this action

func (*DeleteComment) Validate

func (action *DeleteComment) Validate(ctx context.Context, user *entity.User) *validate.Result

Validate if current model is valid

type DeletePost

type DeletePost struct {
	Number int    `route:"number"`
	Text   string `json:"text"`

	Post *entity.Post
}

DeletePost represents the action of an administrator deleting an existing Post

func (*DeletePost) IsAuthorized

func (action *DeletePost) IsAuthorized(ctx context.Context, user *entity.User) bool

IsAuthorized returns true if current user is authorized to perform this action

func (*DeletePost) Validate

func (action *DeletePost) Validate(ctx context.Context, user *entity.User) *validate.Result

Validate if current model is valid

type DeleteTag

type DeleteTag struct {
	Slug string `route:"slug"`

	Tag *entity.Tag
}

DeleteTag is used to delete an existing tag

func (*DeleteTag) IsAuthorized

func (action *DeleteTag) IsAuthorized(ctx context.Context, user *entity.User) bool

IsAuthorized returns true if current user is authorized to perform this action

func (*DeleteTag) Validate

func (action *DeleteTag) Validate(ctx context.Context, user *entity.User) *validate.Result

Validate if current model is valid

type EditComment

type EditComment struct {
	PostNumber  int                `route:"number"`
	ID          int                `route:"id"`
	Content     string             `json:"content"`
	Attachments []*dto.ImageUpload `json:"attachments"`

	Post    *entity.Post
	Comment *entity.Comment
}

EditComment represents the action to update an existing comment

func (*EditComment) IsAuthorized

func (action *EditComment) IsAuthorized(ctx context.Context, user *entity.User) bool

IsAuthorized returns true if current user is authorized to perform this action

func (*EditComment) Validate

func (action *EditComment) Validate(ctx context.Context, user *entity.User) *validate.Result

Validate if current model is valid

type GenerateCheckoutLink struct {
	PlanID string `json:"planId"`
}

GenerateCheckoutLink is used to generate a Paddle-hosted checkout link for the service subscription

func (*GenerateCheckoutLink) IsAuthorized

func (action *GenerateCheckoutLink) IsAuthorized(ctx context.Context, user *entity.User) bool

IsAuthorized returns true if current user is authorized to perform this action

func (*GenerateCheckoutLink) Validate

func (action *GenerateCheckoutLink) Validate(ctx context.Context, user *entity.User) *validate.Result

Validate if current model is valid

type GitHubIssue

type GitHubIssue struct {
	RepoID int    `json:"repoid"`
	PostID int    `route:"postid"`
	Title  string `json:"postTitle"`
	Body   string `json:"postBody"`
}

func (*GitHubIssue) IsAuthorized

func (action *GitHubIssue) IsAuthorized(ctx context.Context, user *entity.User) bool

func (*GitHubIssue) Validate

func (action *GitHubIssue) Validate(ctx context.Context, user *entity.User) *validate.Result

Validate if current model is valid

type InviteUsers

type InviteUsers struct {
	Subject        string   `json:"subject"`
	Message        string   `json:"message"`
	Recipients     []string `json:"recipients" format:"lower"`
	IsSampleInvite bool

	Invitations []*UserInvitation
}

InviteUsers is used to invite new users into Templates

func (*InviteUsers) IsAuthorized

func (action *InviteUsers) IsAuthorized(ctx context.Context, user *entity.User) bool

IsAuthorized returns true if current user is authorized to perform this action

func (*InviteUsers) Validate

func (action *InviteUsers) Validate(ctx context.Context, user *entity.User) *validate.Result

Validate if current model is valid

type PreExecuteAction

type PreExecuteAction interface {
	OnPreExecute(ctx context.Context) error
}

PreExecuteAction can add custom pre processing logic for any action OnPreExecute is executed before IsAuthorized and Validate

type PreviewWebhook

type PreviewWebhook struct {
	Type    enum.WebhookType `json:"type"`
	Url     string           `json:"url"`
	Content string           `json:"content"`
}

func (*PreviewWebhook) IsAuthorized

func (action *PreviewWebhook) IsAuthorized(_ context.Context, user *entity.User) bool

IsAuthorized returns true if current user is authorized to perform this action

func (*PreviewWebhook) Validate

func (action *PreviewWebhook) Validate(context.Context, *entity.User) *validate.Result

Validate if current model is valid

type SetResponse

type SetResponse struct {
	Number         int             `route:"number"`
	Status         enum.PostStatus `json:"status"`
	Text           string          `json:"text"`
	OriginalNumber int             `json:"originalNumber"`

	Original *entity.Post
}

SetResponse represents the action to update an post response

func (*SetResponse) IsAuthorized

func (action *SetResponse) IsAuthorized(ctx context.Context, user *entity.User) bool

IsAuthorized returns true if current user is authorized to perform this action

func (*SetResponse) Validate

func (action *SetResponse) Validate(ctx context.Context, user *entity.User) *validate.Result

Validate if current model is valid

type SignInByEmail

type SignInByEmail struct {
	Email           string `json:"email" format:"lower"`
	VerificationKey string
}

SignInByEmail happens when user request to sign in by email

func NewSignInByEmail

func NewSignInByEmail() *SignInByEmail

func (*SignInByEmail) GetEmail

func (action *SignInByEmail) GetEmail() string

GetEmail returns the email being verified

func (*SignInByEmail) GetKind

func (action *SignInByEmail) GetKind() enum.EmailVerificationKind

GetKind returns EmailVerificationKindSignIn

func (*SignInByEmail) GetName

func (action *SignInByEmail) GetName() string

GetName returns empty for this kind of process

func (*SignInByEmail) GetUser

func (action *SignInByEmail) GetUser() *entity.User

GetUser returns the current user performing this action

func (*SignInByEmail) IsAuthorized

func (action *SignInByEmail) IsAuthorized(ctx context.Context, user *entity.User) bool

IsAuthorized returns true if current user is authorized to perform this action

func (*SignInByEmail) Validate

func (action *SignInByEmail) Validate(ctx context.Context, user *entity.User) *validate.Result

Validate if current model is valid

type UpdatePost

type UpdatePost struct {
	Number      int                `route:"number"`
	Title       string             `json:"title"`
	Description string             `json:"description"`
	Attachments []*dto.ImageUpload `json:"attachments"`

	Post *entity.Post
}

UpdatePost is used to edit an existing new post

func (*UpdatePost) IsAuthorized

func (input *UpdatePost) IsAuthorized(ctx context.Context, user *entity.User) bool

IsAuthorized returns true if current user is authorized to perform this action

func (*UpdatePost) OnPreExecute

func (input *UpdatePost) OnPreExecute(ctx context.Context) error

OnPreExecute prefetches Post for later use

func (*UpdatePost) Validate

func (action *UpdatePost) Validate(ctx context.Context, user *entity.User) *validate.Result

Validate if current model is valid

type UpdateTenantAdvancedSettings

type UpdateTenantAdvancedSettings struct {
	CustomCSS string `json:"customCSS"`
}

UpdateTenantAdvancedSettings is the input model used to update tenant advanced settings

func (*UpdateTenantAdvancedSettings) IsAuthorized

func (action *UpdateTenantAdvancedSettings) IsAuthorized(ctx context.Context, user *entity.User) bool

IsAuthorized returns true if current user is authorized to perform this action

func (*UpdateTenantAdvancedSettings) Validate

func (action *UpdateTenantAdvancedSettings) Validate(ctx context.Context, user *entity.User) *validate.Result

Validate if current model is valid

type UpdateTenantEmailAuthAllowed

type UpdateTenantEmailAuthAllowed struct {
	IsEmailAuthAllowed bool `json:"isEmailAuthAllowed"`
}

UpdateTenantEmailAuthAllowed is the input model used to update tenant privacy settings

func (*UpdateTenantEmailAuthAllowed) IsAuthorized

func (action *UpdateTenantEmailAuthAllowed) IsAuthorized(ctx context.Context, user *entity.User) bool

IsAuthorized returns true if current user is authorized to perform this action

func (*UpdateTenantEmailAuthAllowed) Validate

func (action *UpdateTenantEmailAuthAllowed) Validate(ctx context.Context, user *entity.User) *validate.Result

Validate if current model is valid

type UpdateTenantGitHubIntegration

type UpdateTenantGitHubIntegration struct {
	IsGitHubEnabled bool `json:"isGitHubEnabled"`
}

func (*UpdateTenantGitHubIntegration) IsAuthorized

func (action *UpdateTenantGitHubIntegration) IsAuthorized(ctx context.Context, user *entity.User) bool

func (*UpdateTenantGitHubIntegration) Validate

func (action *UpdateTenantGitHubIntegration) Validate(ctx context.Context, user *entity.User) *validate.Result

Validate if current model is valid

type UpdateTenantGitHubSettings

type UpdateTenantGitHubSettings struct {
	Token string `json:"token"`
	Repo  string `json:"repo"`
	Owner string `json:"owner"`
	ID    int    `route:"id"`
}

This specifies the HTTP post format the JSON is in. The JSON ID must reflect what is being passed from the tsx page.

func (*UpdateTenantGitHubSettings) IsAuthorized

func (action *UpdateTenantGitHubSettings) IsAuthorized(ctx context.Context, user *entity.User) bool

func (*UpdateTenantGitHubSettings) Validate

func (action *UpdateTenantGitHubSettings) Validate(ctx context.Context, user *entity.User) *validate.Result

Validate if current model is valid

type UpdateTenantPrivacy

type UpdateTenantPrivacy struct {
	IsPrivate bool `json:"isPrivate"`
}

UpdateTenantPrivacy is the input model used to update tenant privacy settings

func (*UpdateTenantPrivacy) IsAuthorized

func (action *UpdateTenantPrivacy) IsAuthorized(ctx context.Context, user *entity.User) bool

IsAuthorized returns true if current user is authorized to perform this action

func (*UpdateTenantPrivacy) Validate

func (action *UpdateTenantPrivacy) Validate(ctx context.Context, user *entity.User) *validate.Result

Validate if current model is valid

type UpdateTenantSettings

type UpdateTenantSettings struct {
	Title          string           `json:"title"`
	Invitation     string           `json:"invitation"`
	WelcomeMessage string           `json:"welcomeMessage"`
	Locale         string           `json:"locale"`
	CNAME          string           `json:"cname" format:"lower"`
}

UpdateTenantSettings is the input model used to update tenant settings

func NewUpdateTenantSettings

func NewUpdateTenantSettings() *UpdateTenantSettings

func (*UpdateTenantSettings) IsAuthorized

func (action *UpdateTenantSettings) IsAuthorized(ctx context.Context, user *entity.User) bool

IsAuthorized returns true if current user is authorized to perform this action

func (*UpdateTenantSettings) Validate

func (action *UpdateTenantSettings) Validate(ctx context.Context, user *entity.User) *validate.Result

Validate if current model is valid

type UpdateUserSettings

type UpdateUserSettings struct {
	Name       string            `json:"name"`
	AvatarType enum.AvatarType   `json:"avatarType"`
	Avatar     *dto.ImageUpload  `json:"avatar"`
	Settings   map[string]string `json:"settings"`
}

UpdateUserSettings happens when users updates their settings

func NewUpdateUserSettings

func NewUpdateUserSettings() *UpdateUserSettings

func (*UpdateUserSettings) IsAuthorized

func (action *UpdateUserSettings) IsAuthorized(ctx context.Context, user *entity.User) bool

IsAuthorized returns true if current user is authorized to perform this action

func (*UpdateUserSettings) Validate

func (action *UpdateUserSettings) Validate(ctx context.Context, user *entity.User) *validate.Result

Validate if current model is valid

type UserInvitation

type UserInvitation struct {
	Email           string
	VerificationKey string
}

UserInvitation is the model used to register an invite sent to an user

func (*UserInvitation) GetEmail

func (e *UserInvitation) GetEmail() string

GetEmail returns the invited user's email

func (*UserInvitation) GetKind

GetKind returns EmailVerificationKindUserInvitation

func (*UserInvitation) GetName

func (e *UserInvitation) GetName() string

GetName returns empty for this kind of process

func (*UserInvitation) GetUser

func (e *UserInvitation) GetUser() *entity.User

GetUser returns the current user performing this action

Jump to

Keyboard shortcuts

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