From ab126563f3cb4d05e190814666d0de5c99ee7a3c Mon Sep 17 00:00:00 2001 From: Kitaiti Makoto Date: Sun, 13 Feb 2022 01:43:01 +0900 Subject: [PATCH] Implement AsObject07 for User --- plume-models/src/users.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/plume-models/src/users.rs b/plume-models/src/users.rs index 33c3d2f4..ebd44867 100644 --- a/plume-models/src/users.rs +++ b/plume-models/src/users.rs @@ -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 for User { } } +impl AsObject07 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)