Remove users::CustomPerson
This commit is contained in:
parent
f8870af9fe
commit
6c615d01ad
@ -4,11 +4,11 @@ use crate::{
|
|||||||
safe_string::SafeString, schema::users, timeline::Timeline, Connection, Error, Result,
|
safe_string::SafeString, schema::users, timeline::Timeline, Connection, Error, Result,
|
||||||
UserEvent::*, CONFIG, ITEMS_PER_PAGE, USER_CHAN,
|
UserEvent::*, CONFIG, ITEMS_PER_PAGE, USER_CHAN,
|
||||||
};
|
};
|
||||||
use activitypub::{actor::Person, Activity, CustomObject};
|
use activitypub::Activity;
|
||||||
use activitystreams::{
|
use activitystreams::{
|
||||||
activity::Delete,
|
activity::Delete,
|
||||||
actor::{ApActor, AsApActor},
|
actor::{ApActor, AsApActor},
|
||||||
actor::{ApActor as ApActor07, Endpoints, Person as Person07},
|
actor::{ApActor as ApActor07, Endpoints, Person},
|
||||||
base::{AnyBase, Base},
|
base::{AnyBase, Base},
|
||||||
collection::{OrderedCollection as OrderedCollection07, OrderedCollectionPage},
|
collection::{OrderedCollection as OrderedCollection07, OrderedCollectionPage},
|
||||||
iri_string::types::IriString,
|
iri_string::types::IriString,
|
||||||
@ -30,8 +30,8 @@ use plume_common::{
|
|||||||
inbox::{AsActor, AsObject, FromId},
|
inbox::{AsActor, AsObject, FromId},
|
||||||
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, ApSignature07, CustomPerson as CustomPerson07, Id, IntoId,
|
ActivityStream, ApSignature07, CustomPerson, Id, IntoId, PublicKey07, ToAsString, ToAsUri,
|
||||||
PublicKey07, ToAsString, ToAsUri, PUBLIC_VISIBILITY,
|
PUBLIC_VISIBILITY,
|
||||||
},
|
},
|
||||||
utils,
|
utils,
|
||||||
};
|
};
|
||||||
@ -47,8 +47,6 @@ use std::{
|
|||||||
};
|
};
|
||||||
use webfinger::*;
|
use webfinger::*;
|
||||||
|
|
||||||
pub type CustomPerson = CustomObject<ApSignature, Person>;
|
|
||||||
|
|
||||||
pub enum Role {
|
pub enum Role {
|
||||||
Admin = 0,
|
Admin = 0,
|
||||||
Moderator = 1,
|
Moderator = 1,
|
||||||
@ -247,13 +245,13 @@ impl User {
|
|||||||
.ok_or(Error::Webfinger)
|
.ok_or(Error::Webfinger)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fetch(url: &str) -> Result<CustomPerson07> {
|
fn fetch(url: &str) -> Result<CustomPerson> {
|
||||||
let mut res = get(url, Self::get_sender07(), CONFIG.proxy().cloned())?;
|
let mut res = get(url, Self::get_sender07(), CONFIG.proxy().cloned())?;
|
||||||
let text = &res.text()?;
|
let text = &res.text()?;
|
||||||
// without this workaround, publicKey is not correctly deserialized
|
// without this workaround, publicKey is not correctly deserialized
|
||||||
let ap_sign = serde_json::from_str::<ApSignature07>(text)?;
|
let ap_sign = serde_json::from_str::<ApSignature07>(text)?;
|
||||||
let person = serde_json::from_str::<Person07>(text)?;
|
let person = serde_json::from_str::<Person>(text)?;
|
||||||
let json = CustomPerson07::new(
|
let json = CustomPerson::new(
|
||||||
ApActor::new(
|
ApActor::new(
|
||||||
person
|
person
|
||||||
.clone()
|
.clone()
|
||||||
@ -827,8 +825,8 @@ impl User {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_activity07(&self, conn: &Connection) -> Result<CustomPerson07> {
|
pub fn to_activity07(&self, conn: &Connection) -> Result<CustomPerson> {
|
||||||
let mut actor = ApActor07::new(self.inbox_url.parse()?, Person07::new());
|
let mut actor = ApActor07::new(self.inbox_url.parse()?, Person::new());
|
||||||
let ap_url = self.ap_url.parse::<IriString>()?;
|
let ap_url = self.ap_url.parse::<IriString>()?;
|
||||||
actor.set_id(ap_url.clone());
|
actor.set_id(ap_url.clone());
|
||||||
actor.set_name(self.display_name.clone());
|
actor.set_name(self.display_name.clone());
|
||||||
@ -862,7 +860,7 @@ impl User {
|
|||||||
actor.set_icon(avatar.into_any_base()?);
|
actor.set_icon(avatar.into_any_base()?);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(CustomPerson07::new(actor, ap_signature))
|
Ok(CustomPerson::new(actor, ap_signature))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn delete_activity07(&self, conn: &Connection) -> Result<Delete> {
|
pub fn delete_activity07(&self, conn: &Connection) -> Result<Delete> {
|
||||||
@ -998,13 +996,13 @@ impl Eq for User {}
|
|||||||
|
|
||||||
impl FromId<DbConn> for User {
|
impl FromId<DbConn> for User {
|
||||||
type Error = Error;
|
type Error = Error;
|
||||||
type Object = CustomPerson07;
|
type Object = CustomPerson;
|
||||||
|
|
||||||
fn from_db07(conn: &DbConn, id: &str) -> Result<Self> {
|
fn from_db07(conn: &DbConn, id: &str) -> Result<Self> {
|
||||||
Self::find_by_ap_url(conn, id)
|
Self::find_by_ap_url(conn, id)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_activity07(conn: &DbConn, acct: CustomPerson07) -> Result<Self> {
|
fn from_activity07(conn: &DbConn, acct: CustomPerson) -> Result<Self> {
|
||||||
let actor = acct.ap_actor_ref();
|
let actor = acct.ap_actor_ref();
|
||||||
let username = actor
|
let username = actor
|
||||||
.preferred_username()
|
.preferred_username()
|
||||||
|
Loading…
Reference in New Issue
Block a user