Merge pull request 'Create empty inbox collections for actors (ref #1322)' (#151) from actor-inbox into main
Reviewed-on: https://yerbamate.ml/LemmyNet/lemmy/pulls/151
This commit is contained in:
commit
44b72ccbd6
4 changed files with 58 additions and 2 deletions
14
docker/prod/deploy-federation-test.sh
Executable file
14
docker/prod/deploy-federation-test.sh
Executable 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"
|
|
@ -94,3 +94,19 @@ pub async fn get_apub_community_outbox(
|
||||||
.set_total_items(len as u64);
|
.set_total_items(len as u64);
|
||||||
Ok(create_apub_response(&collection))
|
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))
|
||||||
|
}
|
||||||
|
|
|
@ -52,3 +52,19 @@ pub async fn get_apub_user_outbox(
|
||||||
.set_total_items(0_u64);
|
.set_total_items(0_u64);
|
||||||
Ok(create_apub_response(&collection))
|
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))
|
||||||
|
}
|
||||||
|
|
|
@ -3,10 +3,15 @@ use http_signature_normalization_actix::digest::middleware::VerifyDigest;
|
||||||
use lemmy_apub::{
|
use lemmy_apub::{
|
||||||
http::{
|
http::{
|
||||||
comment::get_apub_comment,
|
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,
|
get_activity,
|
||||||
post::get_apub_post,
|
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},
|
inbox::{community_inbox::community_inbox, shared_inbox::shared_inbox, user_inbox::user_inbox},
|
||||||
APUB_JSON_CONTENT_TYPE,
|
APUB_JSON_CONTENT_TYPE,
|
||||||
|
@ -46,8 +51,13 @@ pub fn config(cfg: &mut web::ServiceConfig) {
|
||||||
"/c/{community_name}/outbox",
|
"/c/{community_name}/outbox",
|
||||||
web::get().to(get_apub_community_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}", web::get().to(get_apub_user_http))
|
||||||
.route("/u/{user_name}/outbox", web::get().to(get_apub_user_outbox))
|
.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("/post/{post_id}", web::get().to(get_apub_post))
|
||||||
.route("/comment/{comment_id}", web::get().to(get_apub_comment))
|
.route("/comment/{comment_id}", web::get().to(get_apub_comment))
|
||||||
.route("/activities/{type_}/{id}", web::get().to(get_activity)),
|
.route("/activities/{type_}/{id}", web::get().to(get_activity)),
|
||||||
|
|
Loading…
Reference in a new issue