[COMPONENT][Notification] ->getSubscribers() should not be pre-included
Notification bug fix on Subscription component Correct docblock
This commit is contained in:
@@ -30,6 +30,7 @@ use App\Core\Form;
|
||||
use function App\Core\I18n\_m;
|
||||
use App\Core\Log;
|
||||
use App\Core\Router\Router;
|
||||
use App\Entity\Activity;
|
||||
use App\Entity\Actor;
|
||||
use App\Entity\Note;
|
||||
use App\Util\Common;
|
||||
@@ -37,6 +38,7 @@ use App\Util\Exception\ClientException;
|
||||
use App\Util\Exception\NoLoggedInUser;
|
||||
use App\Util\Exception\RedirectException;
|
||||
use App\Util\Exception\ServerException;
|
||||
use Component\Notification\Entity\Attention;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
@@ -73,9 +75,15 @@ class Repeat extends Controller
|
||||
|
||||
$form_add_to_repeat->handleRequest($request);
|
||||
if ($form_add_to_repeat->isSubmitted()) {
|
||||
$repeat_activity = \Plugin\RepeatNote\RepeatNote::repeatNote(note: $note, actor_id: $actor_id);
|
||||
$activity = \Plugin\RepeatNote\RepeatNote::repeatNote(note: $note, actor_id: $actor_id);
|
||||
$actor = Actor::getById($actor_id);
|
||||
foreach ($actor->getSubscribers() as $subscriber) {
|
||||
$target_id = $subscriber->getId();
|
||||
DB::persist(Attention::create(['object_type' => Activity::schemaName(), 'object_id' => $activity->getId(), 'target_id' => $target_id]));
|
||||
$effective_attentions[$target_id] = $subscriber;
|
||||
}
|
||||
DB::flush();
|
||||
Event::handle('NewNotification', [$actor = Actor::getById($actor_id), $repeat_activity, $repeat_activity->getAttentionTargets(), _m('{actor_id} repeated note {note_id}.', ['{actor_id}' => $actor->getId(), '{note_id}' => $repeat_activity->getObjectId()])]);
|
||||
Event::handle('NewNotification', [$actor, $activity, $activity->getAttentionTargets(), _m('{actor_id} repeated note {note_id}.', ['{actor_id}' => $actor->getId(), '{note_id}' => $activity->getObjectId()])]);
|
||||
|
||||
// Redirect user to where they came from
|
||||
// Prevent open redirect
|
||||
@@ -130,9 +138,15 @@ class Repeat extends Controller
|
||||
|
||||
$form_remove_repeat->handleRequest($request);
|
||||
if ($form_remove_repeat->isSubmitted()) {
|
||||
if (!\is_null($undo_repeat_activity = \Plugin\RepeatNote\RepeatNote::unrepeatNote(note_id: $note_id, actor_id: $actor_id))) {
|
||||
if (!\is_null($activity = \Plugin\RepeatNote\RepeatNote::unrepeatNote(note_id: $note_id, actor_id: $actor_id))) {
|
||||
$actor = Actor::getById($actor_id);
|
||||
foreach ($actor->getSubscribers() as $subscriber) {
|
||||
$target_id = $subscriber->getId();
|
||||
DB::persist(Attention::create(['object_type' => Activity::schemaName(), 'object_id' => $activity->getId(), 'target_id' => $target_id]));
|
||||
$effective_attentions[$target_id] = $subscriber;
|
||||
}
|
||||
DB::flush();
|
||||
Event::handle('NewNotification', [$actor = Actor::getById($actor_id), $undo_repeat_activity, $undo_repeat_activity->getAttentionTargets(), _m('{actor_id} unrepeated note {note_id}.', ['{actor_id}' => $actor->getId(), '{note_id}' => $note_id])]);
|
||||
Event::handle('NewNotification', [$actor, $activity, $activity->getAttentionTargets(), _m('{actor_id} unrepeated note {note_id}.', ['{actor_id}' => $actor->getId(), '{note_id}' => $note_id])]);
|
||||
} else {
|
||||
throw new ClientException(_m('Note wasn\'t repeated!'));
|
||||
}
|
||||
|
Reference in New Issue
Block a user