mirror of https://github.com/LemmyNet/lemmy.git
Merge pull request 'Remove code for apub compatibility with Lemmy v0.8.9 and older' (#178) from remove-apub-compat-code into main
Reviewed-on: https://yerbamate.ml/LemmyNet/lemmy/pulls/178pull/1465/head
commit
da5b27ecc6
|
@ -115,7 +115,10 @@ pub(in crate::inbox) async fn receive_like_for_community(
|
|||
verify_activity_domains_valid(&like, &expected_domain, false)?;
|
||||
is_addressed_to_public(&like)?;
|
||||
|
||||
let object_id = get_like_object_id(&like)?;
|
||||
let object_id = like
|
||||
.object()
|
||||
.as_single_xsd_any_uri()
|
||||
.context(location_info!())?;
|
||||
match fetch_post_or_comment_by_id(&object_id, context, request_counter).await? {
|
||||
PostOrComment::Post(post) => receive_like_post(like, post, context, request_counter).await,
|
||||
PostOrComment::Comment(comment) => {
|
||||
|
@ -143,7 +146,10 @@ pub(in crate::inbox) async fn receive_dislike_for_community(
|
|||
verify_activity_domains_valid(&dislike, &expected_domain, false)?;
|
||||
is_addressed_to_public(&dislike)?;
|
||||
|
||||
let object_id = get_like_object_id(&dislike)?;
|
||||
let object_id = dislike
|
||||
.object()
|
||||
.as_single_xsd_any_uri()
|
||||
.context(location_info!())?;
|
||||
match fetch_post_or_comment_by_id(&object_id, context, request_counter).await? {
|
||||
PostOrComment::Post(post) => {
|
||||
receive_dislike_post(dislike, post, context, request_counter).await
|
||||
|
@ -313,7 +319,10 @@ pub(in crate::inbox) async fn receive_undo_like_for_community(
|
|||
verify_activity_domains_valid(&like, &expected_domain, false)?;
|
||||
is_addressed_to_public(&like)?;
|
||||
|
||||
let object_id = get_like_object_id(&like)?;
|
||||
let object_id = like
|
||||
.object()
|
||||
.as_single_xsd_any_uri()
|
||||
.context(location_info!())?;
|
||||
match fetch_post_or_comment_by_id(&object_id, context, request_counter).await? {
|
||||
PostOrComment::Post(post) => {
|
||||
receive_undo_like_post(&like, post, context, request_counter).await
|
||||
|
@ -336,7 +345,10 @@ pub(in crate::inbox) async fn receive_undo_dislike_for_community(
|
|||
verify_activity_domains_valid(&dislike, &expected_domain, false)?;
|
||||
is_addressed_to_public(&dislike)?;
|
||||
|
||||
let object_id = get_like_object_id(&dislike)?;
|
||||
let object_id = dislike
|
||||
.object()
|
||||
.as_single_xsd_any_uri()
|
||||
.context(location_info!())?;
|
||||
match fetch_post_or_comment_by_id(&object_id, context, request_counter).await? {
|
||||
PostOrComment::Post(post) => {
|
||||
receive_undo_dislike_post(&dislike, post, context, request_counter).await
|
||||
|
@ -362,26 +374,3 @@ async fn fetch_post_or_comment_by_id(
|
|||
|
||||
Err(NotFound.into())
|
||||
}
|
||||
|
||||
fn get_like_object_id<Activity>(like_or_dislike: &Activity) -> Result<Url, LemmyError>
|
||||
where
|
||||
Activity: ActorAndObjectRefExt,
|
||||
{
|
||||
// TODO: For backwards compatibility with older Lemmy versions where like.object contains a full
|
||||
// post/comment. This can be removed after some time, using
|
||||
// `activity.oject().as_single_xsd_any_uri()` instead.
|
||||
let object = like_or_dislike.object();
|
||||
if let Some(xsd_uri) = object.as_single_xsd_any_uri() {
|
||||
Ok(xsd_uri.to_owned())
|
||||
} else {
|
||||
Ok(
|
||||
object
|
||||
.to_owned()
|
||||
.one()
|
||||
.context(location_info!())?
|
||||
.id()
|
||||
.context(location_info!())?
|
||||
.to_owned(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,9 +31,7 @@ pub fn config(cfg: &mut web::ServiceConfig) {
|
|||
.or(guard::Header("Accept", APUB_JSON_CONTENT_TYPE_LONG));
|
||||
let header_guard_content_type =
|
||||
guard::Any(guard::Header("Content-Type", APUB_JSON_CONTENT_TYPE))
|
||||
.or(guard::Header("Content-Type", APUB_JSON_CONTENT_TYPE_LONG))
|
||||
// TODO: compatibility with previous lemmy versions, remove this later
|
||||
.or(guard::Header("Content-Type", "application/json"));
|
||||
.or(guard::Header("Content-Type", APUB_JSON_CONTENT_TYPE_LONG));
|
||||
|
||||
cfg
|
||||
.service(
|
||||
|
|
Loading…
Reference in New Issue