[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:
@@ -51,12 +51,17 @@ class Group extends Component
|
||||
* Enqueues a notification for an Actor (such as person or group) which means
|
||||
* it shows up in their home feed and such.
|
||||
*/
|
||||
public function onNewNotificationWithTargets(Actor $sender, Activity $activity, array $targets = [], ?string $reason = null): bool
|
||||
public function onNewNotificationStart(Actor $sender, Activity $activity, array $targets = [], ?string $reason = null): bool
|
||||
{
|
||||
foreach ($targets as $target) {
|
||||
if ($target->isGroup()) {
|
||||
// The Group announces to its subscribers
|
||||
Notification::notify($target, $activity, $target->getSubscribers(), $reason);
|
||||
Notification::notify(
|
||||
sender: $target,
|
||||
activity: $activity,
|
||||
targets: $target->getSubscribers(),
|
||||
reason: $reason,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user