Skip to content

Commit 5b9c00c

Browse files
committed
Merge remote-tracking branch 'origin/feat/1.5.0/user' into test
2 parents 3f87e16 + 5b7cdce commit 5b9c00c

File tree

17 files changed

+146
-83
lines changed

17 files changed

+146
-83
lines changed

docs/swagger.json

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5006,9 +5006,6 @@
50065006
"/answer/api/v1/report": {
50075007
"post": {
50085008
"security": [
5009-
{
5010-
"ApiKeyAuth": []
5011-
},
50125009
{
50135010
"ApiKeyAuth": []
50145011
}
@@ -5048,9 +5045,6 @@
50485045
"/answer/api/v1/report/review": {
50495046
"put": {
50505047
"security": [
5051-
{
5052-
"ApiKeyAuth": []
5053-
},
50545048
{
50555049
"ApiKeyAuth": []
50565050
}
@@ -5153,9 +5147,6 @@
51535147
"/answer/api/v1/review/pending/post": {
51545148
"put": {
51555149
"security": [
5156-
{
5157-
"ApiKeyAuth": []
5158-
},
51595150
{
51605151
"ApiKeyAuth": []
51615152
}
@@ -6268,9 +6259,6 @@
62686259
"/answer/api/v1/user/email/verification/send": {
62696260
"post": {
62706261
"security": [
6271-
{
6272-
"ApiKeyAuth": []
6273-
},
62746262
{
62756263
"ApiKeyAuth": []
62766264
}

i18n/en_US.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ backend:
565565
name:
566566
other: First Link
567567
desc:
568-
other: First dirst added a link to another post.
568+
other: First added a link to another post.
569569
first_reaction:
570570
name:
571571
other: First Reaction

i18n/zh_CN.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ backend:
564564
name:
565565
other: 第一个链接
566566
desc:
567-
other: 第一个脏添加了一个链接到另一个帖子
567+
other: 第一次添加了一个链接到另一个帖子
568568
first_reaction:
569569
name:
570570
other: 第一个响应

internal/base/constant/constant.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,43 @@ var (
2929
Revision = ""
3030
GoVersion = ""
3131
)
32+
33+
var Timezones = []string{
34+
// Americas
35+
"America/New_York",
36+
"America/Chicago",
37+
"America/Los_Angeles",
38+
"America/Toronto",
39+
"America/Vancouver",
40+
"America/Mexico_City",
41+
"America/Sao_Paulo",
42+
"America/Buenos_Aires",
43+
44+
// Europe
45+
"Europe/London",
46+
"Europe/Paris",
47+
"Europe/Berlin",
48+
"Europe/Madrid",
49+
"Europe/Rome",
50+
"Europe/Moscow",
51+
52+
// Asia
53+
"Asia/Shanghai",
54+
"Asia/Tokyo",
55+
"Asia/Singapore",
56+
"Asia/Dubai",
57+
"Asia/Hong_Kong",
58+
"Asia/Seoul",
59+
"Asia/Bangkok",
60+
"Asia/Kolkata",
61+
62+
// Pacific
63+
"Australia/Sydney",
64+
"Australia/Melbourne",
65+
"Pacific/Auckland",
66+
67+
// Africa
68+
"Africa/Cairo",
69+
"Africa/Johannesburg",
70+
"Africa/Lagos",
71+
}

internal/cli/build.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func newAnswerBuilder(buildDir, outputPath string, plugins []string, originalAns
105105
if len(outputPath) == 0 {
106106
outputPath = filepath.Join(parentDir, "new_answer")
107107
}
108-
material.outputPath = outputPath
108+
material.outputPath, _ = filepath.Abs(outputPath)
109109
material.plugins = formatPlugins(plugins)
110110
material.answerModuleReplacement = os.Getenv("ANSWER_MODULE")
111111
return &answerBuilder{

internal/controller/report_controller.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ func NewReportController(
5959
// AddReport add report
6060
// @Summary add report
6161
// @Description add report <br> source (question, answer, comment, user)
62-
// @Security ApiKeyAuth
6362
// @Tags Report
6463
// @Accept json
6564
// @Produce json
@@ -130,7 +129,6 @@ func (rc *ReportController) GetUnreviewedReportPostPage(ctx *gin.Context) {
130129
// ReviewReport review report
131130
// @Summary review report
132131
// @Description review report
133-
// @Security ApiKeyAuth
134132
// @Tags Report
135133
// @Accept json
136134
// @Produce json

internal/controller/review_controller.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ func (rc *ReviewController) GetUnreviewedPostPage(ctx *gin.Context) {
8686
// UpdateReview update review
8787
// @Summary update review
8888
// @Description update review
89-
// @Security ApiKeyAuth
9089
// @Tags Review
9190
// @Accept json
9291
// @Produce json

internal/controller/tag_controller.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,10 @@ func (tc *TagController) GetTagWithPage(ctx *gin.Context) {
274274
req.UserID = middleware.GetLoginUserIDFromContext(ctx)
275275

276276
resp, err := tc.tagService.GetTagWithPage(ctx, req)
277+
if err != nil {
278+
handler.HandleResponse(ctx, err, nil)
279+
return
280+
}
277281
if pager.ValPageOutOfRange(resp.Count, req.Page, req.PageSize) {
278282
handler.HandleResponse(ctx, errors.NotFound(reason.RequestFormatError), nil)
279283
return

internal/controller/user_controller.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,11 @@ func (uc *UserController) UserEmailLogin(ctx *gin.Context) {
162162
if !isAdmin {
163163
uc.actionService.ActionRecordDel(ctx, entity.CaptchaActionPassword, ctx.ClientIP())
164164
}
165+
if resp.Status == constant.UserSuspended {
166+
handler.HandleResponse(ctx, errors.Forbidden(reason.UserSuspended),
167+
&schema.ForbiddenResp{Type: schema.ForbiddenReasonTypeUserSuspended})
168+
return
169+
}
165170
uc.setVisitCookies(ctx, resp.VisitToken, true)
166171
handler.HandleResponse(ctx, nil, resp)
167172
}
@@ -335,7 +340,6 @@ func (uc *UserController) UserVerifyEmail(ctx *gin.Context) {
335340
// UserVerifyEmailSend godoc
336341
// @Summary UserVerifyEmailSend
337342
// @Description UserVerifyEmailSend
338-
// @Security ApiKeyAuth
339343
// @Tags User
340344
// @Accept json
341345
// @Produce json

internal/install/install_from_env.go

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,14 @@ type Env struct {
4141
DbFile string `json:"db_file"`
4242
Language string `json:"lang"`
4343

44-
SiteName string `json:"site_name"`
45-
SiteURL string `json:"site_url"`
46-
ContactEmail string `json:"contact_email"`
47-
AdminName string `json:"name"`
48-
AdminPassword string `json:"password"`
49-
AdminEmail string `json:"email"`
50-
LoginRequired bool `json:"login_required"`
44+
SiteName string `json:"site_name"`
45+
SiteURL string `json:"site_url"`
46+
ContactEmail string `json:"contact_email"`
47+
AdminName string `json:"name"`
48+
AdminPassword string `json:"password"`
49+
AdminEmail string `json:"email"`
50+
LoginRequired bool `json:"login_required"`
51+
ExternalContentDisplay string `json:"external_content_display"`
5152
}
5253

5354
func TryToInstallByEnv() (installByEnv bool, err error) {
@@ -61,20 +62,21 @@ func TryToInstallByEnv() (installByEnv bool, err error) {
6162

6263
func loadEnv() (env *Env) {
6364
return &Env{
64-
AutoInstall: os.Getenv("AUTO_INSTALL"),
65-
DbType: os.Getenv("DB_TYPE"),
66-
DbUsername: os.Getenv("DB_USERNAME"),
67-
DbPassword: os.Getenv("DB_PASSWORD"),
68-
DbHost: os.Getenv("DB_HOST"),
69-
DbName: os.Getenv("DB_NAME"),
70-
DbFile: os.Getenv("DB_FILE"),
71-
Language: os.Getenv("LANGUAGE"),
72-
SiteName: os.Getenv("SITE_NAME"),
73-
SiteURL: os.Getenv("SITE_URL"),
74-
ContactEmail: os.Getenv("CONTACT_EMAIL"),
75-
AdminName: os.Getenv("ADMIN_NAME"),
76-
AdminPassword: os.Getenv("ADMIN_PASSWORD"),
77-
AdminEmail: os.Getenv("ADMIN_EMAIL"),
65+
AutoInstall: os.Getenv("AUTO_INSTALL"),
66+
DbType: os.Getenv("DB_TYPE"),
67+
DbUsername: os.Getenv("DB_USERNAME"),
68+
DbPassword: os.Getenv("DB_PASSWORD"),
69+
DbHost: os.Getenv("DB_HOST"),
70+
DbName: os.Getenv("DB_NAME"),
71+
DbFile: os.Getenv("DB_FILE"),
72+
Language: os.Getenv("LANGUAGE"),
73+
SiteName: os.Getenv("SITE_NAME"),
74+
SiteURL: os.Getenv("SITE_URL"),
75+
ContactEmail: os.Getenv("CONTACT_EMAIL"),
76+
AdminName: os.Getenv("ADMIN_NAME"),
77+
AdminPassword: os.Getenv("ADMIN_PASSWORD"),
78+
AdminEmail: os.Getenv("ADMIN_EMAIL"),
79+
ExternalContentDisplay: os.Getenv("EXTERNAL_CONTENT_DISPLAY"),
7880
}
7981
}
8082

@@ -118,14 +120,15 @@ func initConfigAndDb(env *Env) (err error) {
118120

119121
func initBaseInfo(env *Env) (err error) {
120122
req := &InitBaseInfoReq{
121-
Language: env.Language,
122-
SiteName: env.SiteName,
123-
SiteURL: env.SiteURL,
124-
ContactEmail: env.ContactEmail,
125-
AdminName: env.AdminName,
126-
AdminPassword: env.AdminPassword,
127-
AdminEmail: env.AdminEmail,
128-
LoginRequired: env.LoginRequired,
123+
Language: env.Language,
124+
SiteName: env.SiteName,
125+
SiteURL: env.SiteURL,
126+
ContactEmail: env.ContactEmail,
127+
AdminName: env.AdminName,
128+
AdminPassword: env.AdminPassword,
129+
AdminEmail: env.AdminEmail,
130+
LoginRequired: env.LoginRequired,
131+
ExternalContentDisplay: env.ExternalContentDisplay,
129132
}
130133
return requestAPI(req, "POST", "/installation/base-info", InitBaseInfo)
131134
}

0 commit comments

Comments
 (0)