lint and fmt
This commit is contained in:
parent
ab7db633d0
commit
31a24167fe
@ -25,7 +25,6 @@ import (
|
|||||||
"github.com/superseriousbusiness/gotosocial/internal/api/client/search"
|
"github.com/superseriousbusiness/gotosocial/internal/api/client/search"
|
||||||
"github.com/superseriousbusiness/gotosocial/internal/api/client/status"
|
"github.com/superseriousbusiness/gotosocial/internal/api/client/status"
|
||||||
"github.com/superseriousbusiness/gotosocial/internal/api/client/timeline"
|
"github.com/superseriousbusiness/gotosocial/internal/api/client/timeline"
|
||||||
timelineprocessing "github.com/superseriousbusiness/gotosocial/internal/processing/timeline"
|
|
||||||
"github.com/superseriousbusiness/gotosocial/internal/api/s2s/user"
|
"github.com/superseriousbusiness/gotosocial/internal/api/s2s/user"
|
||||||
"github.com/superseriousbusiness/gotosocial/internal/api/s2s/webfinger"
|
"github.com/superseriousbusiness/gotosocial/internal/api/s2s/webfinger"
|
||||||
"github.com/superseriousbusiness/gotosocial/internal/api/security"
|
"github.com/superseriousbusiness/gotosocial/internal/api/security"
|
||||||
@ -40,6 +39,7 @@ import (
|
|||||||
"github.com/superseriousbusiness/gotosocial/internal/media"
|
"github.com/superseriousbusiness/gotosocial/internal/media"
|
||||||
"github.com/superseriousbusiness/gotosocial/internal/oauth"
|
"github.com/superseriousbusiness/gotosocial/internal/oauth"
|
||||||
"github.com/superseriousbusiness/gotosocial/internal/processing"
|
"github.com/superseriousbusiness/gotosocial/internal/processing"
|
||||||
|
timelineprocessing "github.com/superseriousbusiness/gotosocial/internal/processing/timeline"
|
||||||
"github.com/superseriousbusiness/gotosocial/internal/router"
|
"github.com/superseriousbusiness/gotosocial/internal/router"
|
||||||
"github.com/superseriousbusiness/gotosocial/internal/transport"
|
"github.com/superseriousbusiness/gotosocial/internal/transport"
|
||||||
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
|
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
|
||||||
|
@ -137,8 +137,6 @@ type Processor interface {
|
|||||||
// PublicTimelineGet returns statuses from the public/local timeline, with the given filters/parameters.
|
// PublicTimelineGet returns statuses from the public/local timeline, with the given filters/parameters.
|
||||||
PublicTimelineGet(authed *oauth.Auth, maxID string, sinceID string, minID string, limit int, local bool) ([]*apimodel.Status, ErrorWithCode)
|
PublicTimelineGet(authed *oauth.Auth, maxID string, sinceID string, minID string, limit int, local bool) ([]*apimodel.Status, ErrorWithCode)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
FEDERATION API-FACING PROCESSING FUNCTIONS
|
FEDERATION API-FACING PROCESSING FUNCTIONS
|
||||||
These functions are intended to be called when the federating client needs an immediate (ie., synchronous) reply
|
These functions are intended to be called when the federating client needs an immediate (ie., synchronous) reply
|
||||||
|
@ -35,40 +35,61 @@ const (
|
|||||||
preparedPostsMaxLength = desiredPostIndexLength
|
preparedPostsMaxLength = desiredPostIndexLength
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Timeline represents a timeline for one account, and contains indexed and prepared posts.
|
||||||
type Timeline interface {
|
type Timeline interface {
|
||||||
|
/*
|
||||||
|
RETRIEVAL FUNCTIONS
|
||||||
|
*/
|
||||||
|
|
||||||
// GetXFromTop returns x amount of posts from the top of the timeline, from newest to oldest.
|
// GetXFromTop returns x amount of posts from the top of the timeline, from newest to oldest.
|
||||||
GetXFromTop(amount int) ([]*apimodel.Status, error)
|
GetXFromTop(amount int) ([]*apimodel.Status, error)
|
||||||
// GetXFromIDOnwards returns x amount of posts from the given id onwards, from newest to oldest.
|
// GetXFromIDOnwards returns x amount of posts from the given id onwards, from newest to oldest.
|
||||||
// This will include the status with the given ID.
|
// This will include the status with the given ID.
|
||||||
GetXFromIDOnwards(amount int, fromID string) ([]*apimodel.Status, error)
|
GetXFromIDOnwards(amount int, fromID string) ([]*apimodel.Status, error)
|
||||||
|
|
||||||
// GetXBeforeID returns x amount of posts up to the given id, from newest to oldest.
|
// GetXBeforeID returns x amount of posts up to the given id, from newest to oldest.
|
||||||
// This will NOT include the status with the given ID.
|
// This will NOT include the status with the given ID.
|
||||||
GetXBeforeID(amount int, sinceID string) ([]*apimodel.Status, error)
|
GetXBeforeID(amount int, sinceID string) ([]*apimodel.Status, error)
|
||||||
|
|
||||||
|
/*
|
||||||
|
INDEXING FUNCTIONS
|
||||||
|
*/
|
||||||
|
|
||||||
// IndexOne puts a status into the timeline at the appropriate place according to its 'createdAt' property.
|
// IndexOne puts a status into the timeline at the appropriate place according to its 'createdAt' property.
|
||||||
IndexOne(statusCreatedAt time.Time, statusID string) error
|
IndexOne(statusCreatedAt time.Time, statusID string) error
|
||||||
// IndexOne puts a status into the timeline at the appropriate place according to its 'createdAt' property,
|
|
||||||
// and then immediately prepares it.
|
|
||||||
IndexAndPrepareOne(statusCreatedAt time.Time, statusID string) error
|
|
||||||
// Remove removes a status from the timeline.
|
// Remove removes a status from the timeline.
|
||||||
Remove(statusID string) error
|
Remove(statusID string) error
|
||||||
// OldestIndexedPostID returns the id of the rearmost (ie., the oldest) indexed post, or an error if something goes wrong.
|
// OldestIndexedPostID returns the id of the rearmost (ie., the oldest) indexed post, or an error if something goes wrong.
|
||||||
// If nothing goes wrong but there's no oldest post, an empty string will be returned so make sure to check for this.
|
// If nothing goes wrong but there's no oldest post, an empty string will be returned so make sure to check for this.
|
||||||
OldestIndexedPostID() (string, error)
|
OldestIndexedPostID() (string, error)
|
||||||
|
|
||||||
|
/*
|
||||||
|
PREPARATION FUNCTIONS
|
||||||
|
*/
|
||||||
|
|
||||||
// PrepareXFromTop instructs the timeline to prepare x amount of posts from the top of the timeline.
|
// PrepareXFromTop instructs the timeline to prepare x amount of posts from the top of the timeline.
|
||||||
PrepareXFromTop(amount int) error
|
PrepareXFromTop(amount int) error
|
||||||
// PrepareXFromIndex instrucst the timeline to prepare the next amount of entries for serialization, from index onwards.
|
// PrepareXFromIndex instrucst the timeline to prepare the next amount of entries for serialization, from index onwards.
|
||||||
PrepareXFromIndex(amount int, index int) error
|
PrepareXFromIndex(amount int, index int) error
|
||||||
|
// IndexOne puts a status into the timeline at the appropriate place according to its 'createdAt' property,
|
||||||
|
// and then immediately prepares it.
|
||||||
|
IndexAndPrepareOne(statusCreatedAt time.Time, statusID string) error
|
||||||
|
|
||||||
|
/*
|
||||||
|
INFO FUNCTIONS
|
||||||
|
*/
|
||||||
|
|
||||||
// ActualPostIndexLength returns the actual length of the post index at this point in time.
|
// ActualPostIndexLength returns the actual length of the post index at this point in time.
|
||||||
PostIndexLength() int
|
PostIndexLength() int
|
||||||
|
|
||||||
|
/*
|
||||||
|
UTILITY FUNCTIONS
|
||||||
|
*/
|
||||||
|
|
||||||
// Reset instructs the timeline to reset to its base state -- cache only the minimum amount of posts.
|
// Reset instructs the timeline to reset to its base state -- cache only the minimum amount of posts.
|
||||||
Reset() error
|
Reset() error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// timeline fulfils the Timeline interface
|
||||||
type timeline struct {
|
type timeline struct {
|
||||||
postIndex *postIndex
|
postIndex *postIndex
|
||||||
preparedPosts *preparedPosts
|
preparedPosts *preparedPosts
|
||||||
@ -79,6 +100,7 @@ type timeline struct {
|
|||||||
sync.Mutex
|
sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewTimeline returns a new Timeline for the given account ID
|
||||||
func NewTimeline(accountID string, db db.DB, typeConverter typeutils.TypeConverter) Timeline {
|
func NewTimeline(accountID string, db db.DB, typeConverter typeutils.TypeConverter) Timeline {
|
||||||
return &timeline{
|
return &timeline{
|
||||||
postIndex: &postIndex{},
|
postIndex: &postIndex{},
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
"github.com/superseriousbusiness/gotosocial/internal/processing/timeline"
|
"github.com/superseriousbusiness/gotosocial/internal/processing/timeline"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// NewTestTimelineManager retuts a new timeline.Manager, suitable for testing, using the given db.
|
||||||
func NewTestTimelineManager(db db.DB) timeline.Manager {
|
func NewTestTimelineManager(db db.DB) timeline.Manager {
|
||||||
return timeline.NewManager(db, NewTestTypeConverter(db), NewTestConfig(), NewTestLog())
|
return timeline.NewManager(db, NewTestTypeConverter(db), NewTestConfig(), NewTestLog())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user