summaryrefslogtreecommitdiff
path: root/internal/timeline/manager.go
diff options
context:
space:
mode:
authorLibravatar Tobi Smethurst <31960611+tsmethurst@users.noreply.github.com>2021-07-11 16:22:21 +0200
committerLibravatar GitHub <noreply@github.com>2021-07-11 16:22:21 +0200
commit846057f0d696fded87d105dec1245e9ba32763ce (patch)
tree9a4914c07bcf189a3eea0a2c091567c56cdf4963 /internal/timeline/manager.go
parentfavourites GET implementation (#95) (diff)
downloadgotosocial-846057f0d696fded87d105dec1245e9ba32763ce.tar.xz
Block/unblock (#96)
* remote + local block logic, incl. federation * improve blocking stuff * fiddle with display of blocked profiles * go fmt
Diffstat (limited to 'internal/timeline/manager.go')
-rw-r--r--internal/timeline/manager.go16
1 files changed, 14 insertions, 2 deletions
diff --git a/internal/timeline/manager.go b/internal/timeline/manager.go
index d50c9f783..00d87bb26 100644
--- a/internal/timeline/manager.go
+++ b/internal/timeline/manager.go
@@ -78,6 +78,8 @@ type Manager interface {
Remove(statusID string, timelineAccountID string) (int, error)
// WipeStatusFromAllTimelines removes one status from the index and prepared posts of all timelines
WipeStatusFromAllTimelines(statusID string) error
+ // WipeStatusesFromAccountID removes all statuses by the given accountID from the timelineAccountID's timelines.
+ WipeStatusesFromAccountID(accountID string, timelineAccountID string) error
}
// NewManager returns a new timeline manager with the given database, typeconverter, config, and log.
@@ -112,7 +114,7 @@ func (m *manager) Ingest(status *gtsmodel.Status, timelineAccountID string) (boo
}
l.Trace("ingesting status")
- return t.IndexOne(status.CreatedAt, status.ID, status.BoostOfID)
+ return t.IndexOne(status.CreatedAt, status.ID, status.BoostOfID, status.AccountID, status.BoostOfAccountID)
}
func (m *manager) IngestAndPrepare(status *gtsmodel.Status, timelineAccountID string) (bool, error) {
@@ -128,7 +130,7 @@ func (m *manager) IngestAndPrepare(status *gtsmodel.Status, timelineAccountID st
}
l.Trace("ingesting status")
- return t.IndexAndPrepareOne(status.CreatedAt, status.ID)
+ return t.IndexAndPrepareOne(status.CreatedAt, status.ID, status.BoostOfID, status.AccountID, status.BoostOfAccountID)
}
func (m *manager) Remove(statusID string, timelineAccountID string) (int, error) {
@@ -219,6 +221,16 @@ func (m *manager) WipeStatusFromAllTimelines(statusID string) error {
return err
}
+func (m *manager) WipeStatusesFromAccountID(accountID string, timelineAccountID string) error {
+ t, err := m.getOrCreateTimeline(timelineAccountID)
+ if err != nil {
+ return err
+ }
+
+ _, err = t.RemoveAllBy(accountID)
+ return err
+}
+
func (m *manager) getOrCreateTimeline(timelineAccountID string) (Timeline, error) {
var t Timeline
i, ok := m.accountTimelines.Load(timelineAccountID)