[COMPONENT][Notification] Make logic more generic and robust
Fixed various bugs Some important concepts to bear in mind: * Notification: Associated with activities, won't be reconstructed together with objects, can be thought of as transient * Attention: Associated with objects, will be reconstructed with them, can be thought as persistent * Notifications and Attentions have no direct implications. * Mentions are a specific form of attentions in notes, leads to the creation of Attentions. Finally, Potential PHP issue detected and reported: https://github.com/php/php-src/issues/8199 `static::method()` from a non static context (such as a class method) calls `__call`, rather than the expected `__callStatic`. Can be fixed by using `(static fn() => static::method())()`, but the usage of the magic method is strictly unnecessary in this case.
This commit is contained in:
@@ -97,7 +97,7 @@ class DeleteNote extends NoteHandlerPlugin
|
||||
Cache::delete(self::cacheKeys($note)['activity']);
|
||||
|
||||
// Undertaker successful
|
||||
Event::handle('NewNotification', [$actor, $activity, [], _m('{nickname} deleted note {note_id}.', ['nickname' => $actor->getNickname(), 'note_id' => $activity->getObjectId()])]);
|
||||
Event::handle('NewNotification', [$actor, $activity, $note->getAttentionTargets(), _m('{actor_id} deleted note {note_id}.', ['actor_id' => $actor->getId(), 'note_id' => $activity->getObjectId()])]);
|
||||
return $activity;
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ class DeleteNote extends NoteHandlerPlugin
|
||||
if (\is_null(
|
||||
Cache::get(
|
||||
self::cacheKeys($note)['activity'],
|
||||
fn () => DB::findOneBy(Activity::class, ['verb' => 'delete', 'object_type' => 'note', 'object_id' => $note->getId()], return_null: true),
|
||||
fn () => DB::findOneBy(Activity::class, ['verb' => 'delete', 'object_type' => Note::schemaName(), 'object_id' => $note->getId()], return_null: true),
|
||||
),
|
||||
)) {
|
||||
// If none found, then undertaker has a job to do
|
||||
@@ -164,7 +164,7 @@ class DeleteNote extends NoteHandlerPlugin
|
||||
// Only add action if note wasn't already deleted!
|
||||
\is_null(Cache::get(
|
||||
self::cacheKeys($note)['activity'],
|
||||
fn () => DB::findOneBy(Activity::class, ['verb' => 'delete', 'object_type' => 'note', 'object_id' => $note->getId()], return_null: true),
|
||||
fn () => DB::findOneBy(Activity::class, ['verb' => 'delete', 'object_type' => Note::schemaName(), 'object_id' => $note->getId()], return_null: true),
|
||||
))
|
||||
// And has permissions
|
||||
&& $actor->canModerate($note->getActor())) {
|
||||
|
Reference in New Issue
Block a user