diff --git a/components/Collection/Util/MetaCollectionPlugin.php b/components/Collection/Util/MetaCollectionPlugin.php index 00c05bf6bc..2445d1aab3 100644 --- a/components/Collection/Util/MetaCollectionPlugin.php +++ b/components/Collection/Util/MetaCollectionPlugin.php @@ -54,8 +54,12 @@ abstract class MetaCollectionPlugin extends Plugin abstract protected function removeItems(Actor $owner, array $vars, $items, array $collections); abstract protected function addItems(Actor $owner, array $vars, $items, array $collections); + /** + * Check the route to determine whether the widget should be added + */ abstract protected function shouldAddToRightPanel(Actor $user, $vars, Request $request): bool; abstract protected function getCollectionsBy(Actor $owner, ?array $vars = null, bool $ids_only = false): array; + /** * Append Collections widget to the right panel. * It's compose of two forms: one to select collections to add @@ -152,6 +156,7 @@ abstract class MetaCollectionPlugin extends Plugin ); return Event::next; } + public function onEndShowStyles(array &$styles, string $route): bool { $styles[] = 'components/Collection/assets/css/widget.css'; diff --git a/plugins/ActorCircles/ActorCircles.php b/plugins/ActorCircles/ActorCircles.php index 8e14f91d5a..5788e4efac 100644 --- a/plugins/ActorCircles/ActorCircles.php +++ b/plugins/ActorCircles/ActorCircles.php @@ -60,6 +60,7 @@ class ActorCircles extends MetaCollectionPlugin $actor = DB::findOneBy(Actor::class, ['nickname' => $nick]); return $actor->getId(); } + protected function createCollection(Actor $owner, array $vars, string $name) { $actor_id = $this->getActorIdFromVars($vars); @@ -73,6 +74,7 @@ class ActorCircles extends MetaCollectionPlugin 'circle_id' => $col->getId(), ])); } + protected function removeItems(Actor $owner, array $vars, $items, array $collections) { $actor_id = $this->getActorIdFromVars($vars); @@ -86,6 +88,7 @@ class ActorCircles extends MetaCollectionPlugin 'ids' => $items, ]); } + protected function addItems(Actor $owner, array $vars, $items, array $collections) { $actor_id = $this->getActorIdFromVars($vars); @@ -99,6 +102,10 @@ class ActorCircles extends MetaCollectionPlugin } } } + + /** + * @see MetaCollectionPlugin->shouldAddToRightPanel + */ protected function shouldAddToRightPanel(Actor $user, $vars, Request $request): bool { return @@ -107,6 +114,7 @@ class ActorCircles extends MetaCollectionPlugin || $vars['path'] === 'group_actor_view_nickname' || $vars['path'] === 'group_actor_view_id'; } + protected function getCollectionsBy(Actor $owner, ?array $vars = null, bool $ids_only = false): array { if (\is_null($vars)) { @@ -158,6 +166,7 @@ class ActorCircles extends MetaCollectionPlugin ); return Event::next; } + public function onCreateDefaultFeeds(int $actor_id, LocalUser $user, int &$ordering) { DB::persist(Feed::create([ diff --git a/plugins/Favourite/Entity/NoteFavourite.php b/plugins/Favourite/Entity/NoteFavourite.php index 43e8bd11b3..6a30cd0c3a 100644 --- a/plugins/Favourite/Entity/NoteFavourite.php +++ b/plugins/Favourite/Entity/NoteFavourite.php @@ -101,6 +101,9 @@ class NoteFavourite extends Entity ); } + /** + * @see Entity->getNotificationTargetIds + */ public function getNotificationTargetIds(array $ids_already_known = [], ?int $sender_id = null, bool $include_additional = true): array { if (!\array_key_exists('object', $ids_already_known)) { diff --git a/plugins/NoteTypeFeedFilter/NoteTypeFeedFilter.php b/plugins/NoteTypeFeedFilter/NoteTypeFeedFilter.php index fa0dda278b..130b1fd2f5 100644 --- a/plugins/NoteTypeFeedFilter/NoteTypeFeedFilter.php +++ b/plugins/NoteTypeFeedFilter/NoteTypeFeedFilter.php @@ -53,6 +53,11 @@ class NoteTypeFeedFilter extends Plugin return new ClientException(_m('Unknown note type requested ({type})', ['{type}' => $type])); } + /** + * Normalize the given $types so only those in self::ALLOWED_TYPES + * are present, filling in the missing ones with the negated + * version + */ private function normalizeTypesList(array $types, bool $add_missing = true): array { if (empty($types)) { @@ -84,13 +89,23 @@ class NoteTypeFeedFilter extends Plugin } } + /** + * Remove Notes from $notes if the GET parameter note-types requests they shoud + * + * Includes if any positive type matches, but removes if any negated matches + */ public function onFilterNoteList(?Actor $actor, array &$notes, Request $request): bool { $types = $this->normalizeTypesList(\is_null($request->get('note-types')) ? [] : explode(',', $request->get('note-types'))); $notes = F\select( $notes, + /** + * Filter each note based on the requested $types + * + * @TODO Would like to express this as a reduce of some sort + */ function (Note $note) use ($types) { - $include = false; // TODO Would like to express this as a reduce of some sort... + $include = false; foreach ($types as $type) { $is_negate = $type[0] === '!'; $type = Formatting::removePrefix($type, '!'); diff --git a/plugins/RepeatNote/Entity/NoteRepeat.php b/plugins/RepeatNote/Entity/NoteRepeat.php index 6685b062d2..88476f0d18 100644 --- a/plugins/RepeatNote/Entity/NoteRepeat.php +++ b/plugins/RepeatNote/Entity/NoteRepeat.php @@ -98,6 +98,9 @@ class NoteRepeat extends Entity ); } + /** + * @see Entity->getNotificationTargetIds + */ public function getNotificationTargetIds(array $ids_already_known = [], ?int $sender_id = null, bool $include_additional = true): array { if (!\array_key_exists('object', $ids_already_known)) { diff --git a/src/Entity/Note.php b/src/Entity/Note.php index 3c8fd140f3..40d2b25265 100644 --- a/src/Entity/Note.php +++ b/src/Entity/Note.php @@ -407,6 +407,10 @@ class Note extends Entity $this->object_mentions_ids = $mentions; return $this; } + + /** + * @see Entity->getNotificationTargetIds + */ public function getNotificationTargetIds(array $ids_already_known = [], ?int $sender_id = null, bool $include_additional = true): array { $target_ids = $this->object_mentions_ids ?? [];