Growth spike guest accounts (#19437)
* tools updates * Revert "tools updates" This reverts commit 6293297b55803c5a263e200ebd80192899666ae9. * new endpoint to get users that should potentially be guests * checking authservice to ensure they were an email signup * adding tests for new endpoint * fixing translation issue * permissions for new endpoint * fixing tests * fixing when domain array is empty * fixing when domain array is empty * removing bots from request Co-authored-by: Benjamin Cooke <benjamincooke@Benjamins-MacBook-Pro.local> Co-authored-by: Benjamin Cooke <benjamincooke@Benjamins-MBP.ht.home> Co-authored-by: mkraft <martinkraft@gmail.com>
Этот коммит содержится в:
@@ -2076,3 +2076,36 @@ func (us SqlUserStore) IsEmpty(excludeBots bool) (bool, error) {
|
||||
}
|
||||
return !hasRows, nil
|
||||
}
|
||||
|
||||
func (us SqlUserStore) GetUsersWithInvalidEmails(page int, perPage int, restrictedDomains string) ([]*model.User, error) {
|
||||
domainArray := strings.Split(restrictedDomains, ",")
|
||||
query := us.usersQuery.
|
||||
LeftJoin("Bots ON u.Id = Bots.UserId").
|
||||
Where("Bots.UserId IS NULL").
|
||||
Where("u.Roles != 'system_guest'").
|
||||
Where("u.DeleteAt = 0").
|
||||
Where("(u.AuthService = '' OR u.AuthService IS NULL)")
|
||||
|
||||
for _, d := range domainArray {
|
||||
if d != "" {
|
||||
query = query.Where("u.Email NOT LIKE LOWER(?)", wildcardSearchTerm(d))
|
||||
}
|
||||
}
|
||||
query = query.Offset(uint64(page * perPage)).Limit(uint64(perPage))
|
||||
|
||||
queryString, args, err := query.ToSql()
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "users_get_many_tosql")
|
||||
}
|
||||
|
||||
var users []*model.User
|
||||
if _, err := us.GetReplica().Select(&users, queryString, args...); err != nil {
|
||||
return nil, errors.Wrap(err, "users_get_many_select")
|
||||
}
|
||||
|
||||
for _, u := range users {
|
||||
u.Sanitize(map[string]bool{})
|
||||
}
|
||||
|
||||
return users, nil
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user