This commit is contained in:
parent
98191fd098
commit
d272fa90b4
20 changed files with 574 additions and 27 deletions
|
@ -1456,6 +1456,7 @@ type IUserDo interface {
|
|||
UnderlyingDB() *gorm.DB
|
||||
schema.Tabler
|
||||
|
||||
GetByUsernameUnrestricted(username string) (result *models.User, err error)
|
||||
GetByUsername(username string) (result *models.User, err error)
|
||||
GetPagedTruePublic(pageNr uint) (result []models.User, err error)
|
||||
GetPagedAllDeleted(pageNr uint) (result []models.User, err error)
|
||||
|
@ -1463,10 +1464,10 @@ type IUserDo interface {
|
|||
GdprUsers() (err error)
|
||||
}
|
||||
|
||||
// Get a user by a username
|
||||
// Get a user by a username, ignoring all restrictions on that user
|
||||
//
|
||||
// SELECT * FROM @@table WHERE username = @username AND deleted_at IS NULL LIMIT 1
|
||||
func (u userDo) GetByUsername(username string) (result *models.User, err error) {
|
||||
func (u userDo) GetByUsernameUnrestricted(username string) (result *models.User, err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
|
@ -1480,6 +1481,31 @@ func (u userDo) GetByUsername(username string) (result *models.User, err error)
|
|||
return
|
||||
}
|
||||
|
||||
// Get a user by the username.
|
||||
// Restricted to users visible to ActivityPub
|
||||
//
|
||||
// SELECT * FROM @@table WHERE
|
||||
//
|
||||
// username = @username AND
|
||||
// deleted_at IS NULL AND
|
||||
// finished_registration = true AND
|
||||
// verified = true
|
||||
//
|
||||
// LIMIT 1
|
||||
func (u userDo) GetByUsername(username string) (result *models.User, err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
params = append(params, username)
|
||||
generateSQL.WriteString("SELECT * FROM users WHERE username = ? AND deleted_at IS NULL AND finished_registration = true AND verified = true LIMIT 1 ")
|
||||
|
||||
var executeSQL *gorm.DB
|
||||
executeSQL = u.UnderlyingDB().Raw(generateSQL.String(), params...).Take(&result) // ignore_security_alert
|
||||
err = executeSQL.Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// Get all true public accounts (verified & no restricted follow & indexable)
|
||||
// in a paged manner, sorted by date saved
|
||||
//
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue