From 9db54d1dd184f106208463103982b8f3f25d85f6 Mon Sep 17 00:00:00 2001 From: rainzm Date: Sun, 17 Jan 2021 19:36:43 +0800 Subject: [PATCH] fix(notify): remote 'lang' filter when contact type is 'mobile' --- pkg/notify/models/template.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pkg/notify/models/template.go b/pkg/notify/models/template.go index f00f8a7937..b68738103b 100644 --- a/pkg/notify/models/template.go +++ b/pkg/notify/models/template.go @@ -237,7 +237,14 @@ func (tm *STemplateManager) NotifyFilter(contactType, topic, msg, lang string) ( return } templates := make([]STemplate, 0, 3) - q := tm.Query().Equals("topic", strings.ToUpper(topic)).Equals("lang", lang).In("contact_type", []string{CONTACTTYPE_ALL, contactType}) + var q *sqlchemy.SQuery + if contactType == api.MOBILE { + // hack + // ingore lang when contactType is mobile + q = tm.Query().Equals("topic", strings.ToUpper(topic)).In("contact_type", []string{CONTACTTYPE_ALL, contactType}) + } else { + q = tm.Query().Equals("topic", strings.ToUpper(topic)).Equals("lang", lang).In("contact_type", []string{CONTACTTYPE_ALL, contactType}) + } err = db.FetchModelObjects(tm, q, &templates) if errors.Cause(err) == sql.ErrNoRows || len(templates) == 0 { // no such template, return as is