[NOTIFICATION] Add FreeNetwork distribution
This commit is contained in:
parent
84217ec866
commit
4ddd00a091
@ -265,9 +265,13 @@ class FreeNetwork extends Component
|
||||
return Event::stop;
|
||||
}
|
||||
|
||||
public static function notify(Actor $sender, Activity $activity, Actor $target, ?string $reason = null): bool
|
||||
public static function notify(Actor $sender, Activity $activity, array $targets, ?string $reason = null): bool
|
||||
{
|
||||
// TODO: implement
|
||||
$protocols = [];
|
||||
Event::handle('AddFreeNetworkProtocol', [&$protocols]);
|
||||
foreach ($protocols as $protocol) {
|
||||
$protocol::freeNetworkDistribute($sender, $activity, $targets, $reason);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -21,15 +21,12 @@ declare(strict_types=1);
|
||||
|
||||
namespace Component\Notification;
|
||||
|
||||
use App\Core\DB\DB;
|
||||
use App\Core\Event;
|
||||
use App\Core\Log;
|
||||
use App\Core\Modules\Component;
|
||||
use App\Entity\Activity;
|
||||
use App\Entity\Actor;
|
||||
use Component\FreeNetwork\FreeNetwork;
|
||||
use DateTime;
|
||||
use DateTimeInterface;
|
||||
|
||||
class Notification extends Component
|
||||
{
|
||||
@ -40,29 +37,32 @@ class Notification extends Component
|
||||
public function onNewNotification(Actor $sender, Activity $activity, array $ids_already_known = [], ?string $reason = null): bool
|
||||
{
|
||||
$targets = $activity->getNotificationTargets($ids_already_known);
|
||||
foreach ($targets as $target) {
|
||||
$this->notify($sender, $activity, $target, $reason);
|
||||
}
|
||||
$this->notify($sender, $activity, $targets, $reason);
|
||||
|
||||
return Event::next;
|
||||
}
|
||||
|
||||
public function notify(Actor $sender, Activity $activity, Actor $target, ?string $reason = null): bool
|
||||
public function notify(Actor $sender, Activity $activity, array $targets, ?string $reason = null): bool
|
||||
{
|
||||
$remote_targets = [];
|
||||
foreach ($targets as $target) {
|
||||
if ($target->getIsLocal()) {
|
||||
if ($target->isGroup()) {
|
||||
// FIXME: Make sure we check (for both local and remote) users are in the groups they send to!
|
||||
} else {
|
||||
if ($target->hasBlocked($activity->getActor())) {
|
||||
Log::info("Not saving reply to actor {$target->getId()} from sender {$sender->getId()} because of a block.");
|
||||
return false;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
// TODO: use https://symfony.com/doc/current/notifier.html
|
||||
} else {
|
||||
$remote_targets[] = $target;
|
||||
}
|
||||
}
|
||||
|
||||
if ($target->getIsLocal()) {
|
||||
// TODO: use https://symfony.com/doc/current/notifier.html
|
||||
} else {
|
||||
return FreeNetwork::notify($sender, $activity, $target, $reason);
|
||||
}
|
||||
return true;
|
||||
FreeNetwork::notify($sender, $activity, $remote_targets, $reason);
|
||||
|
||||
return Event::next;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user