[TOOLS][DOC] Add documentation to functions flagged by doc-check

This commit is contained in:
Hugo Sales 2022-01-02 22:02:25 +00:00 committed by Diogo Peralta Cordeiro
parent 9e0a2dd4a0
commit a9ea49d34c
Signed by: diogo
GPG Key ID: 18D2D35001FBFAB0
6 changed files with 40 additions and 1 deletions

View File

@ -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';

View File

@ -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([

View File

@ -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)) {

View File

@ -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, '!');

View File

@ -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)) {

View File

@ -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 ?? [];