]> Untitled Git - lemmy.git/commitdiff
Create empty inbox collections for actors (ref #1322)
authorFelix Ableitner <me@nutomic.com>
Wed, 16 Dec 2020 20:07:48 +0000 (21:07 +0100)
committerFelix Ableitner <me@nutomic.com>
Thu, 17 Dec 2020 13:22:51 +0000 (14:22 +0100)
docker/prod/deploy-federation-test.sh [new file with mode: 0755]
lemmy_apub/src/http/community.rs
lemmy_apub/src/http/user.rs
src/routes/federation.rs

diff --git a/docker/prod/deploy-federation-test.sh b/docker/prod/deploy-federation-test.sh
new file mode 100755 (executable)
index 0000000..e9d9aef
--- /dev/null
@@ -0,0 +1,14 @@
+#!/bin/bash
+set -e
+
+TAG="federation-test"
+
+sudo docker build ../../ --file Dockerfile -t "dessalines/lemmy:$TAG"
+sudo docker save "dessalines/lemmy:$TAG" -o "$TAG.tar"
+sudo chown "$(id -u):$(id -g)" "$TAG.tar"
+
+scp "$TAG.tar" enterprise.lemmy.ml:
+rm "$TAG.tar"
+ssh lemmy-test "cat $TAG.tar | docker load"
+ssh lemmy-test "rm $TAG.tar"
+ssh lemmy-test "cd /lemmy/enterprise.lemmy.ml && docker-compose up -d"
\ No newline at end of file
index 0a90571ff0287bfbb00b8eceb5cd2e60875b2f15..eb23a7edd655d161eb8d4540bd6d4442d5d38ef3 100644 (file)
@@ -94,3 +94,19 @@ pub async fn get_apub_community_outbox(
     .set_total_items(len as u64);
   Ok(create_apub_response(&collection))
 }
+
+pub async fn get_apub_community_inbox(
+  info: web::Path<CommunityQuery>,
+  context: web::Data<LemmyContext>,
+) -> Result<HttpResponse<Body>, LemmyError> {
+  let community = blocking(context.pool(), move |conn| {
+    Community::read_from_name(&conn, &info.community_name)
+  })
+  .await??;
+
+  let mut collection = OrderedCollection::new();
+  collection
+    .set_id(format!("{}/inbox", community.actor_id).parse()?)
+    .set_many_contexts(lemmy_context()?);
+  Ok(create_apub_response(&collection))
+}
index 1e546d953dd47026116b00b29c22f97b57a98ea5..5acdd28d3a2e3708845eef209c51e8d9a667c38a 100644 (file)
@@ -52,3 +52,19 @@ pub async fn get_apub_user_outbox(
     .set_total_items(0_u64);
   Ok(create_apub_response(&collection))
 }
+
+pub async fn get_apub_user_inbox(
+  info: web::Path<UserQuery>,
+  context: web::Data<LemmyContext>,
+) -> Result<HttpResponse<Body>, LemmyError> {
+  let user = blocking(context.pool(), move |conn| {
+    User_::read_from_name(&conn, &info.user_name)
+  })
+  .await??;
+
+  let mut collection = OrderedCollection::new();
+  collection
+    .set_id(format!("{}/inbox", user.actor_id).parse()?)
+    .set_many_contexts(lemmy_context()?);
+  Ok(create_apub_response(&collection))
+}
index 4d03de770231b3100c79fa2a7a54f6b1210cd716..2cad8bc08b578838c2051e0572d09957fba8c3ec 100644 (file)
@@ -3,10 +3,15 @@ use http_signature_normalization_actix::digest::middleware::VerifyDigest;
 use lemmy_apub::{
   http::{
     comment::get_apub_comment,
-    community::{get_apub_community_followers, get_apub_community_http, get_apub_community_outbox},
+    community::{
+      get_apub_community_followers,
+      get_apub_community_http,
+      get_apub_community_inbox,
+      get_apub_community_outbox,
+    },
     get_activity,
     post::get_apub_post,
-    user::{get_apub_user_http, get_apub_user_outbox},
+    user::{get_apub_user_http, get_apub_user_inbox, get_apub_user_outbox},
   },
   inbox::{community_inbox::community_inbox, shared_inbox::shared_inbox, user_inbox::user_inbox},
   APUB_JSON_CONTENT_TYPE,
@@ -41,8 +46,13 @@ pub fn config(cfg: &mut web::ServiceConfig) {
             "/c/{community_name}/outbox",
             web::get().to(get_apub_community_outbox),
           )
+          .route(
+            "/c/{community_name}/inbox",
+            web::get().to(get_apub_community_inbox),
+          )
           .route("/u/{user_name}", web::get().to(get_apub_user_http))
           .route("/u/{user_name}/outbox", web::get().to(get_apub_user_outbox))
+          .route("/u/{user_name}/inbox", web::get().to(get_apub_user_inbox))
           .route("/post/{post_id}", web::get().to(get_apub_post))
           .route("/comment/{comment_id}", web::get().to(get_apub_comment))
           .route("/activities/{type_}/{id}", web::get().to(get_activity)),