Skip to content

Commit

Permalink
chore(deps): Update nextcloud/coding-standard to v1.3.0
Browse files Browse the repository at this point in the history
Signed-off-by: provokateurin <[email protected]>
  • Loading branch information
provokateurin committed Sep 18, 2024
1 parent 33928fc commit c06d3f0
Show file tree
Hide file tree
Showing 1,886 changed files with 10,562 additions and 1,740 deletions.
6 changes: 4 additions & 2 deletions apps/admin_audit/lib/Actions/Action.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,19 @@ public function log(string $text,
if (!isset($params[$element])) {
if ($obfuscateParameters) {
$this->logger->critical(
'$params["'.$element.'"] was missing.',
'$params["' . $element . '"] was missing.',
['app' => 'admin_audit']
);
} else {
$this->logger->critical(
sprintf(
'$params["'.$element.'"] was missing. Transferred value: %s',
'$params["' . $element . '"] was missing. Transferred value: %s',
print_r($params, true)
),
['app' => 'admin_audit']
);
}

return;
}
}
Expand All @@ -53,6 +54,7 @@ public function log(string $text,
if ($params[$element] instanceof \DateTime) {
$params[$element] = $params[$element]->format('Y-m-d H:i:s');
}

$replaceArray[] = $params[$element];
}

Expand Down
31 changes: 23 additions & 8 deletions apps/admin_audit/lib/Actions/Files.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,12 @@ public function read(BeforeNodeReadEvent $event): void {
];
} catch (InvalidPathException|NotFoundException $e) {
\OCP\Server::get(LoggerInterface::class)->error(
'Exception thrown in file read: '.$e->getMessage(), ['app' => 'admin_audit', 'exception' => $e]
'Exception thrown in file read: ' . $e->getMessage(), ['app' => 'admin_audit', 'exception' => $e]
);

return;
}

$this->log(
'File with id "%s" accessed: "%s"',
$params,
Expand All @@ -64,8 +66,9 @@ public function beforeRename(BeforeNodeRenamedEvent $event): void {
$this->renamedNodes[$source->getId()] = $source;
} catch (InvalidPathException|NotFoundException $e) {
\OCP\Server::get(LoggerInterface::class)->error(
'Exception thrown in file rename: '.$e->getMessage(), ['app' => 'admin_audit', 'exception' => $e]
'Exception thrown in file rename: ' . $e->getMessage(), ['app' => 'admin_audit', 'exception' => $e]
);

return;
}
}
Expand All @@ -86,8 +89,9 @@ public function afterRename(NodeRenamedEvent $event): void {
];
} catch (InvalidPathException|NotFoundException $e) {
\OCP\Server::get(LoggerInterface::class)->error(
'Exception thrown in file rename: '.$e->getMessage(), ['app' => 'admin_audit', 'exception' => $e]
'Exception thrown in file rename: ' . $e->getMessage(), ['app' => 'admin_audit', 'exception' => $e]
);

return;
}

Expand All @@ -112,13 +116,16 @@ public function create(NodeCreatedEvent $event): void {
];
} catch (InvalidPathException|NotFoundException $e) {
\OCP\Server::get(LoggerInterface::class)->error(
'Exception thrown in file create: '.$e->getMessage(), ['app' => 'admin_audit', 'exception' => $e]
'Exception thrown in file create: ' . $e->getMessage(), ['app' => 'admin_audit', 'exception' => $e]
);

return;
}

if ($params['path'] === '/' || $params['path'] === '') {
return;
}

$this->log(
'File with id "%s" created: "%s"',
$params,
Expand All @@ -141,10 +148,12 @@ public function copy(NodeCopiedEvent $event): void {
];
} catch (InvalidPathException|NotFoundException $e) {
\OCP\Server::get(LoggerInterface::class)->error(
'Exception thrown in file copy: '.$e->getMessage(), ['app' => 'admin_audit', 'exception' => $e]
'Exception thrown in file copy: ' . $e->getMessage(), ['app' => 'admin_audit', 'exception' => $e]
);

return;
}

$this->log(
'File id copied from: "%s" to "%s", path from "%s" to "%s"',
$params,
Expand All @@ -166,10 +175,12 @@ public function write(BeforeNodeWrittenEvent $event): void {
];
} catch (InvalidPathException|NotFoundException $e) {
\OCP\Server::get(LoggerInterface::class)->error(
'Exception thrown in file write: '.$e->getMessage(), ['app' => 'admin_audit', 'exception' => $e]
'Exception thrown in file write: ' . $e->getMessage(), ['app' => 'admin_audit', 'exception' => $e]
);

return;
}

if ($params['path'] === '/' || $params['path'] === '') {
return;
}
Expand All @@ -194,10 +205,12 @@ public function update(NodeWrittenEvent $event): void {
];
} catch (InvalidPathException|NotFoundException $e) {
\OCP\Server::get(LoggerInterface::class)->error(
'Exception thrown in file update: '.$e->getMessage(), ['app' => 'admin_audit', 'exception' => $e]
'Exception thrown in file update: ' . $e->getMessage(), ['app' => 'admin_audit', 'exception' => $e]
);

return;
}

$this->log(
'File with id "%s" updated: "%s"',
$params,
Expand All @@ -218,10 +231,12 @@ public function delete(NodeDeletedEvent $event): void {
];
} catch (InvalidPathException|NotFoundException $e) {
\OCP\Server::get(LoggerInterface::class)->error(
'Exception thrown in file delete: '.$e->getMessage(), ['app' => 'admin_audit', 'exception' => $e]
'Exception thrown in file delete: ' . $e->getMessage(), ['app' => 'admin_audit', 'exception' => $e]
);

return;
}

$this->log(
'File with id "%s" deleted: "%s"',
$params,
Expand Down
3 changes: 2 additions & 1 deletion apps/admin_audit/lib/Listener/FileEventListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ private function beforePreviewFetched(BeforePreviewFetchedEvent $event): void {
);
} catch (InvalidPathException|NotFoundException $e) {
\OCP\Server::get(LoggerInterface::class)->error(
'Exception thrown in file preview: '.$e->getMessage(), ['app' => 'admin_audit', 'exception' => $e]
'Exception thrown in file preview: ' . $e->getMessage(), ['app' => 'admin_audit', 'exception' => $e]
);

return;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function __construct(
private ICloudFederationProviderManager $cloudFederationProviderManager,
private Config $config,
private ICloudFederationFactory $factory,
private ICloudIdManager $cloudIdManager
private ICloudIdManager $cloudIdManager,
) {
parent::__construct($appName, $request);
}
Expand Down Expand Up @@ -125,6 +125,7 @@ public function addShare($shareWith, $name, $description, $providerId, $owner, $
Http::STATUS_BAD_REQUEST
);
$response->throttle();

return $response;
}
}
Expand All @@ -139,6 +140,7 @@ public function addShare($shareWith, $name, $description, $providerId, $owner, $
Http::STATUS_BAD_REQUEST
);
$response->throttle();

return $response;
}
}
Expand Down Expand Up @@ -242,6 +244,7 @@ public function receiveNotification($notificationType, $resourceType, $providerI
Http::STATUS_BAD_REQUEST
);
$response->throttle();

return $response;
} catch (ActionNotSupportedException $e) {
return new JSONResponse(
Expand All @@ -253,6 +256,7 @@ public function receiveNotification($notificationType, $resourceType, $providerI
} catch (AuthenticationFailedException $e) {
$response = new JSONResponse(['message' => 'RESOURCE_NOT_FOUND'], Http::STATUS_FORBIDDEN);
$response->throttle();

return $response;
} catch (\Exception $e) {
return new JSONResponse(
Expand Down
1 change: 1 addition & 0 deletions apps/comments/lib/Activity/Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public function parse($language, IEvent $event, ?IEvent $previousEvent = null):

return $this->parseLongVersion($event);
}

throw new UnknownActivityException();

}
Expand Down
3 changes: 3 additions & 0 deletions apps/comments/lib/Collaboration/CommentersSorter.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public function sort(array &$sortArray, array $context): void {
if ($r === 0) {
$r = $a[0] - $b[0];
}

return $r;
});

Expand All @@ -70,12 +71,14 @@ protected function retrieveCommentsInformation(string $type, string $id): array
if (!isset($actors[$comment->getActorType()])) {
$actors[$comment->getActorType()] = [];
}

if (!isset($actors[$comment->getActorType()][$comment->getActorId()])) {
$actors[$comment->getActorType()][$comment->getActorId()] = 1;
} else {
$actors[$comment->getActorType()][$comment->getActorId()]++;
}
}

return $actors;
}

Expand Down
3 changes: 2 additions & 1 deletion apps/comments/lib/Controller/NotificationsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function __construct(
protected IRootFolder $rootFolder,
protected IURLGenerator $urlGenerator,
protected IManager $notificationManager,
protected IUserSession $userSession
protected IUserSession $userSession,
) {
parent::__construct($appName, $request);
}
Expand Down Expand Up @@ -68,6 +68,7 @@ public function view(string $id): RedirectResponse|NotFoundResponse {
if ($comment->getObjectType() !== 'files') {
return new NotFoundResponse();
}

$userFolder = $this->rootFolder->getUserFolder($currentUser->getUID());
$files = $userFolder->getById((int)$comment->getObjectId());

Expand Down
1 change: 1 addition & 0 deletions apps/comments/lib/Listener/CommentsEventListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public function handle(Event $event): void {
) {
$this->notificationHandler($event);
$this->activityHandler($event);

return;
}

Expand Down
4 changes: 3 additions & 1 deletion apps/comments/lib/Notification/Listener.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
class Listener {
public function __construct(
protected IManager $notificationManager,
protected IUserManager $userManager
protected IUserManager $userManager,
) {
}

Expand Down Expand Up @@ -73,12 +73,14 @@ public function extractMentions(array $mentions): array {
if (empty($mentions)) {
return [];
}

$uids = [];
foreach ($mentions as $mention) {
if ($mention['type'] === 'user') {
$uids[] = $mention['id'];
}
}

return $uids;
}
}
12 changes: 11 additions & 1 deletion apps/comments/lib/Notification/Notifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function __construct(
protected IRootFolder $rootFolder,
protected ICommentsManager $commentsManager,
protected IURLGenerator $url,
protected IUserManager $userManager
protected IUserManager $userManager,
) {
}

Expand Down Expand Up @@ -61,12 +61,14 @@ public function prepare(INotification $notification, string $languageCode): INot
if ($notification->getApp() !== 'comments') {
throw new UnknownNotificationException();
}

try {
$comment = $this->commentsManager->get($notification->getObjectId());
} catch (NotFoundException $e) {
// needs to be converted to InvalidArgumentException, otherwise none Notifications will be shown at all
throw new UnknownNotificationException('Comment not found', 0, $e);
}

$l = $this->l10nFactory->get('comments', $languageCode);
$displayName = $comment->getActorId();
$isDeletedActor = $comment->getActorType() === ICommentsManager::DELETED_USER;
Expand All @@ -83,11 +85,13 @@ public function prepare(INotification $notification, string $languageCode): INot
if ($parameters[0] !== 'files') {
throw new UnknownNotificationException('Unsupported comment object');
}

$userFolder = $this->rootFolder->getUserFolder($notification->getUser());
$nodes = $userFolder->getById((int)$parameters[1]);
if (empty($nodes)) {
throw new AlreadyProcessedException();
}

$node = $nodes[0];

$path = rtrim($node->getPath(), '/');
Expand All @@ -96,6 +100,7 @@ public function prepare(INotification $notification, string $languageCode): INot
$fullPath = $path;
[,,, $path] = explode('/', $fullPath, 4);
}

$subjectParameters = [
'file' => [
'type' => 'file',
Expand All @@ -116,6 +121,7 @@ public function prepare(INotification $notification, string $languageCode): INot
'name' => $displayName,
];
}

[$message, $messageParameters] = $this->commentToRichMessage($comment);
$notification->setRichSubject($subject, $subjectParameters)
->setRichMessage($message, $messageParameters)
Expand Down Expand Up @@ -145,9 +151,11 @@ public function commentToRichMessage(IComment $comment): array {
continue;
}
}

if (!array_key_exists($mention['type'], $mentionTypeCount)) {
$mentionTypeCount[$mention['type']] = 0;
}

$mentionTypeCount[$mention['type']]++;
// To keep a limited character set in parameter IDs ([a-zA-Z0-9-])
// the mention parameter ID does not include the mention ID (which
Expand All @@ -166,12 +174,14 @@ public function commentToRichMessage(IComment $comment): array {
// type, so the client decides what to display.
$displayName = '';
}

$messageParameters[$mentionParameterId] = [
'type' => $mention['type'],
'id' => $mention['id'],
'name' => $displayName
];
}

return [$message, $messageParameters];
}
}
2 changes: 2 additions & 0 deletions apps/comments/lib/Search/CommentsSearchProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public function getOrder(string $route, array $routeParameters): int {
// Files first
return 0;
}

return 10;
}

Expand All @@ -54,6 +55,7 @@ public function search(IUser $user, ISearchQuery $query): SearchResult {
$avatarUrl = $isUser
? $this->urlGenerator->linkToRouteAbsolute('core.avatar.getAvatar', ['userId' => $result->authorId, 'size' => 42])
: $this->urlGenerator->linkToRouteAbsolute('core.GuestAvatar.getAvatar', ['guestName' => $result->authorId, 'size' => 42]);

return new SearchResultEntry(
$avatarUrl,
$result->name,
Expand Down
1 change: 1 addition & 0 deletions apps/comments/lib/Search/LegacyProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public function search($query): array {
if (!$user instanceof IUser) {
return [];
}

$uf = \OC::$server->getUserFolder($user->getUID());

if ($uf === null) {
Expand Down
1 change: 1 addition & 0 deletions apps/contactsinteraction/lib/AddressBook.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ public function childExists($name): bool {
$this->getUid(),
(int)$name
);

return true;
} catch (DoesNotExistException $e) {
return false;
Expand Down
Loading

0 comments on commit c06d3f0

Please sign in to comment.