diff --git a/internal/api/model/timeline.go b/internal/api/model/timeline.go index 6949813..52d9208 100644 --- a/internal/api/model/timeline.go +++ b/internal/api/model/timeline.go @@ -1,5 +1,7 @@ package model +// StatusTimelineResponse wraps a slice of statuses, ready to be serialized, along with the Link +// header for the previous and next queries, to be returned to the client. type StatusTimelineResponse struct { Statuses []*Status LinkHeader string diff --git a/internal/api/s2s/webfinger/webfingerget.go b/internal/api/s2s/webfinger/webfingerget.go index ace7c4d..30e0891 100644 --- a/internal/api/s2s/webfinger/webfingerget.go +++ b/internal/api/s2s/webfinger/webfingerget.go @@ -63,7 +63,7 @@ func (m *Module) WebfingerGETRequest(c *gin.Context) { } if domain != m.config.Host { - l.Debug("aborting request because domain %s does not belong to this instance", domain) + l.Debugf("aborting request because domain %s does not belong to this instance", domain) c.JSON(http.StatusBadRequest, gin.H{"error": fmt.Sprintf("domain %s does not belong to this instance", domain)}) return } diff --git a/internal/timeline/get.go b/internal/timeline/get.go index f9da589..867e094 100644 --- a/internal/timeline/get.go +++ b/internal/timeline/get.go @@ -5,10 +5,16 @@ import ( "errors" "fmt" + "github.com/sirupsen/logrus" apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model" ) func (t *timeline) Get(amount int, maxID string, sinceID string, minID string) ([]*apimodel.Status, error) { + l := t.log.WithFields(logrus.Fields{ + "func": "Get", + "accountID": t.accountID, + }) + var statuses []*apimodel.Status var err error @@ -18,7 +24,11 @@ func (t *timeline) Get(amount int, maxID string, sinceID string, minID string) ( // aysnchronously prepare the next predicted query so it's ready when the user asks for it if len(statuses) != 0 { nextMaxID := statuses[len(statuses)-1].ID - go t.prepareNextQuery(amount, nextMaxID, "", "") + go func() { + if err := t.prepareNextQuery(amount, nextMaxID, "", ""); err != nil { + l.Errorf("error preparing next query: %s", err) + } + }() } } @@ -28,7 +38,11 @@ func (t *timeline) Get(amount int, maxID string, sinceID string, minID string) ( // aysnchronously prepare the next predicted query so it's ready when the user asks for it if len(statuses) != 0 { nextMaxID := statuses[len(statuses)-1].ID - go t.prepareNextQuery(amount, nextMaxID, "", "") + go func() { + if err := t.prepareNextQuery(amount, nextMaxID, "", ""); err != nil { + l.Errorf("error preparing next query: %s", err) + } + }() } } diff --git a/internal/timeline/index.go b/internal/timeline/index.go index 9a77961..56f5c14 100644 --- a/internal/timeline/index.go +++ b/internal/timeline/index.go @@ -52,7 +52,6 @@ func (t *timeline) IndexBehind(statusID string, amount int) error { filtered := []*gtsmodel.Status{} offsetStatus := statusID - fmt.Println("\n\n\nENTERING GRABLOOP\n\n\n") grabloop: for len(filtered) < amount { statuses, err := t.db.GetStatusesWhereFollowing(t.accountID, offsetStatus, "", "", amount, false) @@ -78,7 +77,6 @@ grabloop: offsetStatus = s.ID } } - fmt.Println("\n\n\nLEAVING GRABLOOP\n\n\n") for _, s := range filtered { if err := t.IndexOne(s.CreatedAt, s.ID); err != nil { diff --git a/internal/timeline/manager.go b/internal/timeline/manager.go index 50234ff..9d28b50 100644 --- a/internal/timeline/manager.go +++ b/internal/timeline/manager.go @@ -32,7 +32,6 @@ import ( ) const ( - preparedPostsMinLength = 80 desiredPostIndexLength = 400 ) @@ -205,7 +204,7 @@ func (m *manager) getOrCreateTimeline(timelineAccountID string) Timeline { var t Timeline i, ok := m.accountTimelines.Load(timelineAccountID) if !ok { - t = NewTimeline(timelineAccountID, m.db, m.tc) + t = NewTimeline(timelineAccountID, m.db, m.tc, m.log) m.accountTimelines.Store(timelineAccountID, t) } else { t, ok = i.(Timeline) diff --git a/internal/timeline/timeline.go b/internal/timeline/timeline.go index 6ac30e7..7408436 100644 --- a/internal/timeline/timeline.go +++ b/internal/timeline/timeline.go @@ -22,16 +22,13 @@ import ( "sync" "time" + "github.com/sirupsen/logrus" apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model" "github.com/superseriousbusiness/gotosocial/internal/db" "github.com/superseriousbusiness/gotosocial/internal/gtsmodel" "github.com/superseriousbusiness/gotosocial/internal/typeutils" ) -const ( - preparedPostsMaxLength = desiredPostIndexLength -) - // Timeline represents a timeline for one account, and contains indexed and prepared posts. type Timeline interface { /* @@ -113,17 +110,19 @@ type timeline struct { account *gtsmodel.Account db db.DB tc typeutils.TypeConverter + log *logrus.Logger 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, log *logrus.Logger) Timeline { return &timeline{ postIndex: &postIndex{}, preparedPosts: &preparedPosts{}, accountID: accountID, db: db, tc: typeConverter, + log: log, } }