Add Discord outbound posting (#14)

Stacks on #13. Adds discord_post_links and a subscriber that posts roots into a public thread, replies into that thread, and edits the linked Discord message. Unset Discord env leaves the site unchanged.

Reviewed-on: #14
Co-authored-by: codegirl-007 <s.raide@gmail.com>
This commit was merged in pull request #14.
This commit is contained in:
2026-08-29 18:24:28 +00:00
committed by codegirl007
parent b8f1d88d6e
commit 5aabc784de
16 changed files with 1037 additions and 2 deletions
+20
View File
@@ -139,6 +139,25 @@ CREATE TABLE IF NOT EXISTS post_images (
return nil
}
func migrateDiscordPostLinks(ctx context.Context, exec execContext) error {
if _, err := exec.ExecContext(ctx, `
CREATE TABLE IF NOT EXISTS discord_post_links (
post_id TEXT PRIMARY KEY REFERENCES posts(id) ON DELETE CASCADE,
discord_message_id TEXT NOT NULL UNIQUE,
discord_thread_id TEXT NOT NULL DEFAULT '',
created_at TEXT NOT NULL
)`); err != nil {
return fmt.Errorf("create discord_post_links: %w", err)
}
if _, err := exec.ExecContext(ctx, `
CREATE UNIQUE INDEX IF NOT EXISTS discord_post_links_thread_uidx
ON discord_post_links (discord_thread_id)
WHERE discord_thread_id <> ''`); err != nil {
return fmt.Errorf("discord_post_links_thread_uidx: %w", err)
}
return nil
}
func migratePostDate(ctx context.Context, exec execContext) error {
steps := []struct {
name string
@@ -331,6 +350,7 @@ CREATE TABLE IF NOT EXISTS schema_migrations (
{"008_post_author_index", migratePostAuthorIndex},
{"009_drop_legacy_post_tables", migrateDropLegacyPostTables},
{"010_post_images", migratePostImages},
{"011_discord_post_links", migrateDiscordPostLinks},
}
for _, m := range migrations {
if applied[m.version] {