Escape reference to user table in models.SearchEmails (#16313)

Fix #16312

Signed-off-by: Adyanth H <adyanthh@gmail.com>
This commit is contained in:
Adyanth H 2021-06-30 22:07:20 +05:30 committed by GitHub
parent 0966349354
commit 66bf74d1b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -316,7 +316,7 @@ type SearchEmailResult struct {
// SearchEmails takes options i.e. keyword and part of email name to search, // SearchEmails takes options i.e. keyword and part of email name to search,
// it returns results in given range and number of total results. // it returns results in given range and number of total results.
func SearchEmails(opts *SearchEmailOptions) ([]*SearchEmailResult, int64, error) { func SearchEmails(opts *SearchEmailOptions) ([]*SearchEmailResult, int64, error) {
var cond builder.Cond = builder.Eq{"user.`type`": UserTypeIndividual} var cond builder.Cond = builder.Eq{"`user`.`type`": UserTypeIndividual}
if len(opts.Keyword) > 0 { if len(opts.Keyword) > 0 {
likeStr := "%" + strings.ToLower(opts.Keyword) + "%" likeStr := "%" + strings.ToLower(opts.Keyword) + "%"
cond = cond.And(builder.Or( cond = cond.And(builder.Or(