improve true remote timeline

This commit is contained in:
localhost_frssoft 2023-11-13 02:54:19 +03:00
parent eedd9d2c5c
commit 0f33427d5b
6 changed files with 160 additions and 23 deletions

View file

@ -117,7 +117,7 @@ func (s *service) NavPage(c *client) (err error) {
}
func (s *service) TimelinePage(c *client, tType, instance, listId, maxID,
minID string, tag string) (err error) {
minID string, tag string, instance_type string) (err error) {
var nextLink, prevLink, title string
var statuses []*mastodon.Status
@ -159,13 +159,17 @@ func (s *service) TimelinePage(c *client, tType, instance, listId, maxID,
title = "Remote Timeline"
case "tremote":
if len(instance) > 0 {
statuses, err = c.TrueRemoteTimeline(c.ctx, instance, &pg)
if instance_type == "" {
instance_type = "mastodon-compatible"
}
statuses, err = c.TrueRemoteTimeline(c.ctx, instance, instance_type, &pg)
if err != nil {
return err
}
v := make(url.Values)
v.Set("max_id", statuses[len(statuses)-1].ID)
v.Set("instance", instance)
v.Set("instance_type", instance_type)
nextLink = "/timeline/" + tType + "?" + v.Encode()
}
title = "True Remote Timeline"
@ -223,6 +227,9 @@ func (s *service) TimelinePage(c *client, tType, instance, listId, maxID,
if len(instance) > 0 {
v.Set("instance", instance)
}
if len(instance_type) > 0 {
v.Set("instance_type", instance_type)
}
if len(tag) > 0 {
v.Set("tag", tag)
}
@ -235,9 +242,13 @@ func (s *service) TimelinePage(c *client, tType, instance, listId, maxID,
if len(minID) > 0 || (len(pg.MaxID) > 0 && len(statuses) == 20) {
v := make(url.Values)
v.Set("max_id", pg.MaxID)
v.Set("max_id", statuses[len(statuses)-1].ID)
if len(instance) > 0 {
v.Set("instance", instance)
}
if len(instance_type) > 0 {
v.Set("instance_type", instance_type)
}
if len(tag) > 0 {
v.Set("tag", tag)
}
@ -252,6 +263,7 @@ func (s *service) TimelinePage(c *client, tType, instance, listId, maxID,
Title: title,
Type: tType,
Instance: instance,
InstanceType: instance_type,
Statuses: statuses,
NextLink: nextLink,
PrevLink: prevLink,

View file

@ -139,7 +139,8 @@ func NewHandler(s *service, verbose bool, staticDir string) http.Handler {
maxID := q.Get("max_id")
minID := q.Get("min_id")
tag := q.Get("tag")
return s.TimelinePage(c, tType, instance, list, maxID, minID, tag)
instance_type := q.Get("instance_type")
return s.TimelinePage(c, tType, instance, list, maxID, minID, tag, instance_type)
}, SESSION, HTML)
defaultTimelinePage := handle(func(c *client) error {