mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-18 11:37:29 -06:00
restructuring federator
This commit is contained in:
parent
d9da0022e1
commit
b777a682fe
15 changed files with 410 additions and 195 deletions
|
|
@ -147,17 +147,13 @@ func (f *federatingDB) Owns(c context.Context, id *url.URL) (bool, error) {
|
|||
return false, fmt.Errorf("error parsing statuses path for url %s: %s", id.String(), err)
|
||||
}
|
||||
acct := >smodel.Account{}
|
||||
if err := f.db.GetWhere("username", username, acct); err != nil {
|
||||
if err := f.db.GetLocalAccountByUsername(username, acct); err != nil {
|
||||
if _, ok := err.(ErrNoEntries); ok {
|
||||
// there are no entries for this username
|
||||
return false, nil
|
||||
}
|
||||
return false, fmt.Errorf("database error fetching account with username %s: %s", username, err)
|
||||
}
|
||||
if acct.Domain != "" {
|
||||
// this is a remote account so we don't own it after all
|
||||
return false, nil
|
||||
}
|
||||
status := >smodel.Status{}
|
||||
if err := f.db.GetByID(uid, status); err != nil {
|
||||
if _, ok := err.(ErrNoEntries); ok {
|
||||
|
|
@ -177,17 +173,13 @@ func (f *federatingDB) Owns(c context.Context, id *url.URL) (bool, error) {
|
|||
return false, fmt.Errorf("error parsing statuses path for url %s: %s", id.String(), err)
|
||||
}
|
||||
acct := >smodel.Account{}
|
||||
if err := f.db.GetWhere("username", username, acct); err != nil {
|
||||
if err := f.db.GetLocalAccountByUsername(username, acct); err != nil {
|
||||
if _, ok := err.(ErrNoEntries); ok {
|
||||
// there are no entries for this username
|
||||
return false, nil
|
||||
}
|
||||
return false, fmt.Errorf("database error fetching account with username %s: %s", username, err)
|
||||
}
|
||||
if acct.Domain != "" {
|
||||
// this is a remote account so we don't own it after all
|
||||
return false, nil
|
||||
}
|
||||
// the user exists, we own it, we're good
|
||||
return true, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue