Implement AsObject07 for User

This commit is contained in:
Kitaiti Makoto 2022-02-13 01:43:01 +09:00
parent c1b9ebdae6
commit ab126563f3

View file

@ -11,7 +11,9 @@ use activitypub::{
object::{Image, Tombstone},
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 diesel::{self, BelongingToDsl, ExpressionMethods, OptionalExtension, QueryDsl, RunQueryDsl};
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 {
fn get_key_id(&self) -> String {
format!("{}#main-key", self.ap_url)