{"modulePath":"github.com/apache/answer","version":"v1.7.1","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package plugin\n\nPackage plugin\n\n## Constants\n\n```go\nconst (\n\tSearchContentStatusAvailable = 1\n\tSearchContentStatusDeleted   = 10\n)\n```\n\n## Variables\n\n```go\nvar (\n\t// ErrKVKeyNotFound is returned when the requested key does not exist in the KV storage\n\tErrKVKeyNotFound = fmt.Errorf(\"key not found in KV storage\")\n\t// ErrKVGroupEmpty is returned when a required group name is empty\n\tErrKVGroupEmpty = fmt.Errorf(\"group name is empty\")\n\t// ErrKVKeyEmpty is returned when a required key name is empty\n\tErrKVKeyEmpty = fmt.Errorf(\"key name is empty\")\n\t// ErrKVKeyAndGroupEmpty is returned when both key and group names are empty\n\tErrKVKeyAndGroupEmpty = fmt.Errorf(\"both key and group are empty\")\n\t// ErrKVTransactionFailed is returned when a KV storage transaction operation fails\n\tErrKVTransactionFailed = fmt.Errorf(\"KV storage transaction failed\")\n)\n```\nError variables for KV storage operations\n\n```go\nvar (\n\tCallAgent, _ = MakePlugin[Agent](true)\n)\n```\n\n```go\nvar (\n\t// CallBase is a function that calls all registered base plugins\n\tCallBase, _ = MakePlugin[Base](true)\n)\n```\n\n```go\nvar (\n\t// CallCDN is a function that calls all registered parsers\n\tCallCDN, _ = MakePlugin[CDN](false)\n)\n```\n\n```go\nvar (\n\t// CallCache is a function that calls all registered cache\n\tCallCache, _ = MakePlugin[Cache](false)\n)\n```\n\n```go\nvar (\n\t// CallConfig is a function that calls all registered config plugins\n\tCallConfig, _ = MakePlugin[Config](true)\n)\n```\n\n```go\nvar (\n\t// CallConnector is a function that calls all registered connectors\n\tCallConnector, _ = MakePlugin[Connector](false)\n)\n```\n\n```go\nvar (\n\t// CallEmbed is a function that calls all registered parsers\n\tCallEmbed, _ = MakePlugin[Embed](false)\n)\n```\n\n```go\nvar (\n\t// CallFilter is a function that calls all registered parsers\n\tCallFilter, _ = MakePlugin[Filter](false)\n)\n```\n\n```go\nvar (\n\t// CallImporter is a function that calls all registered parsers\n\tCallImporter, _ = MakePlugin[Importer](false)\n)\n```\n\n```go\nvar (\n\tCallKVStorage, _ = MakePlugin[KVStorage](true)\n)\n```\n\n```go\nvar (\n\t// CallNotification is a function that calls all registered notification plugins\n\tCallNotification, _ = MakePlugin[Notification](false)\n)\n```\n\n```go\nvar (\n\t// CallParser is a function that calls all registered parsers\n\tCallParser, _ = MakePlugin[Parser](false)\n)\n```\n\n```go\nvar (\n\t// CallRender is a function that calls all registered parsers\n\tCallRender, _ = MakePlugin[Render](false)\n)\n```\n\n```go\nvar (\n\t// CallReviewer is a function that calls all registered parsers\n\tCallReviewer, _ = MakePlugin[Reviewer](false)\n)\n```\n\n```go\nvar (\n\t// CallSearch is a function that calls all registered parsers\n\tCallSearch, _ = MakePlugin[Search](false)\n)\n```\n\n```go\nvar (\n\t// CallRender is a function that calls all registered parsers\n\tCallSidebar, _ = MakePlugin[Sidebar](false)\n)\n```\n\n```go\nvar (\n\t// CallStorage is a function that calls all registered storage\n\tCallStorage, _ = MakePlugin[Storage](false)\n)\n```\n\n```go\nvar (\n\t// CallUserCenter is a function that calls all registered parsers\n\tCallUserCenter, _ = MakePlugin[UserCenter](false)\n)\n```\n\n```go\nvar (\n\t// CallUserConfig is a function that calls all registered config plugins\n\tCallUserConfig, _ = MakePlugin[UserConfig](false)\n)\n```\n\n```go\nvar (\n\tDefaultCDNFileType = map[string]bool{\n\t\t\".ico\":   true,\n\t\t\".json\":  true,\n\t\t\".css\":   true,\n\t\t\".js\":    true,\n\t\t\".webp\":  true,\n\t\t\".woff2\": true,\n\t\t\".woff\":  true,\n\t\t\".jpg\":   true,\n\t\t\".svg\":   true,\n\t\t\".png\":   true,\n\t\t\".map\":   true,\n\t\t\".txt\":   true,\n\t}\n)\n```\n\n```go\nvar (\n\tDefaultFileTypeCheckMapping = map[UploadSource]map[string]bool{\n\t\tUserAvatar: {\n\t\t\t\".jpg\":  true,\n\t\t\t\".jpeg\": true,\n\t\t\t\".png\":  true,\n\t\t\t\".webp\": true,\n\t\t},\n\t\tUserPost: {\n\t\t\t\".jpg\":  true,\n\t\t\t\".jpeg\": true,\n\t\t\t\".png\":  true,\n\t\t\t\".gif\":  true,\n\t\t\t\".webp\": true,\n\t\t},\n\t\tAdminBranding: {\n\t\t\t\".jpg\":  true,\n\t\t\t\".jpeg\": true,\n\t\t\t\".png\":  true,\n\t\t\t\".ico\":  true,\n\t\t},\n\t}\n)\n```\n\n```go\nvar StatusManager = statusManager{\n\t// contains filtered or unexported fields\n}\n```\nStatusManager is a manager that manages the status of plugins Init Plugins: json.Unmarshal(\\[]byte(\\`{\"plugin1\": true, \"plugin2\": false}\\`), \u0026plugin.StatusManager) Dump Status: json.Marshal(plugin.StatusManager)\n\n## Functions\n\n```go\nfunc CallCaptcha(fn func(fn Captcha) error) error\n```\n\n```go\nfunc CaptchaEnabled() (enabled bool)\n```\n\n```go\nfunc GetPluginUserConfig(userID, pluginSlugName string) []byte\n```\nGetPluginUserConfig returns the user config of the given user id\n\n```go\nfunc ImporterEnabled() (enabled bool)\n```\n\n```go\nfunc MakePlugin[T Base](super bool) (CallFn[T], RegisterFn[T])\n```\nMakePlugin 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\n\n```go\nfunc RankAgentEnabled() (enabled bool)\n```\n\n```go\nfunc Register(p Base)\n```\nRegister registers a plugin\n\n```go\nfunc RegisterGetPluginUserConfigFunc(fn func(userID, pluginSlugName string) []byte)\n```\nRegisterGetPluginUserConfigFunc registers a function to get the user config of the given user id\n\n```go\nfunc RegisterGetSiteURLFunc(fn func() string)\n```\nRegisterGetSiteURLFunc Register a function to get the site url.\n\n```go\nfunc SiteURL() string\n```\nSiteURL The site url is the domain address of the current site. e.g. [http://localhost:8080](http://localhost:8080) When some Agent plugins want to redirect to the origin site, it can use this function to get the site url.\n\n```go\nfunc Translate(ctx *GinContext, key string) string\n```\nTranslate translates the key to the current language of the context\n\n```go\nfunc TranslateWithData(lang i18n.Language, key string, data any) string\n```\nTranslateWithData translates the key to the language with data\n\n```go\nfunc UserCenterEnabled() (enabled bool)\n```\n\n## Types\n\n```go\ntype Agent interface {\n\tBase\n\tRegisterUnAuthRouter(r *gin.RouterGroup)\n\tRegisterAuthUserRouter(r *gin.RouterGroup)\n\tRegisterAuthAdminRouter(r *gin.RouterGroup)\n}\n```\n\n```go\ntype Base interface {\n\t// Info returns the plugin information\n\tInfo() Info\n}\n```\nBase is the base plugin\n\n```go\ntype CDN interface {\n\tBase\n\tGetStaticPrefix() string\n}\n```\n\n```go\ntype Cache interface {\n\tBase\n\n\tGetString(ctx context.Context, key string) (data string, exist bool, err error)\n\tSetString(ctx context.Context, key, value string, ttl time.Duration) (err error)\n\tGetInt64(ctx context.Context, key string) (data int64, exist bool, err error)\n\tSetInt64(ctx context.Context, key string, value int64, ttl time.Duration) (err error)\n\tIncrease(ctx context.Context, key string, value int64) (data int64, err error)\n\tDecrease(ctx context.Context, key string, value int64) (data int64, err error)\n\tDel(ctx context.Context, key string) (err error)\n\tFlush(ctx context.Context) (err error)\n}\n```\n\n```go\ntype CallFn[T Base] func(fn Caller[T]) error\n```\n\n```go\ntype Caller[T Base] func(p T) error\n```\n\n```go\ntype Captcha interface {\n\tBase\n\t// GetConfig required. Get the captcha plugin configuration.\n\t// The configuration is used to generate the captcha for frontend. Such as the token for third-party service.\n\tGetConfig() (configJsonStr string)\n\t// Create optional. If this plugin need to create captcha via backend, implement this method.\n\t// On other hand, if this plugin create captcha via third-party service, ignore this method.\n\t// Return captcha: The captcha image base64 string, code: The real captcha code.\n\tCreate() (captcha, code string)\n\t// Verify required. Verify the user input captcha is correct or not\n\t// captcha: The captchaCode generated by Create method, if not implemented, it's empty.\n\tVerify(captchaCode, userInput string) (pass bool)\n}\n```\n\n```go\ntype Config interface {\n\tBase\n\n\t// ConfigFields returns the list of config fields\n\tConfigFields() []ConfigField\n\n\t// ConfigReceiver receives the config data, it calls when the config is saved or initialized.\n\t// We recommend to unmarshal the data to a struct, and then use the struct to do something.\n\t// The config is encoded in JSON format.\n\t// It depends on the definition of ConfigFields.\n\tConfigReceiver(config []byte) error\n}\n```\n\n```go\ntype ConfigField struct {\n\tName        string               `json:\"name\"`\n\tType        ConfigType           `json:\"type\"`\n\tTitle       Translator           `json:\"title\"`\n\tDescription Translator           `json:\"description\"`\n\tRequired    bool                 `json:\"required\"`\n\tValue       any                  `json:\"value\"`\n\tUIOptions   ConfigFieldUIOptions `json:\"ui_options\"`\n\tOptions     []ConfigFieldOption  `json:\"options,omitempty\"`\n}\n```\n\n```go\ntype ConfigFieldOption struct {\n\tLabel Translator `json:\"label\"`\n\tValue string     `json:\"value\"`\n}\n```\n\n```go\ntype ConfigFieldUIOptions struct {\n\tPlaceholder    Translator      `json:\"placeholder,omitempty\"`\n\tRows           string          `json:\"rows,omitempty\"`\n\tInputType      InputType       `json:\"input_type,omitempty\"`\n\tLabel          Translator      `json:\"label,omitempty\"`\n\tAction         *UIOptionAction `json:\"action,omitempty\"`\n\tVariant        string          `json:\"variant,omitempty\"`\n\tText           Translator      `json:\"text,omitempty\"`\n\tClassName      string          `json:\"class_name,omitempty\"`\n\tFieldClassName string          `json:\"field_class_name,omitempty\"`\n}\n```\n\n```go\ntype ConfigType string\n```\n\n```go\nconst (\n\tConfigTypeInput       ConfigType = \"input\"\n\tConfigTypeTextarea    ConfigType = \"textarea\"\n\tConfigTypeCheckbox    ConfigType = \"checkbox\"\n\tConfigTypeRadio       ConfigType = \"radio\"\n\tConfigTypeSelect      ConfigType = \"select\"\n\tConfigTypeUpload      ConfigType = \"upload\"\n\tConfigTypeTimezone    ConfigType = \"timezone\"\n\tConfigTypeSwitch      ConfigType = \"switch\"\n\tConfigTypeButton      ConfigType = \"button\"\n\tConfigTypeLegend      ConfigType = \"legend\"\n\tConfigTypeTagSelector ConfigType = \"tag_selector\"\n)\n```\n\n```go\ntype Connector interface {\n\tBase\n\n\t// ConnectorLogoSVG presents the logo in svg format\n\tConnectorLogoSVG() string\n\n\t// ConnectorName presents the name of the connector\n\t// e.g. Facebook, Twitter, Instagram\n\tConnectorName() Translator\n\n\t// ConnectorSlugName presents the slug name of the connector\n\t// Please use lowercase and hyphen as the separator\n\t// e.g. facebook, twitter, instagram\n\tConnectorSlugName() string\n\n\t// ConnectorSender presents the sender of the connector\n\t// It handles the start endpoint of the connector\n\t// receiverURL is the whole URL of the receiver\n\tConnectorSender(ctx *GinContext, receiverURL string) (redirectURL string)\n\n\t// ConnectorReceiver presents the receiver of the connector\n\t// It handles the callback endpoint of the connector, and returns the\n\tConnectorReceiver(ctx *GinContext, receiverURL string) (userInfo ExternalLoginUserInfo, err error)\n}\n```\n\n```go\ntype ControlCenter struct {\n\tName  string `json:\"name\"`\n\tLabel string `json:\"label\"`\n\tUrl   string `json:\"url\"`\n}\n```\n\n```go\ntype Data struct {\n\tDB    *xorm.Engine\n\tCache cache.Cache\n}\n```\nData is defined here to avoid circular dependency with internal/base/data\n\n```go\ntype Embed interface {\n\tBase\n\tGetEmbedConfigs(ctx *gin.Context) (embedConfigs []*EmbedConfig, err error)\n}\n```\n\n```go\ntype EmbedConfig struct {\n\tPlatform string `json:\"platform\"`\n\tEnable   bool   `json:\"enable\"`\n}\n```\n\n```go\ntype ExternalLoginUserInfo struct {\n\t// required. The unique user ID provided by the third-party login\n\tExternalID string\n\t// optional. This name is used preferentially during registration\n\tDisplayName string\n\t// optional. This username is used preferentially during registration\n\tUsername string\n\t// optional. If email exist will bind the existing user\n\t// IMPORTANT: The email must have been verified. If the plugin can't guarantee the email is verified, please leave it empty.\n\tEmail string\n\t// optional. The avatar URL provided by the third-party login platform\n\tAvatar string\n\t// optional. The original user information provided by the third-party login platform\n\tMetaInfo string\n}\n```\nExternalLoginUserInfo external login user info\n\n```go\ntype Filter interface {\n\tBase\n\tFilterText(text string) (err error)\n}\n```\n\n```go\ntype GinContext = gin.Context\n```\nGinContext is a wrapper of gin.Context We export it to make it easy to use in plugins\n\n```go\ntype Importer interface {\n\tBase\n\tRegisterImporterFunc(ctx context.Context, importer ImporterFunc)\n}\n```\n\n```go\nfunc GetImporter() (ip Importer, ok bool)\n```\n\n```go\ntype ImporterFunc interface {\n\tAddQuestion(ctx context.Context, questionInfo QuestionImporterInfo) (err error)\n}\n```\n\n```go\ntype Info struct {\n\tName        Translator\n\tSlugName    string\n\tDescription Translator\n\tAuthor      string\n\tVersion     string\n\tLink        string\n}\n```\nInfo presents the plugin information\n\n```go\ntype InputType string\n```\n\n```go\nconst (\n\tInputTypeText     InputType = \"text\"\n\tInputTypeColor    InputType = \"color\"\n\tInputTypeDate     InputType = \"date\"\n\tInputTypeDatetime InputType = \"datetime-local\"\n\tInputTypeEmail    InputType = \"email\"\n\tInputTypeMonth    InputType = \"month\"\n\tInputTypeNumber   InputType = \"number\"\n\tInputTypePassword InputType = \"password\"\n\tInputTypeRange    InputType = \"range\"\n\tInputTypeSearch   InputType = \"search\"\n\tInputTypeTel      InputType = \"tel\"\n\tInputTypeTime     InputType = \"time\"\n\tInputTypeUrl      InputType = \"url\"\n\tInputTypeWeek     InputType = \"week\"\n)\n```\n\n```go\ntype KVOperator struct {\n\t// contains filtered or unexported fields\n}\n```\nKVOperator provides methods to interact with the key-value storage system for plugins\n\n```go\nfunc NewKVOperator(db *xorm.Engine, cache cache.Cache, pluginSlugName string) *KVOperator\n```\nNewKVOperator 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.\n\n```go\nfunc (kv *KVOperator) Del(ctx context.Context, params KVParams) error\n```\nDel 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.\n\n```go\nfunc (kv *KVOperator) Get(ctx context.Context, params KVParams) (string, error)\n```\nGet 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.\n\n```go\nfunc (kv *KVOperator) GetByGroup(ctx context.Context, params KVParams) (map[string]string, error)\n```\nGetByGroup 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.\n\n```go\nfunc (kv *KVOperator) Option(opts ...KVStorageOption)\n```\nOption is used to set the options for the KV storage\n\n```go\nfunc (kv *KVOperator) Set(ctx context.Context, params KVParams) error\n```\nSet stores a value in KV storage with the specified group and key. Updates the value if it already exists.\n\n```go\nfunc (kv *KVOperator) Tx(ctx context.Context, fn func(ctx context.Context, kv *KVOperator) error) error\n```\nTx 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.\n\n```go\ntype KVParams struct {\n\tGroup    string\n\tKey      string\n\tValue    string\n\tPage     int\n\tPageSize int\n}\n```\nKVParams is the parameters for KV storage operations\n\n```go\ntype KVStorage interface {\n\tInfo() Info\n\tSetOperator(operator *KVOperator)\n}\n```\nKVStorage defines the interface for plugins that need data storage capabilities\n\n```go\ntype KVStorageOption func(*KVOperator)\n```\nKVStorageOption defines a function type that configures a KVOperator\n\n```go\nfunc WithCacheTTL(ttl time.Duration) KVStorageOption\n```\nWithCacheTTL 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\n\n```go\ntype LoadingAction struct {\n\tText  Translator        `json:\"text\"`\n\tState LoadingActionType `json:\"state\"`\n}\n```\n\n```go\ntype LoadingActionType string\n```\n\n```go\nconst (\n\tLoadingActionStateNone     LoadingActionType = \"none\"\n\tLoadingActionStatePending  LoadingActionType = \"pending\"\n\tLoadingActionStateComplete LoadingActionType = \"completed\"\n)\n```\n\n```go\ntype Notification interface {\n\tBase\n\n\t// GetNewQuestionSubscribers returns the subscribers of the new question notification\n\tGetNewQuestionSubscribers() (userIDs []string)\n\n\t// Notify sends a notification to the user\n\tNotify(msg NotificationMessage)\n}\n```\n\n```go\ntype NotificationMessage struct {\n\t//  the type of the notification\n\tType NotificationType `json:\"notification_type\"`\n\t// the receiver user id\n\tReceiverUserID string `json:\"receiver_user_id\"`\n\t// the receiver user using language\n\tReceiverLang string `json:\"receiver_lang\"`\n\t// the receiver user external id (optional)\n\tReceiverExternalID string `json:\"receiver_external_id\"`\n\n\t// Who triggered the notification (optional, admin or system operation will not have this field)\n\tTriggerUserID string `json:\"trigger_user_id\"`\n\t// The trigger user's display name (optional, admin or system operation will not have this field)\n\tTriggerUserDisplayName string `json:\"trigger_user_display_name\"`\n\t// The trigger user's url (optional, admin or system operation will not have this field)\n\tTriggerUserUrl string `json:\"trigger_user_url\"`\n\n\t// the question title\n\tQuestionTitle string `json:\"question_title\"`\n\t// the question url\n\tQuestionUrl string `json:\"question_url\"`\n\t// the question tags (comma separated, optional, only for new question notification)\n\tQuestionTags string `json:\"tags\"`\n\n\t// the answer url (optional, only for new answer notification)\n\tAnswerUrl string `json:\"answer_url\"`\n\t// the comment url (optional, only for new comment notification)\n\tCommentUrl string `json:\"comment_url\"`\n}\n```\n\n```go\ntype NotificationType string\n```\nNotificationType is the type of the notification\n\n```go\nconst (\n\tNotificationUpdateQuestion         NotificationType = \"notification.action.update_question\"\n\tNotificationAnswerTheQuestion      NotificationType = \"notification.action.answer_the_question\"\n\tNotificationUpVotedTheQuestion     NotificationType = \"notification.action.up_voted_question\"\n\tNotificationDownVotedTheQuestion   NotificationType = \"notification.action.down_voted_question\"\n\tNotificationUpdateAnswer           NotificationType = \"notification.action.update_answer\"\n\tNotificationAcceptAnswer           NotificationType = \"notification.action.accept_answer\"\n\tNotificationUpVotedTheAnswer       NotificationType = \"notification.action.up_voted_answer\"\n\tNotificationDownVotedTheAnswer     NotificationType = \"notification.action.down_voted_answer\"\n\tNotificationCommentQuestion        NotificationType = \"notification.action.comment_question\"\n\tNotificationCommentAnswer          NotificationType = \"notification.action.comment_answer\"\n\tNotificationUpVotedTheComment      NotificationType = \"notification.action.up_voted_comment\"\n\tNotificationReplyToYou             NotificationType = \"notification.action.reply_to_you\"\n\tNotificationMentionYou             NotificationType = \"notification.action.mention_you\"\n\tNotificationYourQuestionIsClosed   NotificationType = \"notification.action.your_question_is_closed\"\n\tNotificationYourQuestionWasDeleted NotificationType = \"notification.action.your_question_was_deleted\"\n\tNotificationYourAnswerWasDeleted   NotificationType = \"notification.action.your_answer_was_deleted\"\n\tNotificationYourCommentWasDeleted  NotificationType = \"notification.action.your_comment_was_deleted\"\n\tNotificationInvitedYouToAnswer     NotificationType = \"notification.action.invited_you_to_answer\"\n\tNotificationNewQuestion            NotificationType = \"notification.action.new_question\"\n\tNotificationNewQuestionFollowedTag NotificationType = \"notification.action.new_question_followed_tag\"\n)\n```\n\n```go\ntype OnCompleteAction struct {\n\tToastReturnMessage bool `json:\"toast_return_message\"`\n\tRefreshFormConfig  bool `json:\"refresh_form_config\"`\n}\n```\n\n```go\ntype Parser interface {\n\tBase\n\tParse(text string) (string, error)\n}\n```\n\n```go\ntype PersonalBranding struct {\n\tIcon  string `json:\"icon\"`\n\tName  string `json:\"name\"`\n\tLabel string `json:\"label\"`\n\tUrl   string `json:\"url\"`\n}\n```\n\n```go\ntype QuestionImporterInfo struct {\n\tTitle     string   `json:\"title\"`\n\tContent   string   `json:\"content\"`\n\tTags      []string `json:\"tags\"`\n\tUserEmail string   `json:\"user_email\"`\n}\n```\n\n```go\ntype RegisterFn[T Base] func(p T)\n```\n\n```go\ntype Render interface {\n\tBase\n\tGetRenderConfig(ctx *gin.Context) (renderConfig *RenderConfig)\n}\n```\n\n```go\ntype RenderConfig struct {\n\tSelectTheme string `json:\"select_theme\"`\n}\n```\n\n```go\ntype ReviewContent struct {\n\t// The type of the content, e.g. question, answer\n\tObjectType string\n\t// The title of the content, only available for the question\n\tTitle string\n\t// The content of the review, always available\n\tContent string\n\t// The tags of the content, only available for the question\n\tTags []string\n\t// The author of the content\n\tAuthor ReviewContentAuthor\n\t// Review Language, the site language. e.g. en_US\n\t// The plugin may reply the review result according to the language\n\tLanguage string\n\t// The user agent of the request web browser\n\tUserAgent string\n\t// The IP address of the request\n\tIP string\n}\n```\nReviewContent is a struct that contains the content of a review\n\n```go\ntype ReviewContentAuthor struct {\n\t// The user's reputation\n\tRank int\n\t// The amount of questions that has approved\n\tApprovedQuestionAmount int64\n\t// The amount of answers that has approved\n\tApprovedAnswerAmount int64\n\t// 1:User 2:Admin 3:Moderator\n\tRole int\n}\n```\n\n```go\ntype ReviewResult struct {\n\t// If the review is approved\n\tApproved bool\n\t// The status of the review\n\tReviewStatus ReviewStatus\n\t// The reason for the result\n\tReason string\n}\n```\nReviewResult is a struct that contains the result of a review\n\n```go\ntype ReviewStatus string\n```\n\n```go\nconst (\n\tReviewStatusApproved       ReviewStatus = \"approved\"\n\tReviewStatusDeleteDirectly ReviewStatus = \"delete_directly\"\n\tReviewStatusNeedReview     ReviewStatus = \"need_review\"\n)\n```\n\n```go\ntype Reviewer interface {\n\tBase\n\tReview(content *ReviewContent) (result *ReviewResult)\n}\n```\n\n```go\ntype Search interface {\n\tBase\n\tDescription() SearchDesc\n\tRegisterSyncer(ctx context.Context, syncer SearchSyncer)\n\tSearchContents(ctx context.Context, cond *SearchBasicCond) (res []SearchResult, total int64, err error)\n\tSearchQuestions(ctx context.Context, cond *SearchBasicCond) (res []SearchResult, total int64, err error)\n\tSearchAnswers(ctx context.Context, cond *SearchBasicCond) (res []SearchResult, total int64, err error)\n\tUpdateContent(ctx context.Context, content *SearchContent) (err error)\n\tDeleteContent(ctx context.Context, objectID string) (err error)\n}\n```\n\n```go\ntype SearchAcceptedCond int\n```\n\n```go\nconst (\n\tAcceptedCondAll SearchAcceptedCond = iota\n\tAcceptedCondTrue\n\tAcceptedCondFalse\n)\n```\n\n```go\ntype SearchBasicCond struct {\n\t// From zero-based page number\n\tPage int\n\t// Page size\n\tPageSize int\n\n\t// The keywords for search.\n\tWords []string\n\t// TagIDs is a list of tag IDs.\n\tTagIDs [][]string\n\t// The object's owner user ID.\n\tUserID string\n\t// The order of the search result.\n\tOrder SearchOrderCond\n\n\t// Weathers the question is accepted or not. Only support search question.\n\tQuestionAccepted SearchAcceptedCond\n\t// Weathers the answer is accepted or not. Only support search answer.\n\tAnswerAccepted SearchAcceptedCond\n\n\t// Only support search answer.\n\tQuestionID string\n\n\t// greater than or equal to the number of votes.\n\tVoteAmount int\n\t// greater than or equal to the number of views.\n\tViewAmount int\n\t// greater than or equal to the number of answers. Only support search question.\n\tAnswerAmount int\n}\n```\n\n```go\ntype SearchContent struct {\n\tObjectID    string              `json:\"objectID\"`\n\tTitle       string              `json:\"title\"`\n\tType        string              `json:\"type\"`\n\tContent     string              `json:\"content\"`\n\tAnswers     int64               `json:\"answers\"`\n\tStatus      SearchContentStatus `json:\"status\"`\n\tTags        []string            `json:\"tags\"`\n\tQuestionID  string              `json:\"questionID\"`\n\tUserID      string              `json:\"userID\"`\n\tViews       int64               `json:\"views\"`\n\tCreated     int64               `json:\"created\"`\n\tActive      int64               `json:\"active\"`\n\tScore       int64               `json:\"score\"`\n\tHasAccepted bool                `json:\"hasAccepted\"`\n}\n```\n\n```go\ntype SearchContentStatus int\n```\n\n```go\ntype SearchDesc struct {\n\t// A svg icon it wil be display in search result page. optional\n\tIcon string `json:\"icon\"`\n\t// The link address of the search engine. optional\n\tLink string `json:\"link\"`\n}\n```\n\n```go\ntype SearchOrderCond string\n```\n\n```go\nconst (\n\tSearchNewestOrder    SearchOrderCond = \"newest\"\n\tSearchActiveOrder    SearchOrderCond = \"active\"\n\tSearchScoreOrder     SearchOrderCond = \"score\"\n\tSearchRelevanceOrder SearchOrderCond = \"relevance\"\n)\n```\n\n```go\ntype SearchResult struct {\n\t// ID content ID\n\tID string\n\t// Type content type, example: \"answer\", \"question\"\n\tType string\n}\n```\n\n```go\ntype SearchSyncer interface {\n\tGetAnswersPage(ctx context.Context, page, pageSize int) (answerList []*SearchContent, err error)\n\tGetQuestionsPage(ctx context.Context, page, pageSize int) (questionList []*SearchContent, err error)\n}\n```\n\n```go\ntype SettingInfo struct {\n\tProfileSettingRedirectURL string `json:\"profile_setting_redirect_url\"`\n\tAccountSettingRedirectURL string `json:\"account_setting_redirect_url\"`\n}\n```\n\n```go\ntype Sidebar interface {\n\tBase\n\tGetSidebarConfig() (sidebarConfig *SidebarConfig, err error)\n}\n```\n\n```go\ntype SidebarConfig struct {\n\tTags      []*TagSelectorOption `json:\"tags\"`\n\tLinksText string               `json:\"links_text\"`\n}\n```\n\n```go\ntype Stack[T Base] struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\ntype Storage interface {\n\tBase\n\n\t// UploadFile uploads a file to storage.\n\t// The file is in the Form of the ctx and the key is \"file\"\n\tUploadFile(ctx *GinContext, condition UploadFileCondition) UploadFileResponse\n}\n```\n\n```go\ntype TagSelectorOption struct {\n\tTagID       string `json:\"tag_id\"`\n\tSlugName    string `json:\"slug_name\"`\n\tDisplayName string `json:\"display_name\"`\n\tRecommend   bool   `json:\"recommend\"`\n\tReserved    bool   `json:\"reserved\"`\n}\n```\nTagSelectorOption represents a tag option in the tag selector config value field\n\n```go\ntype TranslateFn func(ctx *GinContext) string\n```\nTranslateFn presents a generator of translated string. We use it to delegate the translation work outside the plugin.\n\n```go\ntype Translator struct {\n\tFn TranslateFn\n}\n```\nTranslator contains a function that translates the key to the current language of the context\n\n```go\nfunc MakeTranslator(key string) Translator\n```\nMakeTranslator generates a translator from the key\n\n```go\nfunc (t Translator) Translate(ctx *GinContext) string\n```\nTranslate translates the key to the current language of the context\n\n```go\ntype UIOptionAction struct {\n\tUrl        string            `json:\"url\"`\n\tMethod     string            `json:\"method,omitempty\"`\n\tLoading    *LoadingAction    `json:\"loading,omitempty\"`\n\tOnComplete *OnCompleteAction `json:\"on_complete,omitempty\"`\n}\n```\n\n```go\ntype UploadFileCondition struct {\n\t// Source is the source of the file\n\tSource UploadSource\n\t// MaxImageSize is the maximum size of the image in MB\n\tMaxImageSize int\n\t// MaxAttachmentSize is the maximum size of the attachment in MB\n\tMaxAttachmentSize int\n\t// MaxImageMegapixel is the maximum megapixel of the image\n\tMaxImageMegapixel int\n\t// AuthorizedImageExtensions is the list of authorized image extensions\n\tAuthorizedImageExtensions []string\n\t// AuthorizedAttachmentExtensions is the list of authorized attachment extensions\n\tAuthorizedAttachmentExtensions []string\n}\n```\n\n```go\ntype UploadFileResponse struct {\n\t// FullURL is the URL that can be used to access the file\n\tFullURL string\n\t// OriginalError is the error returned by the storage plugin. It is used for debugging.\n\tOriginalError error\n\t// DisplayErrorMsg is the error message that will be displayed to the user.\n\tDisplayErrorMsg Translator\n}\n```\n\n```go\ntype UploadSource string\n```\n\n```go\nconst (\n\tUserAvatar         UploadSource = \"user_avatar\"\n\tUserPost           UploadSource = \"user_post\"\n\tUserPostAttachment UploadSource = \"user_post_attachment\"\n\tAdminBranding      UploadSource = \"admin_branding\"\n)\n```\n\n```go\ntype UserCenter interface {\n\tBase\n\t// Description returns the description of the user center, including the name, icon, url, etc.\n\tDescription() UserCenterDesc\n\t// ControlCenterItems returns the items that will be displayed in the control center\n\tControlCenterItems() []ControlCenter\n\t// LoginCallback is called when the user center login callback is called\n\tLoginCallback(ctx *GinContext) (userInfo *UserCenterBasicUserInfo, err error)\n\t// SignUpCallback is called when the user center sign up callback is called\n\tSignUpCallback(ctx *GinContext) (userInfo *UserCenterBasicUserInfo, err error)\n\t// UserInfo returns the user information\n\tUserInfo(externalID string) (userInfo *UserCenterBasicUserInfo, err error)\n\t// UserStatus returns the latest user status\n\tUserStatus(externalID string) (userStatus UserStatus)\n\t// UserList returns the user list information\n\tUserList(externalIDs []string) (userInfo []*UserCenterBasicUserInfo, err error)\n\t// UserSettings returns the user settings\n\tUserSettings(externalID string) (userSettings *SettingInfo, err error)\n\t// PersonalBranding returns the personal branding information\n\tPersonalBranding(externalID string) (branding []*PersonalBranding)\n\t// AfterLogin is called after the user logs in\n\tAfterLogin(externalID, accessToken string)\n}\n```\n\n```go\nfunc GetUserCenter() (uc UserCenter, ok bool)\n```\n\n```go\ntype UserCenterBasicUserInfo struct {\n\tExternalID  string     `json:\"external_id\"`\n\tUsername    string     `json:\"username\"`\n\tDisplayName string     `json:\"display_name\"`\n\tEmail       string     `json:\"email\"`\n\tRank        int        `json:\"rank\"`\n\tAvatar      string     `json:\"avatar\"`\n\tMobile      string     `json:\"mobile\"`\n\tBio         string     `json:\"bio\"`\n\tStatus      UserStatus `json:\"status\"`\n}\n```\n\n```go\ntype UserCenterDesc struct {\n\tName                      string     `json:\"name\"`\n\tDisplayName               Translator `json:\"display_name\"`\n\tIcon                      string     `json:\"icon\"`\n\tUrl                       string     `json:\"url\"`\n\tLoginRedirectURL          string     `json:\"login_redirect_url\"`\n\tSignUpRedirectURL         string     `json:\"sign_up_redirect_url\"`\n\tRankAgentEnabled          bool       `json:\"rank_agent_enabled\"`\n\tUserStatusAgentEnabled    bool       `json:\"user_status_agent_enabled\"`\n\tUserRoleAgentEnabled      bool       `json:\"user_role_agent_enabled\"`\n\tMustAuthEmailEnabled      bool       `json:\"must_auth_email_enabled\"`\n\tEnabledOriginalUserSystem bool       `json:\"enabled_original_user_system\"`\n}\n```\n\n```go\ntype UserConfig interface {\n\tBase\n\n\t// UserConfigFields returns the list of config fields\n\tUserConfigFields() []ConfigField\n\t// UserConfigReceiver receives the config data, it calls when the config is saved or initialized.\n\t// We recommend to unmarshal the data to a struct, and then use the struct to do something.\n\t// The config is encoded in JSON format.\n\t// It depends on the definition of ConfigFields.\n\tUserConfigReceiver(userID string, config []byte) error\n}\n```\n\n```go\ntype UserStatus int\n```\n\n```go\nconst (\n\tUserStatusAvailable UserStatus = 1\n\tUserStatusSuspended UserStatus = 9\n\tUserStatusDeleted   UserStatus = 10\n)\n```\n\n","path":"github.com/apache/answer/plugin","name":"plugin","synopsis":"Package plugin","isRedistributable":true}
