mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-12-02 21:08:08 -06:00
parent
ac9adb172b
commit
6f5c045284
183 changed files with 7391 additions and 5414 deletions
|
|
@ -20,17 +20,13 @@ package db
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net"
|
||||
"strings"
|
||||
|
||||
"github.com/go-fed/activity/pub"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/config"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/db/gtsmodel"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
|
||||
)
|
||||
|
||||
const dbTypePostgres string = "POSTGRES"
|
||||
const DBTypePostgres string = "POSTGRES"
|
||||
|
||||
// ErrNoEntries is to be returned from the DB interface when no entries are found for a given query.
|
||||
type ErrNoEntries struct{}
|
||||
|
|
@ -126,6 +122,12 @@ type DB interface {
|
|||
// In case of no entries, a 'no entries' error will be returned
|
||||
GetAccountByUserID(userID string, account *gtsmodel.Account) error
|
||||
|
||||
// GetLocalAccountByUsername is a shortcut for the common action of fetching an account ON THIS INSTANCE
|
||||
// according to its username, which should be unique.
|
||||
// The given account pointer will be set to the result of the query, whatever it is.
|
||||
// In case of no entries, a 'no entries' error will be returned
|
||||
GetLocalAccountByUsername(username string, account *gtsmodel.Account) error
|
||||
|
||||
// GetFollowRequestsForAccountID is a shortcut for the common action of fetching a list of follow requests targeting the given account ID.
|
||||
// The given slice 'followRequests' will be set to the result of the query, whatever it is.
|
||||
// In case of no entries, a 'no entries' error will be returned
|
||||
|
|
@ -277,14 +279,3 @@ type DB interface {
|
|||
// if they exist in the db and conveniently returning them if they do.
|
||||
EmojiStringsToEmojis(emojis []string, originAccountID string, statusID string) ([]*gtsmodel.Emoji, error)
|
||||
}
|
||||
|
||||
// New returns a new database service that satisfies the DB interface and, by extension,
|
||||
// the go-fed database interface described here: https://github.com/go-fed/activity/blob/master/pub/database.go
|
||||
func New(ctx context.Context, c *config.Config, log *logrus.Logger) (DB, error) {
|
||||
switch strings.ToUpper(c.DBConfig.Type) {
|
||||
case dbTypePostgres:
|
||||
return newPostgresService(ctx, c, log.WithField("service", "db"))
|
||||
default:
|
||||
return nil, fmt.Errorf("database type %s not supported", c.DBConfig.Type)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue