Block/unblock (#96)

* remote + local block logic, incl. federation

* improve blocking stuff

* fiddle with display of blocked profiles

* go fmt
This commit is contained in:
Tobi Smethurst 2021-07-11 16:22:21 +02:00 committed by GitHub
commit 846057f0d6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
45 changed files with 1405 additions and 63 deletions

View file

@ -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)