Skip to content

Commit

Permalink
automod: fix label creation/action
Browse files Browse the repository at this point in the history
  • Loading branch information
bnewbold committed Nov 15, 2023
1 parent 0ad1010 commit cc7e4ba
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
6 changes: 6 additions & 0 deletions automod/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ func (e *Engine) ProcessRecord(ctx context.Context, did syntax.DID, path, recCID
if err := evt.PersistAccountActions(ctx); err != nil {
return err
}
if err := evt.PersistRecordActions(ctx); err != nil {
return err
}
if err := evt.PersistCounters(ctx); err != nil {
return err
}
Expand All @@ -114,6 +117,9 @@ func (e *Engine) ProcessRecord(ctx context.Context, did syntax.DID, path, recCID
if err := evt.PersistAccountActions(ctx); err != nil {
return err
}
if err := evt.PersistRecordActions(ctx); err != nil {
return err
}
if err := evt.PersistCounters(ctx); err != nil {
return err
}
Expand Down
3 changes: 2 additions & 1 deletion automod/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,9 @@ func (e *RecordEvent) PersistRecordActions(ctx context.Context) error {
}
xrpcc := e.Engine.AdminClient
if len(e.RecordLabels) > 0 {
// TODO: this does an action, not just create labels; will update after event refactor
_, err := comatproto.AdminTakeModerationAction(ctx, xrpcc, &comatproto.AdminTakeModerationAction_Input{
Action: "com.atproto.admin.defs#createLabels",
Action: "com.atproto.admin.defs#flag",
CreateLabelVals: dedupeStrings(e.RecordLabels),
Reason: "automod",
CreatedBy: xrpcc.Auth.Did,
Expand Down
1 change: 1 addition & 0 deletions cmd/hepa/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ func NewServer(dir identity.Directory, config Config) (*Server, error) {
Client: util.RobustHTTPClient(),
Host: config.ModHost,
AdminToken: &config.ModAdminToken,
Auth: &xrpc.AuthInfo{},
}

auth, err := comatproto.ServerCreateSession(context.TODO(), xrpcc, &comatproto.ServerCreateSession_Input{
Expand Down

0 comments on commit cc7e4ba

Please sign in to comment.