Move a lot of stuff + tidy stuff (#37)
Lots of renaming and moving stuff, some bug fixes, more lenient parsing of notifications and home timeline.
This commit is contained in:
@ -30,34 +30,10 @@ 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{}
|
||||
|
||||
func (e ErrNoEntries) Error() string {
|
||||
return "no entries"
|
||||
}
|
||||
|
||||
// ErrAlreadyExists is to be returned from the DB interface when an entry already exists for a given query or its constraints.
|
||||
type ErrAlreadyExists struct{}
|
||||
|
||||
func (e ErrAlreadyExists) Error() string {
|
||||
return "already exists"
|
||||
}
|
||||
|
||||
type Where struct {
|
||||
Key string
|
||||
Value interface{}
|
||||
CaseInsensitive bool
|
||||
}
|
||||
|
||||
// DB provides methods for interacting with an underlying database or other storage mechanism (for now, just postgres).
|
||||
// Note that in all of the functions below, the passed interface should be a pointer or a slice, which will then be populated
|
||||
// by whatever is returned from the database.
|
||||
type DB interface {
|
||||
// Federation returns an interface that's compatible with go-fed, for performing federation storage/retrieval functions.
|
||||
// See: https://pkg.go.dev/github.com/go-fed/activity@v1.0.0/pub?utm_source=gopls#Database
|
||||
// Federation() federatingdb.FederatingDB
|
||||
|
||||
/*
|
||||
BASIC DB FUNCTIONALITY
|
||||
*/
|
||||
@ -269,10 +245,6 @@ type DB interface {
|
||||
// StatusBookmarkedBy checks if a given status has been bookmarked by a given account ID
|
||||
StatusBookmarkedBy(status *gtsmodel.Status, accountID string) (bool, error)
|
||||
|
||||
// FaveStatus faves the given status, using accountID as the faver.
|
||||
// The returned fave will be nil if the status was already faved.
|
||||
// FaveStatus(status *gtsmodel.Status, accountID string) (*gtsmodel.StatusFave, error)
|
||||
|
||||
// UnfaveStatus unfaves the given status, using accountID as the unfaver (sure, that's a word).
|
||||
// The returned fave will be nil if the status was already not faved.
|
||||
UnfaveStatus(status *gtsmodel.Status, accountID string) (*gtsmodel.StatusFave, error)
|
||||
@ -285,6 +257,7 @@ type DB interface {
|
||||
// It will use the given filters and try to return as many statuses up to the limit as possible.
|
||||
GetHomeTimelineForAccount(accountID string, maxID string, sinceID string, minID string, limit int, local bool) ([]*gtsmodel.Status, error)
|
||||
|
||||
// GetNotificationsForAccount returns a list of notifications that pertain to the given accountID.
|
||||
GetNotificationsForAccount(accountID string, limit int, maxID string) ([]*gtsmodel.Notification, error)
|
||||
|
||||
/*
|
||||
|
@ -18,20 +18,16 @@
|
||||
|
||||
package db
|
||||
|
||||
import (
|
||||
"context"
|
||||
// ErrNoEntries is to be returned from the DB interface when no entries are found for a given query.
|
||||
type ErrNoEntries struct{}
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/action"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/config"
|
||||
)
|
||||
|
||||
// Initialize will initialize the database given in the config for use with GoToSocial
|
||||
var Initialize action.GTSAction = func(ctx context.Context, c *config.Config, log *logrus.Logger) error {
|
||||
// db, err := New(ctx, c, log)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
return nil
|
||||
// return db.CreateSchema(ctx)
|
||||
func (e ErrNoEntries) Error() string {
|
||||
return "no entries"
|
||||
}
|
||||
|
||||
// ErrAlreadyExists is to be returned from the DB interface when an entry already exists for a given query or its constraints.
|
||||
type ErrAlreadyExists struct{}
|
||||
|
||||
func (e ErrAlreadyExists) Error() string {
|
||||
return "already exists"
|
||||
}
|
30
internal/db/params.go
Normal file
30
internal/db/params.go
Normal file
@ -0,0 +1,30 @@
|
||||
/*
|
||||
GoToSocial
|
||||
Copyright (C) 2021 GoToSocial Authors admin@gotosocial.org
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package db
|
||||
|
||||
// Where allows the caller of the DB to specify Where parameters.
|
||||
type Where struct {
|
||||
// The table to search on.
|
||||
Key string
|
||||
// The value that must be set.
|
||||
Value interface{}
|
||||
// Whether the value (if a string) should be case sensitive or not.
|
||||
// Defaults to false.
|
||||
CaseInsensitive bool
|
||||
}
|
Reference in New Issue
Block a user