Skip to content

Commit 8b739c5

Browse files
committed
fix(service): set default language to "en_US" if invalid language is provided
1 parent 27cd773 commit 8b739c5

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

internal/service/siteinfo/siteinfo_service.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ import (
4040
tagcommon "github.com/apache/answer/internal/service/tag_common"
4141
"github.com/apache/answer/plugin"
4242
"github.com/jinzhu/copier"
43-
"github.com/segmentfault/pacman/errors"
4443
"github.com/segmentfault/pacman/log"
4544
)
4645

@@ -159,10 +158,9 @@ func (s *SiteInfoService) SaveSiteGeneral(ctx context.Context, req schema.SiteGe
159158
}
160159

161160
func (s *SiteInfoService) SaveSiteInterface(ctx context.Context, req schema.SiteInterfaceReq) (err error) {
162-
// check language
161+
// If the language is invalid, set it to the default language "en_US"
163162
if !translator.CheckLanguageIsValid(req.Language) {
164-
err = errors.BadRequest(reason.LangNotFound)
165-
return
163+
req.Language = "en_US"
166164
}
167165

168166
content, _ := json.Marshal(req)

0 commit comments

Comments
 (0)