first implementation of search feature
这个提交包含在:
@ -10,6 +10,7 @@ import (
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/db"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/util"
|
||||
)
|
||||
|
||||
// Followers obtains the Followers Collection for an actor with the
|
||||
@ -28,8 +29,17 @@ func (f *federatingDB) Followers(c context.Context, actorIRI *url.URL) (follower
|
||||
l.Debugf("entering FOLLOWERS function with actorIRI %s", actorIRI.String())
|
||||
|
||||
acct := >smodel.Account{}
|
||||
if err := f.db.GetWhere([]db.Where{{Key: "uri", Value: actorIRI.String()}}, acct); err != nil {
|
||||
return nil, fmt.Errorf("db error getting account with uri %s: %s", actorIRI.String(), err)
|
||||
|
||||
if util.IsUserPath(actorIRI) {
|
||||
if err := f.db.GetWhere([]db.Where{{Key: "uri", Value: actorIRI.String()}}, acct); err != nil {
|
||||
return nil, fmt.Errorf("db error getting account with uri %s: %s", actorIRI.String(), err)
|
||||
}
|
||||
} else if util.IsFollowersPath(actorIRI) {
|
||||
if err := f.db.GetWhere([]db.Where{{Key: "followers_uri", Value: actorIRI.String()}}, acct); err != nil {
|
||||
return nil, fmt.Errorf("db error getting account with followers uri %s: %s", actorIRI.String(), err)
|
||||
}
|
||||
} else {
|
||||
return nil, fmt.Errorf("could not parse actor IRI %s as users or followers path", actorIRI.String())
|
||||
}
|
||||
|
||||
acctFollowers := []gtsmodel.Follow{}
|
||||
|
@ -10,6 +10,7 @@ import (
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/db"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/util"
|
||||
)
|
||||
|
||||
// Following obtains the Following Collection for an actor with the
|
||||
@ -28,8 +29,16 @@ func (f *federatingDB) Following(c context.Context, actorIRI *url.URL) (followin
|
||||
l.Debugf("entering FOLLOWING function with actorIRI %s", actorIRI.String())
|
||||
|
||||
acct := >smodel.Account{}
|
||||
if err := f.db.GetWhere([]db.Where{{Key: "uri", Value: actorIRI.String()}}, acct); err != nil {
|
||||
return nil, fmt.Errorf("db error getting account with uri %s: %s", actorIRI.String(), err)
|
||||
if util.IsUserPath(actorIRI) {
|
||||
if err := f.db.GetWhere([]db.Where{{Key: "uri", Value: actorIRI.String()}}, acct); err != nil {
|
||||
return nil, fmt.Errorf("db error getting account with uri %s: %s", actorIRI.String(), err)
|
||||
}
|
||||
} else if util.IsFollowingPath(actorIRI) {
|
||||
if err := f.db.GetWhere([]db.Where{{Key: "following_uri", Value: actorIRI.String()}}, acct); err != nil {
|
||||
return nil, fmt.Errorf("db error getting account with following uri %s: %s", actorIRI.String(), err)
|
||||
}
|
||||
} else {
|
||||
return nil, fmt.Errorf("could not parse actor IRI %s as users or following path", actorIRI.String())
|
||||
}
|
||||
|
||||
acctFollowing := []gtsmodel.Follow{}
|
||||
|
@ -42,6 +42,10 @@ func (f *federatingDB) Lock(c context.Context, id *url.URL) error {
|
||||
|
||||
// Strategy: create a new lock, if stored, continue. Otherwise, lock the
|
||||
// existing mutex.
|
||||
if id == nil {
|
||||
return errors.New("Lock: id was nil")
|
||||
}
|
||||
|
||||
mu := &sync.Mutex{}
|
||||
mu.Lock() // Optimistically lock if we do store it.
|
||||
i, loaded := f.locks.LoadOrStore(id.String(), mu)
|
||||
@ -59,6 +63,9 @@ func (f *federatingDB) Lock(c context.Context, id *url.URL) error {
|
||||
func (f *federatingDB) Unlock(c context.Context, id *url.URL) error {
|
||||
// Once Go-Fed is done calling Database methods, the relevant `id`
|
||||
// entries are unlocked.
|
||||
if id == nil {
|
||||
return errors.New("Unlock: id was nil")
|
||||
}
|
||||
|
||||
i, ok := f.locks.Load(id.String())
|
||||
if !ok {
|
||||
|
在新工单中引用
屏蔽一个用户