1 use crate::fetcher::post_or_comment::PostOrComment;
2 use lemmy_db_queries::source::{
8 use lemmy_db_schema::source::{
15 use lemmy_utils::LemmyError;
16 use lemmy_api_common::LemmyContext;
18 // TODO: merge this trait with ApubObject (means that db_schema needs to depend on apub_lib)
19 #[async_trait::async_trait(?Send)]
20 pub trait DeletableApubObject {
21 // TODO: pass in tombstone with summary field, to decide between remove/delete
22 async fn delete(self, context: &LemmyContext) -> Result<(), LemmyError>;
25 #[async_trait::async_trait(?Send)]
26 impl DeletableApubObject for Community {
27 async fn delete(self, context: &LemmyContext) -> Result<(), LemmyError> {
29 Community::update_deleted(context.pool(), id, true)
35 #[async_trait::async_trait(?Send)]
36 impl DeletableApubObject for Person {
37 async fn delete(self, context: &LemmyContext) -> Result<(), LemmyError> {
39 Person::delete_account(context.pool(), id).await?;
44 #[async_trait::async_trait(?Send)]
45 impl DeletableApubObject for Post {
46 async fn delete(self, context: &LemmyContext) -> Result<(), LemmyError> {
48 Post::update_deleted(context.pool(), id, true)
54 #[async_trait::async_trait(?Send)]
55 impl DeletableApubObject for Comment {
56 async fn delete(self, context: &LemmyContext) -> Result<(), LemmyError> {
58 Comment::update_deleted(context.pool(), id, true)
64 #[async_trait::async_trait(?Send)]
65 impl DeletableApubObject for PostOrComment {
66 async fn delete(self, context: &LemmyContext) -> Result<(), LemmyError> {
68 PostOrComment::Comment(c) => {
69 Comment::update_deleted(context.pool(), c.id, true)
72 PostOrComment::Post(p) => {
73 Post::update_deleted(context.pool(), p.id, true)
82 #[async_trait::async_trait(?Send)]
83 impl DeletableApubObject for Site {
84 async fn delete(self, _context: &LemmyContext) -> Result<(), LemmyError> {
85 // not implemented, ignore