[ENTITY][Note] Add deleter

This commit is contained in:
Diogo Peralta Cordeiro 2021-12-10 02:35:28 +00:00
parent b1585f0ef2
commit 5f167517ad
Signed by: diogo
GPG Key ID: 18D2D35001FBFAB0
1 changed files with 17 additions and 0 deletions

View File

@ -360,6 +360,23 @@ class Note extends Entity
return $mentioned;
}
public function delete(?int $actor_id = null, string $source = 'web'): bool
{
if (Event::handle('NoteDeleteRelated', [&$this]) === Event::next) {
DB::persist(Activity::create([
'actor_id' => $actor_id ?? $this->getActorId(),
'verb' => 'delete',
'object_type' => 'note',
'object_id' => $this->getId(),
'source' => $source
])
);
DB::remove($this);
return true;
}
return false;
}
public static function schemaDef(): array
{
return [