tidy + lint
This commit is contained in:
		@ -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
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@ -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)
 | 
			
		||||
				}
 | 
			
		||||
			}()
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -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 {
 | 
			
		||||
 | 
			
		||||
@ -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)
 | 
			
		||||
 | 
			
		||||
@ -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,
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user