Implement AsObject07 for User
This commit is contained in:
parent
c1b9ebdae6
commit
ab126563f3
@ -11,7 +11,9 @@ use activitypub::{
|
|||||||
object::{Image, Tombstone},
|
object::{Image, Tombstone},
|
||||||
Activity, CustomObject, Endpoint,
|
Activity, CustomObject, Endpoint,
|
||||||
};
|
};
|
||||||
use activitystreams::{actor::AsApActor, object::AsObject as _, prelude::*};
|
use activitystreams::{
|
||||||
|
activity::Delete as Delete07, actor::AsApActor, object::AsObject as _, 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};
|
||||||
@ -1161,6 +1163,19 @@ impl AsObject<User, Delete, &DbConn> for User {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl AsObject07<User, Delete07, &DbConn> for User {
|
||||||
|
type Error = Error;
|
||||||
|
type Output = ();
|
||||||
|
|
||||||
|
fn activity07(self, conn: &DbConn, actor: User, _id: &str) -> Result<()> {
|
||||||
|
if self.id == actor.id {
|
||||||
|
self.delete(conn).map(|_| ())
|
||||||
|
} else {
|
||||||
|
Err(Error::Unauthorized)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Signer for User {
|
impl Signer for User {
|
||||||
fn get_key_id(&self) -> String {
|
fn get_key_id(&self) -> String {
|
||||||
format!("{}#main-key", self.ap_url)
|
format!("{}#main-key", self.ap_url)
|
||||||
|
Loading…
Reference in New Issue
Block a user