Database updates (#144)

* start moving some database stuff around

* continue moving db stuff around

* more fiddling

* more updates

* and some more

* and yet more

* i broke SOMETHING but what, it's a mystery

* tidy up

* vendor ttlcache

* use ttlcache

* fix up some tests

* rename some stuff

* little reminder

* some more updates
This commit is contained in:
tobi
2021-08-20 12:26:56 +02:00
committed by GitHub
parent ce190d867c
commit 4920229a3b
164 changed files with 4850 additions and 2617 deletions

View File

@ -28,7 +28,6 @@ import (
"github.com/sirupsen/logrus"
"github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/db"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
)
// Controller generates transports for use in making federation requests to other servers.
@ -95,14 +94,15 @@ func (c *controller) NewTransportForUsername(username string) (Transport, error)
// We need an account to use to create a transport for dereferecing something.
// If a username has been given, we can fetch the account with that username and use it.
// Otherwise, we can take the instance account and use those credentials to make the request.
ourAccount := &gtsmodel.Account{}
var u string
if username == "" {
u = c.config.Host
} else {
u = username
}
if err := c.db.GetLocalAccountByUsername(u, ourAccount); err != nil {
ourAccount, err := c.db.GetLocalAccountByUsername(u)
if err != nil {
return nil, fmt.Errorf("error getting account %s from db: %s", username, err)
}