Create empty inbox collections for actors (ref #1322)

This commit is contained in:
Felix Ableitner 2020-12-16 21:07:48 +01:00
parent db0a51de2a
commit 4bf0ec94c8
4 changed files with 58 additions and 2 deletions

View File

@ -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"

View 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))
}

View 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))
}

View 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)),