Skip to content

Commit

Permalink
preserve local outbox
Browse files Browse the repository at this point in the history
  • Loading branch information
dimkr committed Dec 28, 2023
1 parent 0f4e693 commit a2d4cae
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion data/garbage.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func CollectGarbage(ctx context.Context, db *sql.DB) error {
return fmt.Errorf("failed to remove old hashtags: %w", err)
}

if _, err := db.ExecContext(ctx, `delete from outbox where inserted < ?`, now.Add(-deliveryTTL).Unix()); err != nil {
if _, err := db.ExecContext(ctx, `delete from outbox where inserted < ? and host != ?`, now.Add(-deliveryTTL).Unix(), cfg.Domain); err != nil {
return fmt.Errorf("failed to remove old posts: %w", err)
}

Expand Down
15 changes: 15 additions & 0 deletions migrations/017_outboxhost.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package migrations

import (
"context"
"database/sql"
)

func outboxhost(ctx context.Context, tx *sql.Tx) error {
if _, err := tx.ExecContext(ctx, `ALTER TABLE outbox ADD COLUMN host TEXT AS (substr(substr(activity->>'id', 9), 0, instr(substr(activity->>'id', 9), '/')))`); err != nil {
return err
}

_, err := tx.ExecContext(ctx, `CREATE INDEX outboxhostinserted ON outbox(host, inserted)`)
return err
}

0 comments on commit a2d4cae

Please sign in to comment.