actions

package
v0.21.1 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2022 License: AGPL-3.0 Imports: 19 Imported by: 20

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 added in v0.8.0

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 added in v0.8.0

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 added in v0.8.0

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

Validate if current model is valid

type ChangeUserEmail added in v0.9.0

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 added in v0.19.0

func NewChangeUserEmail() *ChangeUserEmail

func (*ChangeUserEmail) GetEmail added in v0.19.0

func (action *ChangeUserEmail) GetEmail() string

GetEmail returns the email being verified

func (*ChangeUserEmail) GetKind added in v0.19.0

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

GetKind returns EmailVerificationKindSignIn

func (*ChangeUserEmail) GetName added in v0.19.0

func (action *ChangeUserEmail) GetName() string

GetName returns empty for this kind of process

func (*ChangeUserEmail) GetUser added in v0.19.0

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

GetUser returns the current user performing this action

func (*ChangeUserEmail) IsAuthorized added in v0.9.0

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 added in v0.9.0

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

Validate if current model is valid

type ChangeUserRole added in v0.7.0

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 added in v0.7.0

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 added in v0.7.0

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

Validate if current model is valid

type CompleteProfile added in v0.6.0

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 added in v0.6.0

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 added in v0.6.0

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

Validate if current model is valid

type CreateEditOAuthConfig added in v0.15.0

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"`
	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 added in v0.19.0

func NewCreateEditOAuthConfig() *CreateEditOAuthConfig

func (*CreateEditOAuthConfig) IsAuthorized added in v0.15.0

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 added in v0.15.0

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

Validate if current model is valid

type CreateEditTag added in v0.8.0

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 added in v0.8.0

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 added in v0.8.0

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

Validate if current model is valid

type CreateEditWebhook added in v0.20.0

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 added in v0.20.0

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 added in v0.20.0

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

Validate if current model is valid

type CreateNewPost added in v0.15.0

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 added in v0.15.0

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 added in v0.15.0

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 added in v0.19.0

func NewCreateTenant() *CreateTenant

func (*CreateTenant) GetEmail added in v0.19.0

func (action *CreateTenant) GetEmail() string

GetEmail returns the email being verified

func (*CreateTenant) GetKind added in v0.19.0

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

GetKind returns EmailVerificationKindSignUp

func (*CreateTenant) GetName added in v0.19.0

func (action *CreateTenant) GetName() string

GetName returns the name of the email owner

func (*CreateTenant) GetUser added in v0.19.0

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 added in v0.16.0

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 added in v0.16.0

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 added in v0.16.0

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

Validate if current model is valid

type DeleteComment added in v0.16.0

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

DeleteComment represents the action of deleting an existing comment

func (*DeleteComment) IsAuthorized added in v0.16.0

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 added in v0.16.0

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

Validate if current model is valid

type DeletePost added in v0.15.0

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 added in v0.15.0

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 added in v0.15.0

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

Validate if current model is valid

type DeleteTag added in v0.8.0

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

	Tag *entity.Tag
}

DeleteTag is used to delete an existing tag

func (*DeleteTag) IsAuthorized added in v0.8.0

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 added in v0.8.0

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

Validate if current model is valid

type EditComment added in v0.11.0

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 added in v0.11.0

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 added in v0.11.0

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

Validate if current model is valid

type InviteUsers added in v0.12.0

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 Fider

func (*InviteUsers) IsAuthorized added in v0.12.0

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 added in v0.12.0

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

Validate if current model is valid

type PreExecuteAction added in v0.19.0

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 added in v0.20.0

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

func (*PreviewWebhook) IsAuthorized added in v0.20.0

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 added in v0.20.0

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 added in v0.6.0

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

SignInByEmail happens when user request to sign in by email

func NewSignInByEmail added in v0.19.0

func NewSignInByEmail() *SignInByEmail

func (*SignInByEmail) GetEmail added in v0.19.0

func (action *SignInByEmail) GetEmail() string

GetEmail returns the email being verified

func (*SignInByEmail) GetKind added in v0.19.0

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

GetKind returns EmailVerificationKindSignIn

func (*SignInByEmail) GetName added in v0.19.0

func (action *SignInByEmail) GetName() string

GetName returns empty for this kind of process

func (*SignInByEmail) GetUser added in v0.19.0

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

GetUser returns the current user performing this action

func (*SignInByEmail) IsAuthorized added in v0.6.0

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 added in v0.6.0

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

Validate if current model is valid

type UpdatePost added in v0.15.0

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 added in v0.15.0

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 added in v0.19.0

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

OnPreExecute prefetches Post for later use

func (*UpdatePost) Validate added in v0.15.0

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

Validate if current model is valid

type UpdateTenantAdvancedSettings added in v0.13.0

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

UpdateTenantAdvancedSettings is the input model used to update tenant advanced settings

func (*UpdateTenantAdvancedSettings) IsAuthorized added in v0.13.0

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 added in v0.13.0

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

Validate if current model is valid

type UpdateTenantEmailAuthAllowed added in v0.19.0

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

UpdateTenantEmailAuthAllowed is the input model used to update tenant privacy settings

func (*UpdateTenantEmailAuthAllowed) IsAuthorized added in v0.19.0

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 added in v0.19.0

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

Validate if current model is valid

type UpdateTenantPrivacy added in v0.12.0

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

UpdateTenantPrivacy is the input model used to update tenant privacy settings

func (*UpdateTenantPrivacy) IsAuthorized added in v0.12.0

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 added in v0.12.0

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 added in v0.19.0

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 added in v0.6.0

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 added in v0.19.0

func NewUpdateUserSettings() *UpdateUserSettings

func (*UpdateUserSettings) IsAuthorized added in v0.6.0

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 added in v0.6.0

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

Validate if current model is valid

type UserInvitation added in v0.19.0

type UserInvitation struct {
	Email           string
	VerificationKey string
}

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

func (*UserInvitation) GetEmail added in v0.19.0

func (e *UserInvitation) GetEmail() string

GetEmail returns the invited user's email

func (*UserInvitation) GetKind added in v0.19.0

GetKind returns EmailVerificationKindUserInvitation

func (*UserInvitation) GetName added in v0.19.0

func (e *UserInvitation) GetName() string

GetName returns empty for this kind of process

func (*UserInvitation) GetUser added in v0.19.0

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