use diesel::NotFound;
use lemmy_api_structs::blocking;
use lemmy_db_queries::{source::activity::Activity_, ApubObject, DbPool};
-use lemmy_db_schema::source::{
- activity::Activity,
- comment::Comment,
- community::Community,
- post::Post,
- private_message::PrivateMessage,
- user::User_,
+use lemmy_db_schema::{
+ source::{
+ activity::Activity,
+ comment::Comment,
+ community::Community,
+ post::Post,
+ private_message::PrivateMessage,
+ user::User_,
+ },
+ DbUrl,
};
use lemmy_utils::{location_info, settings::structs::Settings, LemmyError};
use lemmy_websocket::LemmyContext;
pub fn generate_apub_endpoint(
endpoint_type: EndpointType,
name: &str,
-) -> Result<lemmy_db_schema::Url, ParseError> {
+) -> Result<DbUrl, ParseError> {
let point = match endpoint_type {
EndpointType::Community => "c",
EndpointType::User => "u",
)
}
-pub fn generate_followers_url(
- actor_id: &lemmy_db_schema::Url,
-) -> Result<lemmy_db_schema::Url, ParseError> {
+pub fn generate_followers_url(actor_id: &DbUrl) -> Result<DbUrl, ParseError> {
Ok(Url::parse(&format!("{}/followers", actor_id))?.into())
}
-pub fn generate_inbox_url(
- actor_id: &lemmy_db_schema::Url,
-) -> Result<lemmy_db_schema::Url, ParseError> {
+pub fn generate_inbox_url(actor_id: &DbUrl) -> Result<DbUrl, ParseError> {
Ok(Url::parse(&format!("{}/inbox", actor_id))?.into())
}
-pub fn generate_shared_inbox_url(
- actor_id: &lemmy_db_schema::Url,
-) -> Result<lemmy_db_schema::Url, LemmyError> {
+pub fn generate_shared_inbox_url(actor_id: &DbUrl) -> Result<DbUrl, LemmyError> {
let actor_id = actor_id.clone().into_inner();
let url = format!(
"{}://{}{}/inbox",
where
T: Serialize + std::fmt::Debug + Send + 'static,
{
- let ap_id = ap_id.to_string();
+ let ap_id = ap_id.to_owned().into();
blocking(pool, move |conn| {
Activity::insert(conn, ap_id, &activity, local, sensitive)
})
}
pub(crate) enum PostOrComment {
- Comment(Comment),
- Post(Post),
+ Comment(Box<Comment>),
+ Post(Box<Post>),
}
/// Tries to find a post or comment in the local database, without any network requests.
})
.await?;
if let Ok(p) = post {
- return Ok(PostOrComment::Post(p));
+ return Ok(PostOrComment::Post(Box::new(p)));
}
let ap_id = apub_id.clone();
})
.await?;
if let Ok(c) = comment {
- return Ok(PostOrComment::Comment(c));
+ return Ok(PostOrComment::Comment(Box::new(c)));
}
Err(NotFound.into())
let ap_id = apub_id.clone();
if let Ok(pc) = find_post_or_comment_by_id(context, ap_id.to_owned()).await {
return Ok(match pc {
- PostOrComment::Post(p) => Object::Post(p),
- PostOrComment::Comment(c) => Object::Comment(c),
+ PostOrComment::Post(p) => Object::Post(*p),
+ PostOrComment::Comment(c) => Object::Comment(*c),
});
}