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