diff --git a/Cargo.lock b/Cargo.lock index b363034..c8dfa74 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2017,9 +2017,9 @@ dependencies = [ [[package]] name = "k-ap" -version = "0.3.1" +version = "0.4.0" source = "sparse+https://git.gabrielkaszewski.dev/api/packages/GKaszewski/cargo/" -checksum = "f73de37ac4feab6d7b78e73c60acbb07933c2be58dcbb12e8a34201f66e0480d" +checksum = "ccaa914953bfd45ea206e11826da8f61ce1fbe02f8fe0622880527046ad6ae24" dependencies = [ "activitypub_federation", "anyhow", @@ -4571,7 +4571,7 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" dependencies = [ - "windows-sys 0.48.0", + "windows-sys 0.61.2", ] [[package]] diff --git a/crates/adapters/activitypub/Cargo.toml b/crates/adapters/activitypub/Cargo.toml index bc7e8af..8497b71 100644 --- a/crates/adapters/activitypub/Cargo.toml +++ b/crates/adapters/activitypub/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -k-ap = { version = "0.3.1", registry = "gitea" } +k-ap = { version = "0.4.0", registry = "gitea" } domain = { workspace = true } url = { workspace = true } serde = { workspace = true } diff --git a/crates/adapters/activitypub/src/service.rs b/crates/adapters/activitypub/src/service.rs index 8bc5521..374e2fe 100644 --- a/crates/adapters/activitypub/src/service.rs +++ b/crates/adapters/activitypub/src/service.rs @@ -124,7 +124,7 @@ fn k_ap_actor_to_domain(a: k_ap::RemoteActor) -> DomainRemoteActor { display_name: a.display_name, avatar_url: a.avatar_url, outbox_url: a.outbox_url, - last_fetched_at: chrono::Utc::now(), + last_fetched_at: a.fetched_at.unwrap_or_else(chrono::Utc::now), bio: a.bio, banner_url: a.banner_url, also_known_as: a.also_known_as, diff --git a/crates/adapters/postgres-federation/Cargo.toml b/crates/adapters/postgres-federation/Cargo.toml index cf91c97..179de97 100644 --- a/crates/adapters/postgres-federation/Cargo.toml +++ b/crates/adapters/postgres-federation/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -k-ap = { version = "0.3.1", registry = "gitea" } +k-ap = { version = "0.4.0", registry = "gitea" } sqlx = { workspace = true } uuid = { workspace = true } chrono = { workspace = true } diff --git a/crates/adapters/postgres-federation/src/lib.rs b/crates/adapters/postgres-federation/src/lib.rs index 00e83eb..e4fdca0 100644 --- a/crates/adapters/postgres-federation/src/lib.rs +++ b/crates/adapters/postgres-federation/src/lib.rs @@ -59,6 +59,7 @@ struct RemoteActorRow { followers_url: Option, following_url: Option, also_known_as: Option>, + last_fetched_at: Option>, } fn map_remote_actor(r: RemoteActorRow) -> RemoteActor { @@ -75,6 +76,7 @@ fn map_remote_actor(r: RemoteActorRow) -> RemoteActor { followers_url: r.followers_url, following_url: r.following_url, also_known_as: r.also_known_as.unwrap_or_default(), + fetched_at: r.last_fetched_at, } } @@ -174,7 +176,7 @@ impl FollowRepository for PgFederationRepository { "SELECT f.remote_actor_url AS url, f.status, COALESCE(r.handle,'') AS handle, COALESCE(r.inbox_url,'') AS inbox_url, r.shared_inbox_url, r.display_name, r.avatar_url, r.outbox_url, - r.bio, r.banner_url, r.followers_url, r.following_url, r.also_known_as + r.bio, r.banner_url, r.followers_url, r.following_url, r.also_known_as, r.last_fetched_at FROM federation_followers f LEFT JOIN remote_actors r ON r.url=f.remote_actor_url WHERE f.local_user_id=$1 AND f.status='accepted'", @@ -209,7 +211,7 @@ impl FollowRepository for PgFederationRepository { "SELECT f.remote_actor_url AS url, f.status, COALESCE(r.handle,'') AS handle, COALESCE(r.inbox_url,'') AS inbox_url, r.shared_inbox_url, r.display_name, r.avatar_url, r.outbox_url, - r.bio, r.banner_url, r.followers_url, r.following_url, r.also_known_as + r.bio, r.banner_url, r.followers_url, r.following_url, r.also_known_as, r.last_fetched_at FROM federation_followers f LEFT JOIN remote_actors r ON r.url=f.remote_actor_url WHERE f.local_user_id=$1 AND f.status='accepted' @@ -261,7 +263,7 @@ impl FollowRepository for PgFederationRepository { sqlx::query_as::<_, RemoteActorRow>( "SELECT f.remote_actor_url AS url, COALESCE(r.handle,'') AS handle, COALESCE(r.inbox_url,'') AS inbox_url, r.shared_inbox_url, r.display_name, r.avatar_url, r.outbox_url, - r.bio, r.banner_url, r.followers_url, r.following_url, r.also_known_as + r.bio, r.banner_url, r.followers_url, r.following_url, r.also_known_as, r.last_fetched_at FROM federation_followers f LEFT JOIN remote_actors r ON r.url=f.remote_actor_url WHERE f.local_user_id=$1 AND f.status='accepted' @@ -305,7 +307,7 @@ impl FollowRepository for PgFederationRepository { sqlx::query_as::<_, RemoteActorRow>( "SELECT f.remote_actor_url AS url, COALESCE(r.handle,'') AS handle, COALESCE(r.inbox_url,'') AS inbox_url, r.shared_inbox_url, r.display_name, r.avatar_url, r.outbox_url, - r.bio, r.banner_url, r.followers_url, r.following_url, r.also_known_as + r.bio, r.banner_url, r.followers_url, r.following_url, r.also_known_as, r.last_fetched_at FROM federation_followers f LEFT JOIN remote_actors r ON r.url=f.remote_actor_url WHERE f.local_user_id=$1 AND f.status='pending'", @@ -389,7 +391,7 @@ impl FollowRepository for PgFederationRepository { sqlx::query_as::<_, RemoteActorRow>( "SELECT f.remote_actor_url AS url, COALESCE(r.handle,'') AS handle, COALESCE(r.inbox_url,'') AS inbox_url, r.shared_inbox_url, r.display_name, r.avatar_url, r.outbox_url, - r.bio, r.banner_url, r.followers_url, r.following_url, r.also_known_as + r.bio, r.banner_url, r.followers_url, r.following_url, r.also_known_as, r.last_fetched_at FROM federation_following f LEFT JOIN remote_actors r ON r.url=f.remote_actor_url WHERE f.local_user_id=$1", @@ -410,7 +412,7 @@ impl FollowRepository for PgFederationRepository { sqlx::query_as::<_, RemoteActorRow>( "SELECT f.remote_actor_url AS url, COALESCE(r.handle,'') AS handle, COALESCE(r.inbox_url,'') AS inbox_url, r.shared_inbox_url, r.display_name, r.avatar_url, r.outbox_url, - r.bio, r.banner_url, r.followers_url, r.following_url, r.also_known_as + r.bio, r.banner_url, r.followers_url, r.following_url, r.also_known_as, r.last_fetched_at FROM federation_following f LEFT JOIN remote_actors r ON r.url=f.remote_actor_url WHERE f.local_user_id=$1 @@ -585,7 +587,7 @@ impl ActorRepository for PgFederationRepository { async fn get_remote_actor(&self, actor_url: &str) -> Result> { sqlx::query_as::<_, RemoteActorRow>( "SELECT url, handle, inbox_url, shared_inbox_url, display_name, avatar_url, outbox_url, - bio, banner_url, followers_url, following_url, also_known_as + bio, banner_url, followers_url, following_url, also_known_as, last_fetched_at FROM remote_actors WHERE url=$1", ) .bind(actor_url) diff --git a/crates/bootstrap/Cargo.toml b/crates/bootstrap/Cargo.toml index cd30859..963a3f7 100644 --- a/crates/bootstrap/Cargo.toml +++ b/crates/bootstrap/Cargo.toml @@ -14,7 +14,7 @@ postgres = { workspace = true } postgres-search = { workspace = true } postgres-federation = { workspace = true } activitypub = { workspace = true } -k-ap = { version = "0.3.1", registry = "gitea" } +k-ap = { version = "0.4.0", registry = "gitea" } serde_json = { workspace = true } anyhow = { workspace = true } nats = { workspace = true } diff --git a/crates/worker/Cargo.toml b/crates/worker/Cargo.toml index 155b755..4cfd9b1 100644 --- a/crates/worker/Cargo.toml +++ b/crates/worker/Cargo.toml @@ -13,7 +13,7 @@ application = { workspace = true } nats = { workspace = true } event-transport = { workspace = true } event-payload = { workspace = true } -k-ap = { version = "0.3.1", registry = "gitea" } +k-ap = { version = "0.4.0", registry = "gitea" } activitypub = { workspace = true } postgres = { workspace = true } postgres-federation = { workspace = true }