From 552120498bb480c61103f64715fd13dbe280584c Mon Sep 17 00:00:00 2001 From: phiresky Date: Sun, 23 Jul 2023 21:00:16 +0000 Subject: [PATCH] fixes --- Cargo.lock | 3 +-- crates/db_schema/src/schema.rs | 9 +++++-- .../up.sql | 21 --------------- .../down.sql | 2 +- .../up.sql | 26 +++++++++++++++++++ 5 files changed, 35 insertions(+), 26 deletions(-) delete mode 100644 migrations/2023-07-09-115243_persistent-activity-queue/up.sql rename migrations/{2023-07-09-115243_persistent-activity-queue => 2023-08-01-115243_persistent-activity-queue}/down.sql (88%) create mode 100644 migrations/2023-08-01-115243_persistent-activity-queue/up.sql diff --git a/Cargo.lock b/Cargo.lock index fa7041fe3..8fbe09244 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11,8 +11,7 @@ checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" [[package]] name = "activitypub_federation" version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e6e7fefba6602240fcf612931b70640ad1e249dff833551ebc218f1c96a4193" +source = "git+https://github.com/phiresky/activitypub-federation-rust/?branch=raw-sending#7991eab37536067d312d75d4fbf2a769286d4dbe" dependencies = [ "activitystreams-kinds", "actix-web", diff --git a/crates/db_schema/src/schema.rs b/crates/db_schema/src/schema.rs index afda31060..46cfb66b9 100644 --- a/crates/db_schema/src/schema.rs +++ b/crates/db_schema/src/schema.rs @@ -297,7 +297,7 @@ diesel::table! { diesel::table! { federation_queue_state (domain) { domain -> Text, - last_successful_id -> Int4, + last_successful_id -> Int8, fail_count -> Int4, last_retry -> Timestamptz, } @@ -792,12 +792,18 @@ diesel::table! { } diesel::table! { + use diesel::sql_types::*; + use super::sql_types::ActorTypeEnum; + sent_activity (id) { id -> Int8, ap_id -> Text, data -> Json, sensitive -> Bool, published -> Timestamp, + send_targets -> Jsonb, + actor_type -> ActorTypeEnum, + actor_apub_id -> Text, } } @@ -892,7 +898,6 @@ diesel::joinable!(custom_emoji_keyword -> custom_emoji (custom_emoji_id)); diesel::joinable!(email_verification -> local_user (local_user_id)); diesel::joinable!(federation_allowlist -> instance (instance_id)); diesel::joinable!(federation_blocklist -> instance (instance_id)); -diesel::joinable!(federation_queue_state -> activity (last_successful_id)); diesel::joinable!(local_site -> site (site_id)); diesel::joinable!(local_site_rate_limit -> local_site (local_site_id)); diesel::joinable!(local_user -> person (person_id)); diff --git a/migrations/2023-07-09-115243_persistent-activity-queue/up.sql b/migrations/2023-07-09-115243_persistent-activity-queue/up.sql deleted file mode 100644 index 2db45766a..000000000 --- a/migrations/2023-07-09-115243_persistent-activity-queue/up.sql +++ /dev/null @@ -1,21 +0,0 @@ -CREATE TYPE actor_type_enum AS enum( - 'site', - 'community', - 'person' -); - -ALTER TABLE activity - ADD COLUMN send_targets jsonb DEFAULT NULL, - ADD COLUMN actor_type actor_type_enum DEFAULT NULL, - ADD COLUMN actor_apub_id text DEFAULT NULL; - -CREATE TABLE federation_queue_state( - domain text PRIMARY KEY, - last_successful_id integer NOT NULL, - fail_count integer NOT NULL, - last_retry timestamptz NOT NULL -); - --- for incremental fetches of followers -CREATE INDEX idx_community_follower_published ON community_follower(published); - diff --git a/migrations/2023-07-09-115243_persistent-activity-queue/down.sql b/migrations/2023-08-01-115243_persistent-activity-queue/down.sql similarity index 88% rename from migrations/2023-07-09-115243_persistent-activity-queue/down.sql rename to migrations/2023-08-01-115243_persistent-activity-queue/down.sql index b90dd3ab8..ea4ef719b 100644 --- a/migrations/2023-07-09-115243_persistent-activity-queue/down.sql +++ b/migrations/2023-08-01-115243_persistent-activity-queue/down.sql @@ -1,4 +1,4 @@ -ALTER TABLE activity +ALTER TABLE sent_activity DROP COLUMN send_targets, DROP COLUMN actor_apub_id, DROP COLUMN actor_type; diff --git a/migrations/2023-08-01-115243_persistent-activity-queue/up.sql b/migrations/2023-08-01-115243_persistent-activity-queue/up.sql new file mode 100644 index 000000000..54688d6f1 --- /dev/null +++ b/migrations/2023-08-01-115243_persistent-activity-queue/up.sql @@ -0,0 +1,26 @@ +CREATE TYPE actor_type_enum AS enum( + 'site', + 'community', + 'person' +); + +ALTER TABLE sent_activity + ADD COLUMN send_targets jsonb NOT NULL DEFAULT '{"inboxes": [], "community_followers_of": [], "all_instances": false}', + ADD COLUMN actor_type actor_type_enum NOT NULL DEFAULT 'person', + ADD COLUMN actor_apub_id text NOT NULL DEFAULT ''; + +ALTER TABLE sent_activity + ALTER COLUMN send_targets DROP DEFAULT, + ALTER COLUMN actor_type DROP DEFAULT, + ALTER COLUMN actor_apub_id DROP DEFAULT; + +CREATE TABLE federation_queue_state( + domain text PRIMARY KEY, + last_successful_id bigint NOT NULL, + fail_count integer NOT NULL, + last_retry timestamptz NOT NULL +); + +-- for incremental fetches of followers +CREATE INDEX idx_community_follower_published ON community_follower(published); +