WIP
This commit is contained in:
parent
6168930fe6
commit
95cf6cd335
@ -8,6 +8,11 @@ use activitypub::{
|
||||
object::Image,
|
||||
CustomObject,
|
||||
};
|
||||
use activitystreams::{
|
||||
activity::ActorAndObjectRef,
|
||||
object::{kind::ImageType, ApObject, AsObject, Image as Image07, ObjectExt},
|
||||
prelude::*,
|
||||
};
|
||||
use chrono::NaiveDateTime;
|
||||
use diesel::{self, ExpressionMethods, OptionalExtension, QueryDsl, RunQueryDsl, SaveChangesDsl};
|
||||
use openssl::{
|
||||
@ -17,8 +22,8 @@ use openssl::{
|
||||
sign::{Signer, Verifier},
|
||||
};
|
||||
use plume_common::activity_pub::{
|
||||
inbox::{AsActor, FromId},
|
||||
sign, ActivityStream, ApSignature, Id, IntoId, PublicKey, Source,
|
||||
inbox::{AsActor, FromId, FromId07},
|
||||
sign, ActivityStream, ApSignature, CustomGroup as CustomGroup07, Id, IntoId, PublicKey, Source,
|
||||
};
|
||||
use url::Url;
|
||||
use webfinger::*;
|
||||
@ -449,6 +454,43 @@ impl FromId<DbConn> for Blog {
|
||||
}
|
||||
}
|
||||
|
||||
impl FromId07<DbConn> for Blog {
|
||||
type Error = Error;
|
||||
type Object = CustomGroup07;
|
||||
|
||||
fn from_db07(conn: &DbConn, id: &str) -> Result<Self> {
|
||||
Self::find_by_ap_url(conn, id)
|
||||
}
|
||||
|
||||
fn from_activity07(conn: &DbConn, acct: CustomGroup07) -> Result<Self> {
|
||||
let icon_id = acct
|
||||
.object_ref()
|
||||
.icon()
|
||||
.and_then(|icons| {
|
||||
icons.iter().next().and_then(|icon| {
|
||||
let icon = icon.extend::<Image07, ImageType>().ok()?;
|
||||
let owner = icon
|
||||
.attributed_to()
|
||||
.iter()
|
||||
.next()
|
||||
.ok_or(Error::MissingApProperty)?
|
||||
.as_str();
|
||||
Media::save_remote(
|
||||
conn,
|
||||
icon.url().ok_or(Error::MissingApProperty)?,
|
||||
&User::from_id07(conn, owner, None, CONFIG.proxy()).ok()?,
|
||||
)
|
||||
.ok()
|
||||
})
|
||||
})
|
||||
.map(|m| m.id);
|
||||
}
|
||||
|
||||
fn get_sender07() -> &'static dyn sign::Signer {
|
||||
Instance::get_local_instance_user().expect("Failed to local instance user")
|
||||
}
|
||||
}
|
||||
|
||||
impl AsActor<&PlumeRocket> for Blog {
|
||||
fn get_inbox_url(&self) -> String {
|
||||
self.inbox_url.clone()
|
||||
|
Loading…
x
Reference in New Issue
Block a user