Documentation
¶
Index ¶
- Constants
- Variables
- func CallCaptcha(fn func(fn Captcha) error) error
- func CaptchaEnabled() (enabled bool)
- func GetPluginUserConfig(userID, pluginSlugName string) []byte
- func ImporterEnabled() (enabled bool)
- func MakePlugin[T Base](super bool) (CallFn[T], RegisterFn[T])
- func RankAgentEnabled() (enabled bool)
- func Register(p Base)
- func RegisterGetPluginUserConfigFunc(fn func(userID, pluginSlugName string) []byte)
- func RegisterGetSiteURLFunc(fn func() string)
- func SiteURL() string
- func Translate(ctx *GinContext, key string) string
- func TranslateWithData(lang i18n.Language, key string, data any) string
- func UserCenterEnabled() (enabled bool)
- type Agent
- type Base
- type CDN
- type Cache
- type CallFn
- type Caller
- type Captcha
- type Config
- type ConfigField
- type ConfigFieldOption
- type ConfigFieldUIOptions
- type ConfigType
- type Connector
- type ControlCenter
- type Data
- type Embed
- type EmbedConfig
- type ExternalLoginUserInfo
- type Filter
- type GinContext
- type Importer
- type ImporterFunc
- type Info
- type InputType
- type KVOperator
- func (kv *KVOperator) Del(ctx context.Context, params KVParams) error
- func (kv *KVOperator) Get(ctx context.Context, params KVParams) (string, error)
- func (kv *KVOperator) GetByGroup(ctx context.Context, params KVParams) (map[string]string, error)
- func (kv *KVOperator) Option(opts ...KVStorageOption)
- func (kv *KVOperator) Set(ctx context.Context, params KVParams) error
- func (kv *KVOperator) Tx(ctx context.Context, fn func(ctx context.Context, kv *KVOperator) error) error
- type KVParams
- type KVStorage
- type KVStorageOption
- type LoadingAction
- type LoadingActionType
- type Notification
- type NotificationMessage
- type NotificationType
- type OnCompleteAction
- type Parser
- type PersonalBranding
- type QuestionImporterInfo
- type RegisterFn
- type Render
- type RenderConfig
- type ReviewContent
- type ReviewContentAuthor
- type ReviewResult
- type ReviewStatus
- type Reviewer
- type Search
- type SearchAcceptedCond
- type SearchBasicCond
- type SearchContent
- type SearchContentStatus
- type SearchDesc
- type SearchOrderCond
- type SearchResult
- type SearchSyncer
- type SettingInfo
- type Stack
- type Storage
- type TranslateFn
- type Translator
- type UIOptionAction
- type UploadFileCondition
- type UploadFileResponse
- type UploadSource
- type UserCenter
- type UserCenterBasicUserInfo
- type UserCenterDesc
- type UserConfig
- type UserStatus
Constants ¶
const ( SearchContentStatusAvailable = 1 SearchContentStatusDeleted = 10 )
Variables ¶
var ( // ErrKVKeyNotFound is returned when the requested key does not exist in the KV storage ErrKVKeyNotFound = fmt.Errorf("key not found in KV storage") // ErrKVGroupEmpty is returned when a required group name is empty ErrKVGroupEmpty = fmt.Errorf("group name is empty") // ErrKVKeyEmpty is returned when a required key name is empty ErrKVKeyEmpty = fmt.Errorf("key name is empty") // ErrKVKeyAndGroupEmpty is returned when both key and group names are empty ErrKVKeyAndGroupEmpty = fmt.Errorf("both key and group are empty") // ErrKVTransactionFailed is returned when a KV storage transaction operation fails ErrKVTransactionFailed = fmt.Errorf("KV storage transaction failed") )
Error variables for KV storage operations
var (
CallAgent, _ = MakePlugin[Agent](true)
)
var (
// CallBase is a function that calls all registered base plugins
CallBase, _ = MakePlugin[Base](true)
)
var (
// CallCDN is a function that calls all registered parsers
CallCDN, _ = MakePlugin[CDN](false)
)
var (
// CallCache is a function that calls all registered cache
CallCache, _ = MakePlugin[Cache](false)
)
var (
// CallConfig is a function that calls all registered config plugins
CallConfig, _ = MakePlugin[Config](true)
)
var (
// CallConnector is a function that calls all registered connectors
CallConnector, _ = MakePlugin[Connector](false)
)
var (
// CallEmbed is a function that calls all registered parsers
CallEmbed, _ = MakePlugin[Embed](false)
)
var (
// CallFilter is a function that calls all registered parsers
CallFilter, _ = MakePlugin[Filter](false)
)
var (
// CallImporter is a function that calls all registered parsers
CallImporter, _ = MakePlugin[Importer](false)
)
var (
CallKVStorage, _ = MakePlugin[KVStorage](true)
)
var (
// CallNotification is a function that calls all registered notification plugins
CallNotification, _ = MakePlugin[Notification](false)
)
var (
// CallParser is a function that calls all registered parsers
CallParser, _ = MakePlugin[Parser](false)
)
var (
// CallRender is a function that calls all registered parsers
CallRender, _ = MakePlugin[Render](false)
)
var (
// CallReviewer is a function that calls all registered parsers
CallReviewer, _ = MakePlugin[Reviewer](false)
)
var (
// CallSearch is a function that calls all registered parsers
CallSearch, _ = MakePlugin[Search](false)
)
var (
// CallStorage is a function that calls all registered storage
CallStorage, _ = MakePlugin[Storage](false)
)
var (
// CallUserCenter is a function that calls all registered parsers
CallUserCenter, _ = MakePlugin[UserCenter](false)
)
var (
// CallUserConfig is a function that calls all registered config plugins
CallUserConfig, _ = MakePlugin[UserConfig](false)
)
var ( DefaultCDNFileType = map[string]bool{ ".ico": true, ".json": true, ".css": true, ".js": true, ".webp": true, ".woff2": true, ".woff": true, ".jpg": true, ".svg": true, ".png": true, ".map": true, ".txt": true, } )
var ( DefaultFileTypeCheckMapping = map[UploadSource]map[string]bool{ UserAvatar: { ".jpg": true, ".jpeg": true, ".png": true, ".webp": true, }, UserPost: { ".jpg": true, ".jpeg": true, ".png": true, ".gif": true, ".webp": true, }, AdminBranding: { ".jpg": true, ".jpeg": true, ".png": true, ".ico": true, }, } )
var StatusManager = statusManager{ // contains filtered or unexported fields }
StatusManager is a manager that manages the status of plugins Init Plugins: json.Unmarshal([]byte(`{"plugin1": true, "plugin2": false}`), &plugin.StatusManager) Dump Status: json.Marshal(plugin.StatusManager)
Functions ¶
func CallCaptcha ¶
func CaptchaEnabled ¶
func CaptchaEnabled() (enabled bool)
func GetPluginUserConfig ¶
GetPluginUserConfig returns the user config of the given user id
func ImporterEnabled ¶
func ImporterEnabled() (enabled bool)
func MakePlugin ¶
func MakePlugin[T Base](super bool) (CallFn[T], RegisterFn[T])
MakePlugin creates a plugin caller and register stack manager The parameter super presents if the plugin can be disabled. It returns a register function and a caller function The register function is used to register a plugin, it will be called in the plugin's init function The caller function is used to call all registered plugins
func RankAgentEnabled ¶
func RankAgentEnabled() (enabled bool)
func RegisterGetPluginUserConfigFunc ¶
RegisterGetPluginUserConfigFunc registers a function to get the user config of the given user id
func RegisterGetSiteURLFunc ¶
func RegisterGetSiteURLFunc(fn func() string)
RegisterGetSiteURLFunc Register a function to get the site url.
func SiteURL ¶
func SiteURL() string
SiteURL The site url is the domain address of the current site. e.g. http://localhost:8080 When some Agent plugins want to redirect to the origin site, it can use this function to get the site url.
func Translate ¶
func Translate(ctx *GinContext, key string) string
Translate translates the key to the current language of the context
func TranslateWithData ¶
TranslateWithData translates the key to the language with data
func UserCenterEnabled ¶
func UserCenterEnabled() (enabled bool)
Types ¶
type Agent ¶
type Agent interface { Base RegisterUnAuthRouter(r *gin.RouterGroup) RegisterAuthUserRouter(r *gin.RouterGroup) RegisterAuthAdminRouter(r *gin.RouterGroup) }
type Base ¶
type Base interface { // Info returns the plugin information Info() Info }
Base is the base plugin
type Cache ¶
type Cache interface { Base GetString(ctx context.Context, key string) (data string, exist bool, err error) SetString(ctx context.Context, key, value string, ttl time.Duration) (err error) GetInt64(ctx context.Context, key string) (data int64, exist bool, err error) SetInt64(ctx context.Context, key string, value int64, ttl time.Duration) (err error) Increase(ctx context.Context, key string, value int64) (data int64, err error) Decrease(ctx context.Context, key string, value int64) (data int64, err error) Del(ctx context.Context, key string) (err error) Flush(ctx context.Context) (err error) }
type Captcha ¶
type Captcha interface { Base // GetConfig required. Get the captcha plugin configuration. // The configuration is used to generate the captcha for frontend. Such as the token for third-party service. GetConfig() (configJsonStr string) // Create optional. If this plugin need to create captcha via backend, implement this method. // On other hand, if this plugin create captcha via third-party service, ignore this method. // Return captcha: The captcha image base64 string, code: The real captcha code. Create() (captcha, code string) // Verify required. Verify the user input captcha is correct or not // captcha: The captchaCode generated by Create method, if not implemented, it's empty. Verify(captchaCode, userInput string) (pass bool) }
type Config ¶
type Config interface { Base // ConfigFields returns the list of config fields ConfigFields() []ConfigField // ConfigReceiver receives the config data, it calls when the config is saved or initialized. // We recommend to unmarshal the data to a struct, and then use the struct to do something. // The config is encoded in JSON format. // It depends on the definition of ConfigFields. ConfigReceiver(config []byte) error }
type ConfigField ¶
type ConfigField struct { Name string `json:"name"` Type ConfigType `json:"type"` Title Translator `json:"title"` Description Translator `json:"description"` Required bool `json:"required"` Value any `json:"value"` UIOptions ConfigFieldUIOptions `json:"ui_options"` Options []ConfigFieldOption `json:"options,omitempty"` }
type ConfigFieldOption ¶
type ConfigFieldOption struct { Label Translator `json:"label"` Value string `json:"value"` }
type ConfigFieldUIOptions ¶
type ConfigFieldUIOptions struct { Placeholder Translator `json:"placeholder,omitempty"` Rows string `json:"rows,omitempty"` InputType InputType `json:"input_type,omitempty"` Label Translator `json:"label,omitempty"` Action *UIOptionAction `json:"action,omitempty"` Variant string `json:"variant,omitempty"` Text Translator `json:"text,omitempty"` ClassName string `json:"class_name,omitempty"` FieldClassName string `json:"field_class_name,omitempty"` }
type ConfigType ¶
type ConfigType string
const ( ConfigTypeInput ConfigType = "input" ConfigTypeTextarea ConfigType = "textarea" ConfigTypeCheckbox ConfigType = "checkbox" ConfigTypeRadio ConfigType = "radio" ConfigTypeSelect ConfigType = "select" ConfigTypeUpload ConfigType = "upload" ConfigTypeTimezone ConfigType = "timezone" ConfigTypeSwitch ConfigType = "switch" ConfigTypeButton ConfigType = "button" ConfigTypeLegend ConfigType = "legend" )
type Connector ¶
type Connector interface { Base // ConnectorLogoSVG presents the logo in svg format ConnectorLogoSVG() string // ConnectorName presents the name of the connector // e.g. Facebook, Twitter, Instagram ConnectorName() Translator // ConnectorSlugName presents the slug name of the connector // Please use lowercase and hyphen as the separator // e.g. facebook, twitter, instagram ConnectorSlugName() string // ConnectorSender presents the sender of the connector // It handles the start endpoint of the connector // receiverURL is the whole URL of the receiver ConnectorSender(ctx *GinContext, receiverURL string) (redirectURL string) // ConnectorReceiver presents the receiver of the connector // It handles the callback endpoint of the connector, and returns the ConnectorReceiver(ctx *GinContext, receiverURL string) (userInfo ExternalLoginUserInfo, err error) }
type ControlCenter ¶
type Data ¶ added in v1.5.1
Data is defined here to avoid circular dependency with internal/base/data
type Embed ¶
type Embed interface { Base GetEmbedConfigs(ctx *gin.Context) (embedConfigs []*EmbedConfig, err error) }
type EmbedConfig ¶
type ExternalLoginUserInfo ¶
type ExternalLoginUserInfo struct { // required. The unique user ID provided by the third-party login ExternalID string // optional. This name is used preferentially during registration DisplayName string // optional. This username is used preferentially during registration Username string // optional. If email exist will bind the existing user // IMPORTANT: The email must have been verified. If the plugin can't guarantee the email is verified, please leave it empty. Email string // optional. The avatar URL provided by the third-party login platform Avatar string // optional. The original user information provided by the third-party login platform MetaInfo string }
ExternalLoginUserInfo external login user info
type GinContext ¶
GinContext is a wrapper of gin.Context We export it to make it easy to use in plugins
type Importer ¶
type Importer interface { Base RegisterImporterFunc(ctx context.Context, importer ImporterFunc) }
func GetImporter ¶
type ImporterFunc ¶
type ImporterFunc interface {
AddQuestion(ctx context.Context, questionInfo QuestionImporterInfo) (err error)
}
type Info ¶
type Info struct { Name Translator SlugName string Description Translator Author string Version string Link string }
Info presents the plugin information
type InputType ¶
type InputType string
const ( InputTypeText InputType = "text" InputTypeColor InputType = "color" InputTypeDate InputType = "date" InputTypeDatetime InputType = "datetime-local" InputTypeEmail InputType = "email" InputTypeMonth InputType = "month" InputTypeNumber InputType = "number" InputTypePassword InputType = "password" InputTypeRange InputType = "range" InputTypeSearch InputType = "search" InputTypeTel InputType = "tel" InputTypeTime InputType = "time" InputTypeUrl InputType = "url" InputTypeWeek InputType = "week" )
type KVOperator ¶ added in v1.5.1
type KVOperator struct {
// contains filtered or unexported fields
}
KVOperator provides methods to interact with the key-value storage system for plugins
func NewKVOperator ¶ added in v1.5.1
NewKVOperator creates a new KV storage operator with the specified database engine, cache and plugin name. It returns a KVOperator instance that can be used to interact with the plugin's storage.
func (*KVOperator) Del ¶ added in v1.5.1
func (kv *KVOperator) Del(ctx context.Context, params KVParams) error
Del removes values from KV storage by group and/or key. If both group and key are provided, only that specific entry is deleted. If only group is provided, all entries in that group are deleted. At least one of group or key must be provided.
func (*KVOperator) Get ¶ added in v1.5.1
Get retrieves a value from KV storage by group and key. Returns the value as a string or an error if the key is not found.
func (*KVOperator) GetByGroup ¶ added in v1.5.1
GetByGroup retrieves all key-value pairs for a specific group with pagination support. Returns a map of keys to values or an error if the group is empty or not found.
func (*KVOperator) Option ¶ added in v1.5.1
func (kv *KVOperator) Option(opts ...KVStorageOption)
Option is used to set the options for the KV storage
func (*KVOperator) Set ¶ added in v1.5.1
func (kv *KVOperator) Set(ctx context.Context, params KVParams) error
Set stores a value in KV storage with the specified group and key. Updates the value if it already exists.
func (*KVOperator) Tx ¶ added in v1.5.1
func (kv *KVOperator) Tx(ctx context.Context, fn func(ctx context.Context, kv *KVOperator) error) error
Tx executes a function within a transaction context. If the KVOperator already has a session, it will use that session. Otherwise, it creates a new transaction session. The transaction will be committed if the function returns nil, or rolled back if it returns an error.
type KVStorage ¶ added in v1.5.1
type KVStorage interface { Info() Info SetOperator(operator *KVOperator) }
KVStorage defines the interface for plugins that need data storage capabilities
type KVStorageOption ¶ added in v1.5.1
type KVStorageOption func(*KVOperator)
KVStorageOption defines a function type that configures a KVOperator
func WithCacheTTL ¶ added in v1.5.1
func WithCacheTTL(ttl time.Duration) KVStorageOption
WithCacheTTL is the option to set the cache TTL; the default value is 30 minutes. If ttl is less than 0, the cache will not be used
type LoadingAction ¶
type LoadingAction struct { Text Translator `json:"text"` State LoadingActionType `json:"state"` }
type LoadingActionType ¶
type LoadingActionType string
const ( LoadingActionStateNone LoadingActionType = "none" LoadingActionStatePending LoadingActionType = "pending" LoadingActionStateComplete LoadingActionType = "completed" )
type Notification ¶
type Notification interface { Base // GetNewQuestionSubscribers returns the subscribers of the new question notification GetNewQuestionSubscribers() (userIDs []string) // Notify sends a notification to the user Notify(msg NotificationMessage) }
type NotificationMessage ¶
type NotificationMessage struct { // the type of the notification Type NotificationType `json:"notification_type"` // the receiver user id ReceiverUserID string `json:"receiver_user_id"` // the receiver user using language ReceiverLang string `json:"receiver_lang"` // the receiver user external id (optional) ReceiverExternalID string `json:"receiver_external_id"` // Who triggered the notification (optional, admin or system operation will not have this field) TriggerUserID string `json:"trigger_user_id"` // The trigger user's display name (optional, admin or system operation will not have this field) TriggerUserDisplayName string `json:"trigger_user_display_name"` // The trigger user's url (optional, admin or system operation will not have this field) TriggerUserUrl string `json:"trigger_user_url"` // the question title QuestionTitle string `json:"question_title"` // the question url QuestionUrl string `json:"question_url"` // the question tags (comma separated, optional, only for new question notification) QuestionTags string `json:"tags"` // the answer url (optional, only for new answer notification) AnswerUrl string `json:"answer_url"` // the comment url (optional, only for new comment notification) CommentUrl string `json:"comment_url"` }
type NotificationType ¶
type NotificationType string
NotificationType is the type of the notification
const ( NotificationUpdateQuestion NotificationType = "notification.action.update_question" NotificationAnswerTheQuestion NotificationType = "notification.action.answer_the_question" NotificationUpVotedTheQuestion NotificationType = "notification.action.up_voted_question" NotificationDownVotedTheQuestion NotificationType = "notification.action.down_voted_question" NotificationUpdateAnswer NotificationType = "notification.action.update_answer" NotificationAcceptAnswer NotificationType = "notification.action.accept_answer" NotificationUpVotedTheAnswer NotificationType = "notification.action.up_voted_answer" NotificationDownVotedTheAnswer NotificationType = "notification.action.down_voted_answer" NotificationCommentQuestion NotificationType = "notification.action.comment_question" NotificationCommentAnswer NotificationType = "notification.action.comment_answer" NotificationUpVotedTheComment NotificationType = "notification.action.up_voted_comment" NotificationReplyToYou NotificationType = "notification.action.reply_to_you" NotificationMentionYou NotificationType = "notification.action.mention_you" NotificationYourQuestionIsClosed NotificationType = "notification.action.your_question_is_closed" NotificationYourQuestionWasDeleted NotificationType = "notification.action.your_question_was_deleted" NotificationYourAnswerWasDeleted NotificationType = "notification.action.your_answer_was_deleted" NotificationYourCommentWasDeleted NotificationType = "notification.action.your_comment_was_deleted" NotificationInvitedYouToAnswer NotificationType = "notification.action.invited_you_to_answer" NotificationNewQuestion NotificationType = "notification.action.new_question" NotificationNewQuestionFollowedTag NotificationType = "notification.action.new_question_followed_tag" )
type OnCompleteAction ¶
type PersonalBranding ¶
type QuestionImporterInfo ¶
type RegisterFn ¶
type RegisterFn[T Base] func(p T)
type Render ¶
type Render interface { Base GetRenderConfig(ctx *gin.Context) (renderConfig *RenderConfig) }
type RenderConfig ¶
type RenderConfig struct {
SelectTheme string `json:"select_theme"`
}
type ReviewContent ¶
type ReviewContent struct { // The type of the content, e.g. question, answer ObjectType string // The title of the content, only available for the question Title string // The content of the review, always available Content string // The tags of the content, only available for the question Tags []string // The author of the content Author ReviewContentAuthor // Review Language, the site language. e.g. en_US // The plugin may reply the review result according to the language Language string // The user agent of the request web browser UserAgent string // The IP address of the request IP string }
ReviewContent is a struct that contains the content of a review
type ReviewContentAuthor ¶
type ReviewResult ¶
type ReviewResult struct { // If the review is approved Approved bool // The status of the review ReviewStatus ReviewStatus // The reason for the result Reason string }
ReviewResult is a struct that contains the result of a review
type ReviewStatus ¶
type ReviewStatus string
const ( ReviewStatusApproved ReviewStatus = "approved" ReviewStatusDeleteDirectly ReviewStatus = "delete_directly" ReviewStatusNeedReview ReviewStatus = "need_review" )
type Reviewer ¶
type Reviewer interface { Base Review(content *ReviewContent) (result *ReviewResult) }
type Search ¶
type Search interface { Base Description() SearchDesc RegisterSyncer(ctx context.Context, syncer SearchSyncer) SearchContents(ctx context.Context, cond *SearchBasicCond) (res []SearchResult, total int64, err error) SearchQuestions(ctx context.Context, cond *SearchBasicCond) (res []SearchResult, total int64, err error) SearchAnswers(ctx context.Context, cond *SearchBasicCond) (res []SearchResult, total int64, err error) UpdateContent(ctx context.Context, content *SearchContent) (err error) DeleteContent(ctx context.Context, objectID string) (err error) }
type SearchAcceptedCond ¶
type SearchAcceptedCond int
const ( AcceptedCondAll SearchAcceptedCond = iota AcceptedCondTrue AcceptedCondFalse )
type SearchBasicCond ¶
type SearchBasicCond struct { // From zero-based page number Page int // Page size PageSize int // The keywords for search. Words []string // TagIDs is a list of tag IDs. TagIDs [][]string // The object's owner user ID. UserID string // The order of the search result. Order SearchOrderCond // Weathers the question is accepted or not. Only support search question. QuestionAccepted SearchAcceptedCond // Weathers the answer is accepted or not. Only support search answer. AnswerAccepted SearchAcceptedCond // Only support search answer. QuestionID string // greater than or equal to the number of votes. VoteAmount int // greater than or equal to the number of views. ViewAmount int // greater than or equal to the number of answers. Only support search question. AnswerAmount int }
type SearchContent ¶
type SearchContent struct { ObjectID string `json:"objectID"` Title string `json:"title"` Type string `json:"type"` Content string `json:"content"` Answers int64 `json:"answers"` Status SearchContentStatus `json:"status"` Tags []string `json:"tags"` QuestionID string `json:"questionID"` UserID string `json:"userID"` Views int64 `json:"views"` Created int64 `json:"created"` Active int64 `json:"active"` Score int64 `json:"score"` HasAccepted bool `json:"hasAccepted"` }
type SearchContentStatus ¶
type SearchContentStatus int
type SearchDesc ¶
type SearchOrderCond ¶
type SearchOrderCond string
const ( SearchNewestOrder SearchOrderCond = "newest" SearchActiveOrder SearchOrderCond = "active" SearchScoreOrder SearchOrderCond = "score" SearchRelevanceOrder SearchOrderCond = "relevance" )
type SearchResult ¶
type SearchSyncer ¶
type SearchSyncer interface { GetAnswersPage(ctx context.Context, page, pageSize int) (answerList []*SearchContent, err error) GetQuestionsPage(ctx context.Context, page, pageSize int) (questionList []*SearchContent, err error) }
type SettingInfo ¶
type Storage ¶
type Storage interface { Base // UploadFile uploads a file to storage. // The file is in the Form of the ctx and the key is "file" UploadFile(ctx *GinContext, condition UploadFileCondition) UploadFileResponse }
type TranslateFn ¶
type TranslateFn func(ctx *GinContext) string
TranslateFn presents a generator of translated string. We use it to delegate the translation work outside the plugin.
type Translator ¶
type Translator struct {
Fn TranslateFn
}
Translator contains a function that translates the key to the current language of the context
func MakeTranslator ¶
func MakeTranslator(key string) Translator
MakeTranslator generates a translator from the key
func (Translator) Translate ¶
func (t Translator) Translate(ctx *GinContext) string
Translate translates the key to the current language of the context
type UIOptionAction ¶
type UIOptionAction struct { Url string `json:"url"` Method string `json:"method,omitempty"` Loading *LoadingAction `json:"loading,omitempty"` OnComplete *OnCompleteAction `json:"on_complete,omitempty"` }
type UploadFileCondition ¶
type UploadFileCondition struct { // Source is the source of the file Source UploadSource // MaxImageSize is the maximum size of the image in MB MaxImageSize int // MaxAttachmentSize is the maximum size of the attachment in MB MaxAttachmentSize int // MaxImageMegapixel is the maximum megapixel of the image MaxImageMegapixel int // AuthorizedImageExtensions is the list of authorized image extensions AuthorizedImageExtensions []string // AuthorizedAttachmentExtensions is the list of authorized attachment extensions AuthorizedAttachmentExtensions []string }
type UploadFileResponse ¶
type UploadFileResponse struct { // FullURL is the URL that can be used to access the file FullURL string // OriginalError is the error returned by the storage plugin. It is used for debugging. OriginalError error // DisplayErrorMsg is the error message that will be displayed to the user. DisplayErrorMsg Translator }
type UploadSource ¶
type UploadSource string
const ( UserAvatar UploadSource = "user_avatar" UserPost UploadSource = "user_post" UserPostAttachment UploadSource = "user_post_attachment" AdminBranding UploadSource = "admin_branding" )
type UserCenter ¶
type UserCenter interface { Base // Description returns the description of the user center, including the name, icon, url, etc. Description() UserCenterDesc // ControlCenterItems returns the items that will be displayed in the control center ControlCenterItems() []ControlCenter // LoginCallback is called when the user center login callback is called LoginCallback(ctx *GinContext) (userInfo *UserCenterBasicUserInfo, err error) // SignUpCallback is called when the user center sign up callback is called SignUpCallback(ctx *GinContext) (userInfo *UserCenterBasicUserInfo, err error) // UserInfo returns the user information UserInfo(externalID string) (userInfo *UserCenterBasicUserInfo, err error) // UserStatus returns the latest user status UserStatus(externalID string) (userStatus UserStatus) // UserList returns the user list information UserList(externalIDs []string) (userInfo []*UserCenterBasicUserInfo, err error) // UserSettings returns the user settings UserSettings(externalID string) (userSettings *SettingInfo, err error) // PersonalBranding returns the personal branding information PersonalBranding(externalID string) (branding []*PersonalBranding) // AfterLogin is called after the user logs in AfterLogin(externalID, accessToken string) }
func GetUserCenter ¶
func GetUserCenter() (uc UserCenter, ok bool)
type UserCenterBasicUserInfo ¶
type UserCenterBasicUserInfo struct { ExternalID string `json:"external_id"` Username string `json:"username"` DisplayName string `json:"display_name"` Email string `json:"email"` Rank int `json:"rank"` Avatar string `json:"avatar"` Mobile string `json:"mobile"` Bio string `json:"bio"` Status UserStatus `json:"status"` }
type UserCenterDesc ¶
type UserCenterDesc struct { Name string `json:"name"` DisplayName Translator `json:"display_name"` Icon string `json:"icon"` Url string `json:"url"` LoginRedirectURL string `json:"login_redirect_url"` SignUpRedirectURL string `json:"sign_up_redirect_url"` RankAgentEnabled bool `json:"rank_agent_enabled"` UserStatusAgentEnabled bool `json:"user_status_agent_enabled"` UserRoleAgentEnabled bool `json:"user_role_agent_enabled"` MustAuthEmailEnabled bool `json:"must_auth_email_enabled"` EnabledOriginalUserSystem bool `json:"enabled_original_user_system"` }
type UserConfig ¶
type UserConfig interface { Base // UserConfigFields returns the list of config fields UserConfigFields() []ConfigField // UserConfigReceiver receives the config data, it calls when the config is saved or initialized. // We recommend to unmarshal the data to a struct, and then use the struct to do something. // The config is encoded in JSON format. // It depends on the definition of ConfigFields. UserConfigReceiver(userID string, config []byte) error }
type UserStatus ¶
type UserStatus int
const ( UserStatusAvailable UserStatus = 1 UserStatusSuspended UserStatus = 9 UserStatusDeleted UserStatus = 10 )