mirror of
https://github.com/LemmyNet/lemmy
synced 2024-11-26 22:40:21 +00:00
Create empty outbox for user (ref #1220)
This commit is contained in:
parent
f0e3303aeb
commit
48f506277a
3 changed files with 32 additions and 7 deletions
|
@ -1,10 +1,15 @@
|
||||||
use crate::{http::create_apub_response, ToApub};
|
use crate::{http::create_apub_response, ActorType, ToApub};
|
||||||
|
use activitystreams::{
|
||||||
|
base::BaseExt,
|
||||||
|
collection::{CollectionExt, OrderedCollection},
|
||||||
|
};
|
||||||
use actix_web::{body::Body, web, HttpResponse};
|
use actix_web::{body::Body, web, HttpResponse};
|
||||||
use lemmy_db::user::User_;
|
use lemmy_db::user::User_;
|
||||||
use lemmy_structs::blocking;
|
use lemmy_structs::blocking;
|
||||||
use lemmy_utils::LemmyError;
|
use lemmy_utils::LemmyError;
|
||||||
use lemmy_websocket::LemmyContext;
|
use lemmy_websocket::LemmyContext;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
use url::Url;
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
pub struct UserQuery {
|
pub struct UserQuery {
|
||||||
|
@ -24,3 +29,20 @@ pub async fn get_apub_user_http(
|
||||||
let u = user.to_apub(context.pool()).await?;
|
let u = user.to_apub(context.pool()).await?;
|
||||||
Ok(create_apub_response(&u))
|
Ok(create_apub_response(&u))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn get_apub_user_outbox(
|
||||||
|
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_many_items(Vec::<Url>::new())
|
||||||
|
.set_context(activitystreams::context())
|
||||||
|
.set_id(user.get_outbox_url()?)
|
||||||
|
.set_total_items(0_u64);
|
||||||
|
Ok(create_apub_response(&collection))
|
||||||
|
}
|
||||||
|
|
|
@ -55,11 +55,13 @@ impl ToApub for User_ {
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut ap_actor = ApActor::new(self.get_inbox_url()?, person);
|
let mut ap_actor = ApActor::new(self.get_inbox_url()?, person);
|
||||||
ap_actor.set_preferred_username(self.name.to_owned());
|
ap_actor
|
||||||
ap_actor.set_endpoints(Endpoints {
|
.set_preferred_username(self.name.to_owned())
|
||||||
shared_inbox: Some(self.get_shared_inbox_url()?),
|
.set_outbox(self.get_outbox_url()?)
|
||||||
..Default::default()
|
.set_endpoints(Endpoints {
|
||||||
});
|
shared_inbox: Some(self.get_shared_inbox_url()?),
|
||||||
|
..Default::default()
|
||||||
|
});
|
||||||
|
|
||||||
Ok(Ext1::new(ap_actor, self.get_public_key_ext()?))
|
Ok(Ext1::new(ap_actor, self.get_public_key_ext()?))
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ use lemmy_apub::{
|
||||||
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_outbox},
|
||||||
get_activity,
|
get_activity,
|
||||||
post::get_apub_post,
|
post::get_apub_post,
|
||||||
user::get_apub_user_http,
|
user::{get_apub_user_http, 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,
|
||||||
|
@ -42,6 +42,7 @@ pub fn config(cfg: &mut web::ServiceConfig) {
|
||||||
web::get().to(get_apub_community_outbox),
|
web::get().to(get_apub_community_outbox),
|
||||||
)
|
)
|
||||||
.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("/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