diff --git a/internal/api/client/emoji/emojisget.go b/internal/api/client/emoji/emojisget.go index e4efb88..0feb5d9 100644 --- a/internal/api/client/emoji/emojisget.go +++ b/internal/api/client/emoji/emojisget.go @@ -1,8 +1,12 @@ package emoji -import "github.com/gin-gonic/gin" +import ( + "net/http" + + "github.com/gin-gonic/gin" +) // EmojisGETHandler returns a list of custom emojis enabled on the instance func (m *Module) EmojisGETHandler(c *gin.Context) { - + c.JSON(http.StatusOK, []string{}) } diff --git a/internal/api/client/filter/filtersget.go b/internal/api/client/filter/filtersget.go index ad9783e..079d39f 100644 --- a/internal/api/client/filter/filtersget.go +++ b/internal/api/client/filter/filtersget.go @@ -1,8 +1,12 @@ package filter -import "github.com/gin-gonic/gin" +import ( + "net/http" + + "github.com/gin-gonic/gin" +) // FiltersGETHandler returns a list of filters set by/for the authed account func (m *Module) FiltersGETHandler(c *gin.Context) { - + c.JSON(http.StatusOK, []string{}) } diff --git a/internal/api/client/list/listsgets.go b/internal/api/client/list/listsgets.go index fd69545..5d8d7d1 100644 --- a/internal/api/client/list/listsgets.go +++ b/internal/api/client/list/listsgets.go @@ -1,8 +1,12 @@ package list -import "github.com/gin-gonic/gin" +import ( + "net/http" + + "github.com/gin-gonic/gin" +) // ListsGETHandler returns a list of lists created by/for the authed account func (m *Module) ListsGETHandler(c *gin.Context) { - + c.JSON(http.StatusOK, []string{}) } diff --git a/internal/processing/synchronous/status/context.go b/internal/processing/synchronous/status/context.go index f4d62ea..8848315 100644 --- a/internal/processing/synchronous/status/context.go +++ b/internal/processing/synchronous/status/context.go @@ -7,5 +7,8 @@ import ( ) func (p *processor) Context(account *gtsmodel.Account, targetStatusID string) (*apimodel.Context, gtserror.WithCode) { - return &apimodel.Context{}, nil + return &apimodel.Context{ + Ancestors: []apimodel.Status{}, + Descendants: []apimodel.Status{}, + }, nil } diff --git a/internal/timeline/manager.go b/internal/timeline/manager.go index 4ee70d2..80e5caf 100644 --- a/internal/timeline/manager.go +++ b/internal/timeline/manager.go @@ -70,7 +70,9 @@ type Manager interface { // PrepareXFromTop prepares limit n amount of posts, based on their indexed representations, from the top of the index. PrepareXFromTop(timelineAccountID string, limit int) error // WipeStatusFromTimeline completely removes a status and from the index and prepared posts of the given account ID - WipeStatusFromTimeline(timelineAccountID string, statusID string) error + // + // The returned int indicates how many entries were removed. + WipeStatusFromTimeline(timelineAccountID string, statusID string) (int, error) // WipeStatusFromAllTimelines removes the status from the index and prepared posts of all timelines WipeStatusFromAllTimelines(statusID string) error } @@ -120,7 +122,7 @@ func (m *manager) IngestAndPrepare(status *gtsmodel.Status, timelineAccountID st return t.IndexAndPrepareOne(status.CreatedAt, status.ID) } -func (m *manager) Remove(statusID string, timelineAccountID string) error { +func (m *manager) Remove(statusID string, timelineAccountID string) (int, error) { l := m.log.WithFields(logrus.Fields{ "func": "Remove", "timelineAccountID": timelineAccountID, @@ -181,23 +183,21 @@ func (m *manager) PrepareXFromTop(timelineAccountID string, limit int) error { return t.PrepareXFromTop(limit) } -func (m *manager) WipeStatusFromTimeline(timelineAccountID string, statusID string) error { +func (m *manager) WipeStatusFromTimeline(timelineAccountID string, statusID string) (int, error) { t := m.getOrCreateTimeline(timelineAccountID) return t.Remove(statusID) } func (m *manager) WipeStatusFromAllTimelines(statusID string) error { - errors := []string{} - m.accountTimelines.Range(func(k interface{}, i interface{}) bool { t, ok := i.(Timeline) if !ok { panic("couldn't parse entry as Timeline, this should never happen so panic") } - if err := t.Remove(statusID); err != nil { + if _, err := t.Remove(statusID); err != nil { errors = append(errors, err.Error()) } diff --git a/internal/timeline/timeline.go b/internal/timeline/timeline.go index 7c6e319..a662632 100644 --- a/internal/timeline/timeline.go +++ b/internal/timeline/timeline.go @@ -65,8 +65,12 @@ type Timeline interface { // IndexOne puts a status into the timeline at the appropriate place according to its 'createdAt' property. IndexOne(statusCreatedAt time.Time, statusID string) error - // Remove removes a status from the timeline. - Remove(statusID string) error + // Remove removes a status from both the index and prepared posts. + // + // If a status has multiple entries in a timeline, they will all be removed. + // + // The returned int indicates the amount of entries that were removed. + Remove(statusID string) (int, error) // 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. OldestIndexedPostID() (string, error) @@ -283,7 +287,7 @@ func (t *timeline) GetXBeforeID(amount int, beforeID string) ([]*apimodel.Status // iterate through the modified list until we hit the fromID again var served int -servloop: +serveloop: for e := t.preparedPosts.data.Front(); e != nil; e = e.Next() { entry, ok := e.Value.(*preparedPostsEntry) if !ok { @@ -292,7 +296,7 @@ servloop: if entry.statusID == beforeID { // we're good - break servloop + break serveloop } // serve up to the amount requested @@ -314,6 +318,8 @@ func (t *timeline) GetXBetweenID(amount int, maxID string, sinceID string) ([]*a if t.preparedPosts.data == nil { t.preparedPosts.data = &list.List{} } + + return statuses, nil } func (t *timeline) IndexOne(statusCreatedAt time.Time, statusID string) error { @@ -348,39 +354,48 @@ func (t *timeline) IndexAndPrepareOne(statusCreatedAt time.Time, statusID string return nil } -func (t *timeline) Remove(statusID string) error { +func (t *timeline) Remove(statusID string) (int, error) { t.Lock() defer t.Unlock() + var removed int + // remove entr(ies) from the post index + removeIndexes := []*list.Element{} if t.postIndex != nil && t.postIndex.data != nil { - // remove the entry from the post index for e := t.postIndex.data.Front(); e != nil; e = e.Next() { entry, ok := e.Value.(*postIndexEntry) if !ok { - return errors.New("Remove: could not parse e as a postIndexEntry") + return removed, errors.New("Remove: could not parse e as a postIndexEntry") } if entry.statusID == statusID { - t.postIndex.data.Remove(e) - break // bail once we found and removed it + removeIndexes = append(removeIndexes, e) } } } + for _, e := range removeIndexes { + t.postIndex.data.Remove(e) + removed = removed + 1 + } - // remove the entry from prepared posts + // remove entr(ies) from prepared posts + removePrepared := []*list.Element{} if t.preparedPosts != nil && t.preparedPosts.data != nil { for e := t.preparedPosts.data.Front(); e != nil; e = e.Next() { entry, ok := e.Value.(*preparedPostsEntry) if !ok { - return errors.New("Remove: could not parse e as a preparedPostsEntry") + return removed, errors.New("Remove: could not parse e as a preparedPostsEntry") } if entry.statusID == statusID { - t.preparedPosts.data.Remove(e) - break // bail once we found and removed it + removePrepared = append(removePrepared, e) } } } + for _, e := range removePrepared { + t.preparedPosts.data.Remove(e) + removed = removed + 1 + } - return nil + return removed, nil } func (t *timeline) Reset() error {