fix up some little things
This commit is contained in:
parent
86fd23ccd9
commit
d55c5d8f42
@ -1,8 +1,12 @@
|
|||||||
package emoji
|
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
|
// EmojisGETHandler returns a list of custom emojis enabled on the instance
|
||||||
func (m *Module) EmojisGETHandler(c *gin.Context) {
|
func (m *Module) EmojisGETHandler(c *gin.Context) {
|
||||||
|
c.JSON(http.StatusOK, []string{})
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,12 @@
|
|||||||
package filter
|
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
|
// FiltersGETHandler returns a list of filters set by/for the authed account
|
||||||
func (m *Module) FiltersGETHandler(c *gin.Context) {
|
func (m *Module) FiltersGETHandler(c *gin.Context) {
|
||||||
|
c.JSON(http.StatusOK, []string{})
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,12 @@
|
|||||||
package list
|
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
|
// ListsGETHandler returns a list of lists created by/for the authed account
|
||||||
func (m *Module) ListsGETHandler(c *gin.Context) {
|
func (m *Module) ListsGETHandler(c *gin.Context) {
|
||||||
|
c.JSON(http.StatusOK, []string{})
|
||||||
}
|
}
|
||||||
|
@ -7,5 +7,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (p *processor) Context(account *gtsmodel.Account, targetStatusID string) (*apimodel.Context, gtserror.WithCode) {
|
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
|
||||||
}
|
}
|
||||||
|
@ -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 prepares limit n amount of posts, based on their indexed representations, from the top of the index.
|
||||||
PrepareXFromTop(timelineAccountID string, limit int) error
|
PrepareXFromTop(timelineAccountID string, limit int) error
|
||||||
// WipeStatusFromTimeline completely removes a status and from the index and prepared posts of the given account ID
|
// 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 removes the status from the index and prepared posts of all timelines
|
||||||
WipeStatusFromAllTimelines(statusID string) error
|
WipeStatusFromAllTimelines(statusID string) error
|
||||||
}
|
}
|
||||||
@ -120,7 +122,7 @@ func (m *manager) IngestAndPrepare(status *gtsmodel.Status, timelineAccountID st
|
|||||||
return t.IndexAndPrepareOne(status.CreatedAt, status.ID)
|
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{
|
l := m.log.WithFields(logrus.Fields{
|
||||||
"func": "Remove",
|
"func": "Remove",
|
||||||
"timelineAccountID": timelineAccountID,
|
"timelineAccountID": timelineAccountID,
|
||||||
@ -181,23 +183,21 @@ func (m *manager) PrepareXFromTop(timelineAccountID string, limit int) error {
|
|||||||
return t.PrepareXFromTop(limit)
|
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)
|
t := m.getOrCreateTimeline(timelineAccountID)
|
||||||
|
|
||||||
return t.Remove(statusID)
|
return t.Remove(statusID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *manager) WipeStatusFromAllTimelines(statusID string) error {
|
func (m *manager) WipeStatusFromAllTimelines(statusID string) error {
|
||||||
|
|
||||||
errors := []string{}
|
errors := []string{}
|
||||||
|
|
||||||
m.accountTimelines.Range(func(k interface{}, i interface{}) bool {
|
m.accountTimelines.Range(func(k interface{}, i interface{}) bool {
|
||||||
t, ok := i.(Timeline)
|
t, ok := i.(Timeline)
|
||||||
if !ok {
|
if !ok {
|
||||||
panic("couldn't parse entry as Timeline, this should never happen so panic")
|
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())
|
errors = append(errors, err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,8 +65,12 @@ type Timeline interface {
|
|||||||
|
|
||||||
// IndexOne puts a status into the timeline at the appropriate place according to its 'createdAt' property.
|
// IndexOne puts a status into the timeline at the appropriate place according to its 'createdAt' property.
|
||||||
IndexOne(statusCreatedAt time.Time, statusID string) error
|
IndexOne(statusCreatedAt time.Time, statusID string) error
|
||||||
// Remove removes a status from the timeline.
|
// Remove removes a status from both the index and prepared posts.
|
||||||
Remove(statusID string) error
|
//
|
||||||
|
// 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.
|
// 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.
|
// 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)
|
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
|
// iterate through the modified list until we hit the fromID again
|
||||||
var served int
|
var served int
|
||||||
servloop:
|
serveloop:
|
||||||
for e := t.preparedPosts.data.Front(); e != nil; e = e.Next() {
|
for e := t.preparedPosts.data.Front(); e != nil; e = e.Next() {
|
||||||
entry, ok := e.Value.(*preparedPostsEntry)
|
entry, ok := e.Value.(*preparedPostsEntry)
|
||||||
if !ok {
|
if !ok {
|
||||||
@ -292,7 +296,7 @@ servloop:
|
|||||||
|
|
||||||
if entry.statusID == beforeID {
|
if entry.statusID == beforeID {
|
||||||
// we're good
|
// we're good
|
||||||
break servloop
|
break serveloop
|
||||||
}
|
}
|
||||||
|
|
||||||
// serve up to the amount requested
|
// 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 {
|
if t.preparedPosts.data == nil {
|
||||||
t.preparedPosts.data = &list.List{}
|
t.preparedPosts.data = &list.List{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return statuses, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *timeline) IndexOne(statusCreatedAt time.Time, statusID string) error {
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *timeline) Remove(statusID string) error {
|
func (t *timeline) Remove(statusID string) (int, error) {
|
||||||
t.Lock()
|
t.Lock()
|
||||||
defer t.Unlock()
|
defer t.Unlock()
|
||||||
|
var removed int
|
||||||
|
|
||||||
|
// remove entr(ies) from the post index
|
||||||
|
removeIndexes := []*list.Element{}
|
||||||
if t.postIndex != nil && t.postIndex.data != nil {
|
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() {
|
for e := t.postIndex.data.Front(); e != nil; e = e.Next() {
|
||||||
entry, ok := e.Value.(*postIndexEntry)
|
entry, ok := e.Value.(*postIndexEntry)
|
||||||
if !ok {
|
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 {
|
if entry.statusID == statusID {
|
||||||
|
removeIndexes = append(removeIndexes, e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, e := range removeIndexes {
|
||||||
t.postIndex.data.Remove(e)
|
t.postIndex.data.Remove(e)
|
||||||
break // bail once we found and removed it
|
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 {
|
if t.preparedPosts != nil && t.preparedPosts.data != nil {
|
||||||
for e := t.preparedPosts.data.Front(); e != nil; e = e.Next() {
|
for e := t.preparedPosts.data.Front(); e != nil; e = e.Next() {
|
||||||
entry, ok := e.Value.(*preparedPostsEntry)
|
entry, ok := e.Value.(*preparedPostsEntry)
|
||||||
if !ok {
|
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 {
|
if entry.statusID == statusID {
|
||||||
|
removePrepared = append(removePrepared, e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, e := range removePrepared {
|
||||||
t.preparedPosts.data.Remove(e)
|
t.preparedPosts.data.Remove(e)
|
||||||
break // bail once we found and removed it
|
removed = removed + 1
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return removed, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *timeline) Reset() error {
|
func (t *timeline) Reset() error {
|
||||||
|
Loading…
Reference in New Issue
Block a user