Remove remaining usages of old activitystreams library #70
|
@ -1,5 +1,6 @@
|
|||
use crate::LemmyError;
|
||||
use activitystreams::{ext::Extension, Actor};
|
||||
use activitystreams_ext::UnparsedExtension;
|
||||
use activitystreams_new::unparsed::UnparsedMutExt;
|
||||
use diesel::PgConnection;
|
||||
use lemmy_db::{category::Category, Crud};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
@ -37,4 +38,22 @@ impl GroupExtension {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T> Extension<T> for GroupExtension where T: Actor {}
|
||||
impl<U> UnparsedExtension<U> for GroupExtension
|
||||
where
|
||||
U: UnparsedMutExt,
|
||||
{
|
||||
type Error = serde_json::Error;
|
||||
|
||||
fn try_from_unparsed(unparsed_mut: &mut U) -> Result<Self, Self::Error> {
|
||||
Ok(GroupExtension {
|
||||
category: unparsed_mut.remove("category")?,
|
||||
sensitive: unparsed_mut.remove("sensitive")?,
|
||||
})
|
||||
}
|
||||
|
||||
fn try_into_unparsed(self, unparsed_mut: &mut U) -> Result<(), Self::Error> {
|
||||
unparsed_mut.insert("category", self.category)?;
|
||||
unparsed_mut.insert("sensitive", self.sensitive)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use activitystreams::{ext::Extension, Base};
|
||||
use activitystreams_ext::UnparsedExtension;
|
||||
use activitystreams_new::unparsed::UnparsedMutExt;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
||||
|
@ -8,4 +9,22 @@ pub struct PageExtension {
|
|||
pub sensitive: bool,
|
||||
}
|
||||
|
||||
impl<T> Extension<T> for PageExtension where T: Base {}
|
||||
impl<U> UnparsedExtension<U> for PageExtension
|
||||
where
|
||||
U: UnparsedMutExt,
|
||||
{
|
||||
type Error = serde_json::Error;
|
||||
|
||||
fn try_from_unparsed(unparsed_mut: &mut U) -> Result<Self, Self::Error> {
|
||||
Ok(PageExtension {
|
||||
comments_enabled: unparsed_mut.remove("commentsEnabled")?,
|
||||
sensitive: unparsed_mut.remove("sensitive")?,
|
||||
})
|
||||
}
|
||||
|
||||
fn try_into_unparsed(self, unparsed_mut: &mut U) -> Result<(), Self::Error> {
|
||||
unparsed_mut.insert("commentsEnabled", self.comments_enabled)?;
|
||||
unparsed_mut.insert("sensitive", self.sensitive)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
use crate::{apub::ActorType, LemmyError};
|
||||
use activitystreams::ext::Extension;
|
||||
use activitystreams_ext::UnparsedExtension;
|
||||
use activitystreams_new::unparsed::UnparsedMutExt;
|
||||
use actix_web::{client::ClientRequest, HttpRequest};
|
||||
use http_signature_normalization_actix::{
|
||||
digest::{DigestClient, SignExt},
|
||||
|
@ -98,4 +99,20 @@ impl PublicKey {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T> Extension<T> for PublicKeyExtension where T: activitystreams::Actor {}
|
||||
impl<U> UnparsedExtension<U> for PublicKeyExtension
|
||||
where
|
||||
U: UnparsedMutExt,
|
||||
{
|
||||
type Error = serde_json::Error;
|
||||
|
||||
fn try_from_unparsed(unparsed_mut: &mut U) -> Result<Self, Self::Error> {
|
||||
Ok(PublicKeyExtension {
|
||||
public_key: unparsed_mut.remove("publicKey")?,
|
||||
})
|
||||
}
|
||||
|
||||
fn try_into_unparsed(self, unparsed_mut: &mut U) -> Result<(), Self::Error> {
|
||||
unparsed_mut.insert("publicKey", self.public_key)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Its so tempting to add the stickied here. It'd be so much easier than using the "featured" as a separate list.
Hmm we could do that, its not part of the ActivityPub standard. Only thing is that we wouldnt be compatible with Mastodon, but our HTTP Signatures arent compatible with theirs either. So it might be a way to get things working, and later we do the proper, compatible implementation.
Or we just do it right from the start, its not that complicated.