Merge pull request #2 from Kasp42/jr6wxx-codex/-pr-#4152

Кэшировать `subEmailInRemark` в `SubService` чтобы избежать повторных вызовов настройки
This commit is contained in:
Vladislav Kasperov 2026-05-03 13:43:23 +03:00 committed by GitHub
commit 298e53e3ac
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -28,6 +28,7 @@ type SubService struct {
showInfo bool showInfo bool
remarkModel string remarkModel string
datepicker string datepicker string
emailInRemark bool
inboundService service.InboundService inboundService service.InboundService
settingService service.SettingService settingService service.SettingService
} }
@ -35,8 +36,9 @@ type SubService struct {
// NewSubService creates a new subscription service with the given configuration. // NewSubService creates a new subscription service with the given configuration.
func NewSubService(showInfo bool, remarkModel string) *SubService { func NewSubService(showInfo bool, remarkModel string) *SubService {
return &SubService{ return &SubService{
showInfo: showInfo, showInfo: showInfo,
remarkModel: remarkModel, remarkModel: remarkModel,
emailInRemark: true,
} }
} }
@ -60,6 +62,11 @@ func (s *SubService) GetSubs(subId string, host string) ([]string, int64, xray.C
if err != nil { if err != nil {
s.datepicker = "gregorian" s.datepicker = "gregorian"
} }
s.emailInRemark, err = s.settingService.GetSubEmailInRemark()
if err != nil {
s.emailInRemark = true
}
for _, inbound := range inbounds { for _, inbound := range inbounds {
clients, err := s.inboundService.GetClients(inbound) clients, err := s.inboundService.GetClients(inbound)
if err != nil { if err != nil {
@ -825,11 +832,7 @@ func (s *SubService) genRemark(inbound *model.Inbound, email string, extra strin
'e': "", 'e': "",
'o': "", 'o': "",
} }
emailInRemark, err := s.settingService.GetSubEmailInRemark() if len(email) > 0 && s.emailInRemark {
if err != nil {
emailInRemark = true
}
if len(email) > 0 && emailInRemark {
orders['e'] = email orders['e'] = email
} }
if len(inbound.Remark) > 0 { if len(inbound.Remark) > 0 {