This commit is contained in:
Kitaiti Makoto 2022-02-11 14:49:52 +09:00
parent 66f5628a27
commit f3b67ab6c9

View File

@ -11,6 +11,7 @@ use activitypub::{
object::{Image, Tombstone}, object::{Image, Tombstone},
Activity, CustomObject, Endpoint, Activity, CustomObject, Endpoint,
}; };
use activitystreams::{actor::ApActor, object::AsApObject, prelude::*};
use chrono::{NaiveDateTime, Utc}; use chrono::{NaiveDateTime, Utc};
use diesel::{self, BelongingToDsl, ExpressionMethods, OptionalExtension, QueryDsl, RunQueryDsl}; use diesel::{self, BelongingToDsl, ExpressionMethods, OptionalExtension, QueryDsl, RunQueryDsl};
use ldap3::{LdapConn, Scope, SearchEntry}; use ldap3::{LdapConn, Scope, SearchEntry};
@ -22,10 +23,11 @@ use openssl::{
}; };
use plume_common::{ use plume_common::{
activity_pub::{ activity_pub::{
inbox::{AsActor, AsObject, FromId}, inbox::{AsActor, AsObject, AsObject07, FromId, FromId07},
request::get, request::get,
sign::{gen_keypair, Error as SignError, Result as SignResult, Signer}, sign::{gen_keypair, Error as SignError, Result as SignResult, Signer},
ActivityStream, ApSignature, Id, IntoId, PublicKey, PUBLIC_VISIBILITY, ActivityStream, ApSignature, CustomPerson as CustomPerson07, Id, IntoId, PublicKey,
PUBLIC_VISIBILITY,
}, },
utils, utils,
}; };
@ -1025,6 +1027,23 @@ impl FromId<DbConn> for User {
} }
} }
impl FromId07<DbConn> for User {
type Error = Error;
type Object = CustomPerson07;
fn from_db07(conn: &DbConn, id: &str) -> Result<Self> {
Self::find_by_ap_url(conn, id)
}
fn from_activity07(conn: &DbConn, acct: CustomPerson07) -> Result<Self> {
let url = Url::parse(acct.ap_object_ref().id()?)?;
}
fn get_sender07() -> &'static dyn Signer {
Instance::get_local_instance_user().expect("Failed to local instance user")
}
}
impl AsActor<&DbConn> for User { impl AsActor<&DbConn> for User {
fn get_inbox_url(&self) -> String { fn get_inbox_url(&self) -> String {
self.inbox_url.clone() self.inbox_url.clone()