A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.
feat: Support SMTP Encryption using TLS
sy-recordsc1eb74bfb091
diff --git a/docs/docs.go b/docs/docs.goindex 3b8e51e3..d5f2e590 100644--- a/docs/docs.go+++ b/docs/docs.go@@ -6208,9 +6208,9 @@ const docTemplate = `{}}},- "/answer/api/v1/user/register/captcha": {- "get": {- "description": "UserRegisterCaptcha",+ "/answer/api/v1/user/register/email": {+ "post": {+ "description": "UserRegisterByEmail","consumes": ["application/json"],@@ -6220,7 +6220,18 @@ const docTemplate = `{"tags": ["User"],- "summary": "UserRegisterCaptcha",+ "summary": "UserRegisterByEmail",+ "parameters": [+ {+ "description": "UserRegisterReq",+ "name": "data",+ "in": "body",+ "required": true,+ "schema": {+ "$ref": "#/definitions/schema.UserRegisterReq"+ }+ }+ ],"responses": {"200": {"description": "OK",@@ -6243,9 +6254,14 @@ const docTemplate = `{}}},- "/answer/api/v1/user/register/email": {- "post": {- "description": "UserRegisterByEmail",+ "/answer/api/v1/user/staff": {+ "get": {+ "security": [+ {+ "ApiKeyAuth": []+ }+ ],+ "description": "get user staff","consumes": ["application/json"],@@ -6255,15 +6271,15 @@ const docTemplate = `{"tags": ["User"],- "summary": "UserRegisterByEmail",+ "summary": "get user staff","parameters": [{- "description": "UserRegisterReq",+ "description": "GetUserStaffReq","name": "data","in": "body","required": true,"schema": {- "$ref": "#/definitions/schema.UserRegisterReq"+ "$ref": "#/definitions/schema.GetUserStaffReq"}}],@@ -6279,7 +6295,7 @@ const docTemplate = `{"type": "object","properties": {"data": {- "$ref": "#/definitions/schema.UserLoginResp"+ "$ref": "#/definitions/schema.GetUserStaffResp"}}}@@ -6927,7 +6943,6 @@ const docTemplate = `{"type": "string"},"captcha_id": {- "description": "captcha_id","type": "string"},"mention_username_list": {@@ -7985,7 +8000,7 @@ const docTemplate = `{"type": "object","properties": {"encryption": {- "description": "\"\" SSL",+ "description": "\"\" SSL TLS","type": "string"},"from_email": {@@ -8333,6 +8348,36 @@ const docTemplate = `{}}},+ "schema.GetUserStaffReq": {+ "type": "object",+ "properties": {+ "page_size": {+ "type": "integer",+ "minimum": 1+ },+ "username": {+ "type": "string",+ "maxLength": 500+ }+ }+ },+ "schema.GetUserStaffResp": {+ "type": "object",+ "properties": {+ "avatar": {+ "description": "avatar",+ "type": "string"+ },+ "display_name": {+ "description": "display name",+ "type": "string"+ },+ "username": {+ "description": "username",+ "type": "string"+ }+ }+ },"schema.GetVoteWithPageResp": {"type": "object","properties": {@@ -8869,7 +8914,6 @@ const docTemplate = `{"type": "string"},"captcha_id": {- "description": "captcha_id","type": "string"},"comment_id": {@@ -9882,10 +9926,11 @@ const docTemplate = `{"type": "object","properties": {"encryption": {- "description": "\"\" SSL",+ "description": "\"\" SSL TLS","type": "string","enum": [- "SSL"+ "SSL",+ "TLS"]},"from_email": {@@ -10117,12 +10162,10 @@ const docTemplate = `{],"properties": {"captcha_code": {- "type": "string",- "maxLength": 500+ "type": "string"},"captcha_id": {- "type": "string",- "maxLength": 500+ "type": "string"},"e_mail": {"type": "string",@@ -10287,12 +10330,10 @@ const docTemplate = `{],"properties": {"captcha_code": {- "type": "string",- "maxLength": 500+ "type": "string"},"captcha_id": {- "type": "string",- "maxLength": 500+ "type": "string"},"old_pass": {"type": "string",@@ -10440,15 +10481,12 @@ const docTemplate = `{"type": "string"},"captcha_id": {- "description": "captcha_id","type": "string"},"is_cancel": {- "description": "is cancel","type": "boolean"},"object_id": {- "description": "id","type": "string"}}diff --git a/docs/swagger.json b/docs/swagger.jsonindex 00b06d9a..58cc5389 100644--- a/docs/swagger.json+++ b/docs/swagger.json@@ -6177,9 +6177,9 @@}}},- "/answer/api/v1/user/register/captcha": {- "get": {- "description": "UserRegisterCaptcha",+ "/answer/api/v1/user/register/email": {+ "post": {+ "description": "UserRegisterByEmail","consumes": ["application/json"],@@ -6189,7 +6189,18 @@"tags": ["User"],- "summary": "UserRegisterCaptcha",+ "summary": "UserRegisterByEmail",+ "parameters": [+ {+ "description": "UserRegisterReq",+ "name": "data",+ "in": "body",+ "required": true,+ "schema": {+ "$ref": "#/definitions/schema.UserRegisterReq"+ }+ }+ ],"responses": {"200": {"description": "OK",@@ -6212,9 +6223,14 @@}}},- "/answer/api/v1/user/register/email": {- "post": {- "description": "UserRegisterByEmail",+ "/answer/api/v1/user/staff": {+ "get": {+ "security": [+ {+ "ApiKeyAuth": []+ }+ ],+ "description": "get user staff","consumes": ["application/json"],@@ -6224,15 +6240,15 @@"tags": ["User"],- "summary": "UserRegisterByEmail",+ "summary": "get user staff","parameters": [{- "description": "UserRegisterReq",+ "description": "GetUserStaffReq","name": "data","in": "body","required": true,"schema": {- "$ref": "#/definitions/schema.UserRegisterReq"+ "$ref": "#/definitions/schema.GetUserStaffReq"}}],@@ -6248,7 +6264,7 @@"type": "object","properties": {"data": {- "$ref": "#/definitions/schema.UserLoginResp"+ "$ref": "#/definitions/schema.GetUserStaffResp"}}}@@ -6896,7 +6912,6 @@"type": "string"},"captcha_id": {- "description": "captcha_id","type": "string"},"mention_username_list": {@@ -7954,7 +7969,7 @@"type": "object","properties": {"encryption": {- "description": "\"\" SSL",+ "description": "\"\" SSL TLS","type": "string"},"from_email": {@@ -8302,6 +8317,36 @@}}},+ "schema.GetUserStaffReq": {+ "type": "object",+ "properties": {+ "page_size": {+ "type": "integer",+ "minimum": 1+ },+ "username": {+ "type": "string",+ "maxLength": 500+ }+ }+ },+ "schema.GetUserStaffResp": {+ "type": "object",+ "properties": {+ "avatar": {+ "description": "avatar",+ "type": "string"+ },+ "display_name": {+ "description": "display name",+ "type": "string"+ },+ "username": {+ "description": "username",+ "type": "string"+ }+ }+ },"schema.GetVoteWithPageResp": {"type": "object","properties": {@@ -8838,7 +8883,6 @@"type": "string"},"captcha_id": {- "description": "captcha_id","type": "string"},"comment_id": {@@ -9851,10 +9895,11 @@"type": "object","properties": {"encryption": {- "description": "\"\" SSL",+ "description": "\"\" SSL TLS","type": "string","enum": [- "SSL"+ "SSL",+ "TLS"]},"from_email": {@@ -10086,12 +10131,10 @@],"properties": {"captcha_code": {- "type": "string",- "maxLength": 500+ "type": "string"},"captcha_id": {- "type": "string",- "maxLength": 500+ "type": "string"},"e_mail": {"type": "string",@@ -10256,12 +10299,10 @@],"properties": {"captcha_code": {- "type": "string",- "maxLength": 500+ "type": "string"},"captcha_id": {- "type": "string",- "maxLength": 500+ "type": "string"},"old_pass": {"type": "string",@@ -10409,15 +10450,12 @@"type": "string"},"captcha_id": {- "description": "captcha_id","type": "string"},"is_cancel": {- "description": "is cancel","type": "boolean"},"object_id": {- "description": "id","type": "string"}}diff --git a/docs/swagger.yaml b/docs/swagger.yamlindex 8c094f86..5b7a7de7 100644--- a/docs/swagger.yaml+++ b/docs/swagger.yaml@@ -1,20 +1,3 @@-# Licensed to the Apache Software Foundation (ASF) under one-# or more contributor license agreements. See the NOTICE file-# distributed with this work for additional information-# regarding copyright ownership. The ASF licenses this file-# to you under the Apache License, Version 2.0 (the-# "License"); you may not use this file except in compliance-# with the License. You may obtain a copy of the License at-#-# http://www.apache.org/licenses/LICENSE-2.0-#-# Unless required by applicable law or agreed to in writing,-# software distributed under the License is distributed on an-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY-# KIND, either express or implied. See the License for the-# specific language governing permissions and limitations-# under the License.-definitions:constant.NotificationChannelKey:enum:@@ -181,7 +164,6 @@ definitions:captcha_code:type: stringcaptcha_id:- description: captcha_idtype: stringmention_username_list:description: '@ user id list'@@ -930,7 +912,7 @@ definitions:schema.GetSMTPConfigResp:properties:encryption:- description: '"" SSL'+ description: '"" SSL TLS'type: stringfrom_email:type: string@@ -1169,6 +1151,27 @@ definitions:slug_name:type: stringtype: object+ schema.GetUserStaffReq:+ properties:+ page_size:+ minimum: 1+ type: integer+ username:+ maxLength: 500+ type: string+ type: object+ schema.GetUserStaffResp:+ properties:+ avatar:+ description: avatar+ type: string+ display_name:+ description: display name+ type: string+ username:+ description: username+ type: string+ type: objectschema.GetVoteWithPageResp:properties:answer_id:@@ -1541,7 +1544,6 @@ definitions:captcha_code:type: stringcaptcha_id:- description: captcha_idtype: stringcomment_id:description: comment id@@ -2234,9 +2236,10 @@ definitions:schema.UpdateSMTPConfigReq:properties:encryption:- description: '"" SSL'+ description: '"" SSL TLS'enum:- SSL+ - TLStype: stringfrom_email:maxLength: 256@@ -2397,10 +2400,8 @@ definitions:schema.UserChangeEmailSendCodeReq:properties:captcha_code:- maxLength: 500type: stringcaptcha_id:- maxLength: 500type: stringe_mail:maxLength: 500@@ -2521,10 +2522,8 @@ definitions:schema.UserModifyPasswordReq:properties:captcha_code:- maxLength: 500type: stringcaptcha_id:- maxLength: 500type: stringold_pass:maxLength: 32@@ -2628,13 +2627,10 @@ definitions:captcha_code:type: stringcaptcha_id:- description: captcha_idtype: stringis_cancel:- description: is canceltype: booleanobject_id:- description: idtype: stringrequired:- object_id@@ -6390,11 +6386,18 @@ paths:summary: get user rankingtags:- User- /answer/api/v1/user/register/captcha:- get:+ /answer/api/v1/user/register/email:+ post:consumes:- application/json- description: UserRegisterCaptcha+ description: UserRegisterByEmail+ parameters:+ - description: UserRegisterReq+ in: body+ name: data+ required: true+ schema:+ $ref: '#/definitions/schema.UserRegisterReq'produces:- application/jsonresponses:@@ -6407,21 +6410,21 @@ paths:data:$ref: '#/definitions/schema.UserLoginResp'type: object- summary: UserRegisterCaptcha+ summary: UserRegisterByEmailtags:- User- /answer/api/v1/user/register/email:- post:+ /answer/api/v1/user/staff:+ get:consumes:- application/json- description: UserRegisterByEmail+ description: get user staffparameters:- - description: UserRegisterReq+ - description: GetUserStaffReqin: bodyname: datarequired: trueschema:- $ref: '#/definitions/schema.UserRegisterReq'+ $ref: '#/definitions/schema.GetUserStaffReq'produces:- application/jsonresponses:@@ -6432,9 +6435,11 @@ paths:- $ref: '#/definitions/handler.RespBody'- properties:data:- $ref: '#/definitions/schema.UserLoginResp'+ $ref: '#/definitions/schema.GetUserStaffResp'type: object- summary: UserRegisterByEmail+ security:+ - ApiKeyAuth: []+ summary: get user stafftags:- User/answer/api/v1/vote/down:diff --git a/i18n/en_US.yaml b/i18n/en_US.yamlindex 25f3ad04..850dc7d1 100644--- a/i18n/en_US.yaml+++ b/i18n/en_US.yaml@@ -1667,6 +1667,7 @@ ui:msg: Encryption cannot be empty.text: For most servers SSL is the recommended option.ssl: SSL+ tls: TLSnone: Nonesmtp_port:label: SMTP portdiff --git a/i18n/zh_CN.yaml b/i18n/zh_CN.yamlindex 9abddc22..f92974ad 100644--- a/i18n/zh_CN.yaml+++ b/i18n/zh_CN.yaml@@ -1620,6 +1620,7 @@ ui:msg: 不能为空text: 对于大多数服务器而言,SSL 是推荐开启的。ssl: SSL+ tls: TLSnone: 无加密smtp_port:label: SMTP 端口diff --git a/internal/schema/siteinfo_schema.go b/internal/schema/siteinfo_schema.goindex ea19d046..abb9ea37 100644--- a/internal/schema/siteinfo_schema.go+++ b/internal/schema/siteinfo_schema.go@@ -236,7 +236,7 @@ type UpdateSMTPConfigReq struct {FromName string `validate:"omitempty,gt=0,lte=256" json:"from_name"`SMTPHost string `validate:"omitempty,gt=0,lte=256" json:"smtp_host"`SMTPPort int `validate:"omitempty,min=1,max=65535" json:"smtp_port"`- Encryption string `validate:"omitempty,oneof=SSL" json:"encryption"` // "" SSL+ Encryption string `validate:"omitempty,oneof=SSL TLS" json:"encryption"` // "" SSL TLSSMTPUsername string `validate:"omitempty,gt=0,lte=256" json:"smtp_username"`SMTPPassword string `validate:"omitempty,gt=0,lte=256" json:"smtp_password"`SMTPAuthentication bool `validate:"omitempty" json:"smtp_authentication"`@@ -260,7 +260,7 @@ type GetSMTPConfigResp struct {FromName string `json:"from_name"`SMTPHost string `json:"smtp_host"`SMTPPort int `json:"smtp_port"`- Encryption string `json:"encryption"` // "" SSL+ Encryption string `json:"encryption"` // "" SSL TLSSMTPUsername string `json:"smtp_username"`SMTPPassword string `json:"smtp_password"`SMTPAuthentication bool `json:"smtp_authentication"`diff --git a/ui/src/pages/Admin/Smtp/index.tsx b/ui/src/pages/Admin/Smtp/index.tsxindex 40725c31..cde274e3 100644--- a/ui/src/pages/Admin/Smtp/index.tsx+++ b/ui/src/pages/Admin/Smtp/index.tsx@@ -55,8 +55,8 @@ const Smtp: FC = () => {type: 'string',title: t('encryption.label'),description: t('encryption.text'),- enum: ['SSL', ''],- enumNames: ['SSL', 'None'],+ enum: ['TLS', 'SSL', ''],+ enumNames: ['TLS', 'SSL', 'None'],},smtp_port: {type: 'string',