From 02aa19c1b6144fa359fd7eebca4d2a6e97a0b903 Mon Sep 17 00:00:00 2001 From: bryan newbold Date: Sat, 9 Dec 2023 14:11:51 +0800 Subject: [PATCH] automod: always persist flags (redis or in-process, not mod API) --- automod/event.go | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/automod/event.go b/automod/event.go index 7539243cc..7780ee4a4 100644 --- a/automod/event.go +++ b/automod/event.go @@ -173,11 +173,17 @@ func (e *RepoEvent) PersistAccountActions(ctx context.Context) error { } } + // flags don't require admin auth + needsPurge := false + if len(newFlags) > 0 { + e.Engine.Flags.Add(ctx, e.Account.Identity.DID.String(), newFlags) + needsPurge = true + } + if e.Engine.AdminClient == nil { return nil } - needsPurge := false xrpcc := e.Engine.AdminClient if len(newLabels) > 0 { comment := "automod" @@ -201,10 +207,6 @@ func (e *RepoEvent) PersistAccountActions(ctx context.Context) error { } needsPurge = true } - if len(newFlags) > 0 { - e.Engine.Flags.Add(ctx, e.Account.Identity.DID.String(), newFlags) - needsPurge = true - } for _, mr := range newReports { _, err := comatproto.ModerationCreateReport(ctx, xrpcc, &comatproto.ModerationCreateReport_Input{ ReasonType: &mr.ReasonType, @@ -344,9 +346,16 @@ func (e *RecordEvent) PersistRecordActions(ctx context.Context) error { } } } + + // flags don't require admin auth + if len(newFlags) > 0 { + e.Engine.Flags.Add(ctx, atURI, newFlags) + } + if e.Engine.AdminClient == nil { return nil } + strongRef := comatproto.RepoStrongRef{ Cid: e.CID, Uri: atURI, @@ -371,9 +380,6 @@ func (e *RecordEvent) PersistRecordActions(ctx context.Context) error { return err } } - if len(newFlags) > 0 { - e.Engine.Flags.Add(ctx, atURI, newFlags) - } for _, mr := range newReports { _, err := comatproto.ModerationCreateReport(ctx, xrpcc, &comatproto.ModerationCreateReport_Input{ ReasonType: &mr.ReasonType,