feat(seo): If the site is set to privacy mode, prohibit crawling any page

This commit is contained in:
LinkinStar 2022-12-10 14:31:08 +08:00
parent 2769c007e7
commit 4fa01db61c
1 changed files with 12 additions and 0 deletions

View File

@ -255,6 +255,18 @@ func (s *SiteInfoService) UpdateSMTPConfig(ctx context.Context, req *schema.Upda
}
func (s *SiteInfoService) GetSeo(ctx context.Context) (resp *schema.SiteSeoResp, err error) {
resp = &schema.SiteSeoResp{}
loginConfig, err := s.GetSiteLogin(ctx)
if err != nil {
log.Error(err)
return resp, nil
}
// If the site is set to privacy mode, prohibit crawling any page.
if loginConfig.LoginRequired {
resp.Robots = "User-agent: *\nDisallow: /"
return resp, nil
}
resp = &schema.SiteSeoResp{}
siteInfo, exist, err := s.siteInfoRepo.GetByType(ctx, constant.SiteTypeSeo)
if err != nil {