From f3b67ab6c9f7e3986236c2d2198ce07789a55e27 Mon Sep 17 00:00:00 2001 From: Kitaiti Makoto Date: Fri, 11 Feb 2022 14:49:52 +0900 Subject: [PATCH] WIP --- plume-models/src/users.rs | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/plume-models/src/users.rs b/plume-models/src/users.rs index 1e27fb19..2100d721 100644 --- a/plume-models/src/users.rs +++ b/plume-models/src/users.rs @@ -11,6 +11,7 @@ use activitypub::{ object::{Image, Tombstone}, Activity, CustomObject, Endpoint, }; +use activitystreams::{actor::ApActor, object::AsApObject, prelude::*}; use chrono::{NaiveDateTime, Utc}; use diesel::{self, BelongingToDsl, ExpressionMethods, OptionalExtension, QueryDsl, RunQueryDsl}; use ldap3::{LdapConn, Scope, SearchEntry}; @@ -22,10 +23,11 @@ use openssl::{ }; use plume_common::{ activity_pub::{ - inbox::{AsActor, AsObject, FromId}, + inbox::{AsActor, AsObject, AsObject07, FromId, FromId07}, request::get, 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, }; @@ -1025,6 +1027,23 @@ impl FromId for User { } } +impl FromId07 for User { + type Error = Error; + type Object = CustomPerson07; + + fn from_db07(conn: &DbConn, id: &str) -> Result { + Self::find_by_ap_url(conn, id) + } + + fn from_activity07(conn: &DbConn, acct: CustomPerson07) -> Result { + 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 { fn get_inbox_url(&self) -> String { self.inbox_url.clone()