From 4fa01db61c47e6e5b35b3c1a696b2f141915b412 Mon Sep 17 00:00:00 2001 From: LinkinStar Date: Sat, 10 Dec 2022 14:31:08 +0800 Subject: [PATCH] feat(seo): If the site is set to privacy mode, prohibit crawling any page --- internal/service/siteinfo/siteinfo_service.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/internal/service/siteinfo/siteinfo_service.go b/internal/service/siteinfo/siteinfo_service.go index cdcad1f5..afbd7edd 100644 --- a/internal/service/siteinfo/siteinfo_service.go +++ b/internal/service/siteinfo/siteinfo_service.go @@ -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 {