mirror of
				https://github.com/superseriousbusiness/gotosocial.git
				synced 2025-10-30 19:12:26 -05:00 
			
		
		
		
	tidy + lint
This commit is contained in:
		
					parent
					
						
							
								a25e53af4e
							
						
					
				
			
			
				commit
				
					
						f1eb6476f3
					
				
			
		
					 6 changed files with 24 additions and 12 deletions
				
			
		|  | @ -1,5 +1,7 @@ | ||||||
| package model | 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 { | type StatusTimelineResponse struct { | ||||||
| 	Statuses   []*Status | 	Statuses   []*Status | ||||||
| 	LinkHeader string | 	LinkHeader string | ||||||
|  |  | ||||||
|  | @ -63,7 +63,7 @@ func (m *Module) WebfingerGETRequest(c *gin.Context) { | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	if domain != m.config.Host { | 	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)}) | 		c.JSON(http.StatusBadRequest, gin.H{"error": fmt.Sprintf("domain %s does not belong to this instance", domain)}) | ||||||
| 		return | 		return | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | @ -5,10 +5,16 @@ import ( | ||||||
| 	"errors" | 	"errors" | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 
 | 
 | ||||||
|  | 	"github.com/sirupsen/logrus" | ||||||
| 	apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model" | 	apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| func (t *timeline) Get(amount int, maxID string, sinceID string, minID string) ([]*apimodel.Status, error) { | 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 statuses []*apimodel.Status | ||||||
| 	var err error | 	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 | 		// aysnchronously prepare the next predicted query so it's ready when the user asks for it | ||||||
| 		if len(statuses) != 0 { | 		if len(statuses) != 0 { | ||||||
| 			nextMaxID := statuses[len(statuses)-1].ID | 			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 | 		// aysnchronously prepare the next predicted query so it's ready when the user asks for it | ||||||
| 		if len(statuses) != 0 { | 		if len(statuses) != 0 { | ||||||
| 			nextMaxID := statuses[len(statuses)-1].ID | 			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{} | 	filtered := []*gtsmodel.Status{} | ||||||
| 	offsetStatus := statusID | 	offsetStatus := statusID | ||||||
| 
 | 
 | ||||||
| 	fmt.Println("\n\n\nENTERING GRABLOOP\n\n\n") |  | ||||||
| grabloop: | grabloop: | ||||||
| 	for len(filtered) < amount { | 	for len(filtered) < amount { | ||||||
| 		statuses, err := t.db.GetStatusesWhereFollowing(t.accountID, offsetStatus, "", "", amount, false) | 		statuses, err := t.db.GetStatusesWhereFollowing(t.accountID, offsetStatus, "", "", amount, false) | ||||||
|  | @ -78,7 +77,6 @@ grabloop: | ||||||
| 			offsetStatus = s.ID | 			offsetStatus = s.ID | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	fmt.Println("\n\n\nLEAVING GRABLOOP\n\n\n") |  | ||||||
| 
 | 
 | ||||||
| 	for _, s := range filtered { | 	for _, s := range filtered { | ||||||
| 		if err := t.IndexOne(s.CreatedAt, s.ID); err != nil { | 		if err := t.IndexOne(s.CreatedAt, s.ID); err != nil { | ||||||
|  |  | ||||||
|  | @ -32,7 +32,6 @@ import ( | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| const ( | const ( | ||||||
| 	preparedPostsMinLength = 80 |  | ||||||
| 	desiredPostIndexLength = 400 | 	desiredPostIndexLength = 400 | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
|  | @ -205,7 +204,7 @@ func (m *manager) getOrCreateTimeline(timelineAccountID string) Timeline { | ||||||
| 	var t Timeline | 	var t Timeline | ||||||
| 	i, ok := m.accountTimelines.Load(timelineAccountID) | 	i, ok := m.accountTimelines.Load(timelineAccountID) | ||||||
| 	if !ok { | 	if !ok { | ||||||
| 		t = NewTimeline(timelineAccountID, m.db, m.tc) | 		t = NewTimeline(timelineAccountID, m.db, m.tc, m.log) | ||||||
| 		m.accountTimelines.Store(timelineAccountID, t) | 		m.accountTimelines.Store(timelineAccountID, t) | ||||||
| 	} else { | 	} else { | ||||||
| 		t, ok = i.(Timeline) | 		t, ok = i.(Timeline) | ||||||
|  |  | ||||||
|  | @ -22,16 +22,13 @@ import ( | ||||||
| 	"sync" | 	"sync" | ||||||
| 	"time" | 	"time" | ||||||
| 
 | 
 | ||||||
|  | 	"github.com/sirupsen/logrus" | ||||||
| 	apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model" | 	apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model" | ||||||
| 	"github.com/superseriousbusiness/gotosocial/internal/db" | 	"github.com/superseriousbusiness/gotosocial/internal/db" | ||||||
| 	"github.com/superseriousbusiness/gotosocial/internal/gtsmodel" | 	"github.com/superseriousbusiness/gotosocial/internal/gtsmodel" | ||||||
| 	"github.com/superseriousbusiness/gotosocial/internal/typeutils" | 	"github.com/superseriousbusiness/gotosocial/internal/typeutils" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| const ( |  | ||||||
| 	preparedPostsMaxLength = desiredPostIndexLength |  | ||||||
| ) |  | ||||||
| 
 |  | ||||||
| // Timeline represents a timeline for one account, and contains indexed and prepared posts. | // Timeline represents a timeline for one account, and contains indexed and prepared posts. | ||||||
| type Timeline interface { | type Timeline interface { | ||||||
| 	/* | 	/* | ||||||
|  | @ -113,17 +110,19 @@ type timeline struct { | ||||||
| 	account       *gtsmodel.Account | 	account       *gtsmodel.Account | ||||||
| 	db            db.DB | 	db            db.DB | ||||||
| 	tc            typeutils.TypeConverter | 	tc            typeutils.TypeConverter | ||||||
|  | 	log           *logrus.Logger | ||||||
| 	sync.Mutex | 	sync.Mutex | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // NewTimeline returns a new Timeline for the given account ID | // 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{ | 	return &timeline{ | ||||||
| 		postIndex:     &postIndex{}, | 		postIndex:     &postIndex{}, | ||||||
| 		preparedPosts: &preparedPosts{}, | 		preparedPosts: &preparedPosts{}, | ||||||
| 		accountID:     accountID, | 		accountID:     accountID, | ||||||
| 		db:            db, | 		db:            db, | ||||||
| 		tc:            typeConverter, | 		tc:            typeConverter, | ||||||
|  | 		log:           log, | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue