[ENTITY][Note] GNU social uses Tombstones for deleted notes instead of fully removing them.

Various corrections.
This commit is contained in:
2021-12-28 06:18:59 +00:00
parent bb4149e092
commit bf4a0008ef
6 changed files with 50 additions and 250 deletions

View File

@@ -35,6 +35,7 @@ use Component\Avatar\Avatar;
use Component\Conversation\Entity\Conversation;
use Component\Language\Entity\Language;
use DateTimeInterface;
use function App\Core\I18n\_m;
/**
* Entity for notices
@@ -475,22 +476,18 @@ class Note extends Entity
return $mentioned;
}
public function delete(?int $actor_id = null, string $source = 'web'): bool
public function delete(?Actor $actor = null, string $source = 'web'): Activity
{
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;
Event::handle('NoteDeleteRelated', [&$this, $actor]);
DB::persist($activity = Activity::create([
'actor_id' => $actor->getId(),
'verb' => 'delete',
'object_type' => 'note',
'object_id' => $this->getId(),
'source' => $source,
]));
DB::remove(DB::findOneBy(self::class, ['id' => $this->id]));
return $activity;
}
public static function schemaDef(): array