[CORE][Event] Make all events return \EventResult, enforced at container build time
This commit is contained in:
@@ -45,6 +45,7 @@ use Component\Language\Entity\Language;
|
||||
use Component\Notification\Entity\Attention;
|
||||
use Component\Posting\Posting;
|
||||
use DateTime;
|
||||
use EventResult;
|
||||
use Plugin\RepeatNote\Entity\NoteRepeat as RepeatEntity;
|
||||
use const SORT_REGULAR;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
@@ -211,7 +212,7 @@ class RepeatNote extends NoteHandlerPlugin
|
||||
*
|
||||
* @return bool Event hook, Event::next (true) is returned to allow Event to be handled by other handlers
|
||||
*/
|
||||
public function onFilterNoteList(?Actor $actor, array &$notes, Request $request): bool
|
||||
public function onFilterNoteList(?Actor $actor, array &$notes, Request $request): EventResult
|
||||
{
|
||||
// Replaces repeat with original note on Actor feed
|
||||
// it's pretty cool
|
||||
@@ -236,7 +237,7 @@ class RepeatNote extends NoteHandlerPlugin
|
||||
*
|
||||
* @return bool Event hook, Event::next (true) is returned to allow Event to be handled by other handlers
|
||||
*/
|
||||
public function onAddNoteActions(Request $request, Note $note, array &$actions): bool
|
||||
public function onAddNoteActions(Request $request, Note $note, array &$actions): EventResult
|
||||
{
|
||||
// Only logged users can repeat notes
|
||||
if (\is_null($user = Common::user())) {
|
||||
@@ -280,7 +281,7 @@ class RepeatNote extends NoteHandlerPlugin
|
||||
*
|
||||
* @return bool Event hook, Event::next (true) is returned to allow Event to be handled by other handlers
|
||||
*/
|
||||
public function onAppendCardNote(array $vars, array &$result)
|
||||
public function onAppendCardNote(array $vars, array &$result): EventResult
|
||||
{
|
||||
// If note is the original and user isn't the one who repeated, append on end "user repeated this"
|
||||
// If user is the one who repeated, append on end "you repeated this, remove repeat?"
|
||||
@@ -318,7 +319,7 @@ class RepeatNote extends NoteHandlerPlugin
|
||||
*
|
||||
* @return bool Event hook, Event::next (true) is returned to allow Event to be handled by other handlers
|
||||
*/
|
||||
public function onNoteDeleteRelated(Note &$note, Actor $actor): bool
|
||||
public function onNoteDeleteRelated(Note &$note, Actor $actor): EventResult
|
||||
{
|
||||
$note_repeats_list = RepeatEntity::getNoteRepeats($note);
|
||||
foreach ($note_repeats_list as $note_repeat) {
|
||||
@@ -340,7 +341,7 @@ class RepeatNote extends NoteHandlerPlugin
|
||||
*
|
||||
* @return bool Event hook, Event::next (true) is returned to allow Event to be handled by other handlers
|
||||
*/
|
||||
public function onAddRoute(Router $r): bool
|
||||
public function onAddRoute(Router $r): EventResult
|
||||
{
|
||||
// Add/remove note to/from repeats
|
||||
$r->connect(id: 'repeat_add', uri_path: '/object/note/{note_id<\d+>}/repeat', target: [Controller\Repeat::class, 'repeatAddNote']);
|
||||
@@ -427,7 +428,7 @@ class RepeatNote extends NoteHandlerPlugin
|
||||
return Event::stop;
|
||||
}
|
||||
|
||||
public function onActivityPubNewNotification(Actor $sender, Activity $activity, array $targets, ?string $reason = null): bool
|
||||
public function onActivityPubNewNotification(Actor $sender, Activity $activity, array $targets, ?string $reason = null): EventResult
|
||||
{
|
||||
switch ($activity->getVerb()) {
|
||||
case 'repeat':
|
||||
@@ -465,7 +466,7 @@ class RepeatNote extends NoteHandlerPlugin
|
||||
*
|
||||
* @return bool Returns `Event::stop` if handled, `Event::next` otherwise
|
||||
*/
|
||||
public function onNewActivityPubActivity(Actor $actor, \ActivityPhp\Type\AbstractObject $type_activity, \ActivityPhp\Type\AbstractObject $type_object, ?\Plugin\ActivityPub\Entity\ActivitypubActivity &$ap_act): bool
|
||||
public function onNewActivityPubActivity(Actor $actor, \ActivityPhp\Type\AbstractObject $type_activity, \ActivityPhp\Type\AbstractObject $type_object, ?\Plugin\ActivityPub\Entity\ActivitypubActivity &$ap_act): EventResult
|
||||
{
|
||||
return $this->activitypub_handler($actor, $type_activity, $type_object, $ap_act);
|
||||
}
|
||||
@@ -490,7 +491,7 @@ class RepeatNote extends NoteHandlerPlugin
|
||||
*
|
||||
* @return bool Returns `Event::stop` if handled, `Event::next` otherwise
|
||||
*/
|
||||
public function onNewActivityPubActivityWithObject(Actor $actor, \ActivityPhp\Type\AbstractObject $type_activity, mixed $type_object, ?\Plugin\ActivityPub\Entity\ActivitypubActivity &$ap_act): bool
|
||||
public function onNewActivityPubActivityWithObject(Actor $actor, \ActivityPhp\Type\AbstractObject $type_activity, mixed $type_object, ?\Plugin\ActivityPub\Entity\ActivitypubActivity &$ap_act): EventResult
|
||||
{
|
||||
return $this->activitypub_handler($actor, $type_activity, $type_object, $ap_act);
|
||||
}
|
||||
@@ -503,7 +504,7 @@ class RepeatNote extends NoteHandlerPlugin
|
||||
*
|
||||
* @return bool Returns `Event::stop` if handled, `Event::next` otherwise
|
||||
*/
|
||||
public function onGSVerbToActivityStreamsTwoActivityType(string $verb, ?string &$gs_verb_to_activity_stream_two_verb): bool
|
||||
public function onGSVerbToActivityStreamsTwoActivityType(string $verb, ?string &$gs_verb_to_activity_stream_two_verb): EventResult
|
||||
{
|
||||
if ($verb === 'repeat') {
|
||||
$gs_verb_to_activity_stream_two_verb = 'Announce';
|
||||
|
Reference in New Issue
Block a user