Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 5 additions & 13 deletions lib/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ public function setOutput(OutputInterface $output): void {
$this->push->setOutput($output);
}

/**
* @param INotification $notification
* @since 8.2.0
*/
#[\Override]
public function notify(INotification $notification): void {
$this->lastInsertedId = $this->handler->add($notification);

Expand All @@ -47,19 +44,12 @@ public function getLastInsertedId(): ?int {
return $this->lastInsertedId;
}

/**
* @param INotification $notification
* @return int
* @since 8.2.0
*/
#[\Override]
public function getCount(INotification $notification): int {
return $this->handler->count($notification);
}

/**
* @param INotification $notification
* @since 8.2.0
*/
#[\Override]
public function markProcessed(INotification $notification): void {
$deleted = $this->handler->delete($notification);

Expand All @@ -77,10 +67,12 @@ public function markProcessed(INotification $notification): void {
}
}

#[\Override]
public function defer(): void {
$this->push->deferPayloads();
}

#[\Override]
public function flush(): void {
$this->push->flushPayloads();
}
Expand Down
6 changes: 4 additions & 2 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public function __construct() {
parent::__construct(self::APP_ID);
}

#[\Override]
public function register(IRegistrationContext $context): void {
$context->registerCapability(Capabilities::class);

Expand All @@ -49,11 +50,12 @@ public function register(IRegistrationContext $context): void {
$context->registerEventListener(PostLoginEvent::class, PostLoginListener::class);
}

#[\Override]
public function boot(IBootContext $context): void {
$context->injectFn(\Closure::fromCallable([$this, 'registerAppAndNotifier']));
$context->injectFn(\Closure::fromCallable([$this, 'registerApp']));
}

public function registerAppAndNotifier(IManager $notificationManager): void {
public function registerApp(IManager $notificationManager): void {
// notification app
$notificationManager->registerApp(App::class);
}
Expand Down
1 change: 1 addition & 0 deletions lib/BackgroundJob/GenerateUserSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public function __construct(
$this->setInterval(24 * 60 * 60);
}

#[\Override]
protected function run($argument): void {
$query = $this->connection->getQueryBuilder();
$query->select('notification_id')
Expand Down
1 change: 1 addition & 0 deletions lib/BackgroundJob/SendNotificationMails.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public function __construct(
parent::__construct($timeFactory);
}

#[\Override]
protected function run($argument): void {
$time = $this->time->getTime();
$batchSize = $this->isCLI ? MailNotifications::BATCH_SIZE_CLI : MailNotifications::BATCH_SIZE_WEB;
Expand Down
1 change: 1 addition & 0 deletions lib/Capabilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class Capabilities implements ICapability {
* },
* }
*/
#[\Override]
public function getCapabilities(): array {
return [
'notifications' => [
Expand Down
7 changes: 2 additions & 5 deletions lib/Command/Delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public function __construct(
parent::__construct();
}

#[\Override]
protected function configure(): void {
$this
->setName('notification:delete')
Expand All @@ -42,11 +43,7 @@ protected function configure(): void {
;
}

/**
* @param InputInterface $input
* @param OutputInterface $output
* @return int
*/
#[\Override]
protected function execute(InputInterface $input, OutputInterface $output): int {

$userId = (string)$input->getArgument('user-id');
Expand Down
9 changes: 3 additions & 6 deletions lib/Command/Generate.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public function __construct(
parent::__construct();
}

#[\Override]
protected function configure(): void {
$this
->setName('notification:generate')
Expand Down Expand Up @@ -92,11 +93,7 @@ protected function configure(): void {
;
}

/**
* @param InputInterface $input
* @param OutputInterface $output
* @return int
*/
#[\Override]
protected function execute(InputInterface $input, OutputInterface $output): int {

$userId = (string)$input->getArgument('user-id');
Expand Down Expand Up @@ -194,7 +191,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
if ($idOnly) {
$output->writeln((string)$this->notificationApp->getLastInsertedId());
} else {
$output->writeln('<info>Notification with ID ' . $this->notificationApp->getLastInsertedId() . '</info>');
$output->writeln('<info>Notification with ID ' . (string)($this->notificationApp->getLastInsertedId() ?? 0) . '</info>');
}
return 0;
}
Expand Down
7 changes: 2 additions & 5 deletions lib/Command/TestPush.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public function __construct(
parent::__construct();
}

#[\Override]
protected function configure(): void {
$this
->setName('notification:test-push')
Expand All @@ -54,11 +55,7 @@ protected function configure(): void {
;
}

/**
* @param InputInterface $input
* @param OutputInterface $output
* @return int
*/
#[\Override]
protected function execute(InputInterface $input, OutputInterface $output): int {
if (!$this->notificationManager->isFairUseOfFreePushService()) {
$output->writeln('<error>We want to keep offering our push notification service for free, but large</error>');
Expand Down
2 changes: 1 addition & 1 deletion lib/Controller/EndpointController.php
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ public function deleteAllNotifications(): DataResponse {
* @return string
*/
protected function generateETag(array $notifications): string {
return md5(json_encode($notifications));
return md5(json_encode($notifications, JSON_THROW_ON_ERROR));
}

/**
Expand Down
6 changes: 5 additions & 1 deletion lib/Controller/PushController.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,11 @@ public function registerDevice(string $pushTokenHash, string $devicePublicKey, s

$key = $this->identityProof->getKey($user);

$deviceIdentifier = json_encode([$user->getCloudId(), $token->getId()]);
try {
$deviceIdentifier = json_encode([$user->getCloudId(), $token->getId()], JSON_THROW_ON_ERROR);
} catch (\JsonException) {
return new DataResponse(['message' => 'INVALID_SESSION_TOKEN'], Http::STATUS_BAD_REQUEST);
}
openssl_sign($deviceIdentifier, $signature, $key->getPrivate(), OPENSSL_ALGO_SHA512);
/**
* For some reason the push proxy's golang code needs the signature
Expand Down
32 changes: 32 additions & 0 deletions lib/FakeUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,130 +16,162 @@ public function __construct(
) {
}

#[\Override]
public function getUID(): string {
return $this->userId;
}

#[\Override]
public function getCloudId() {
throw new \RuntimeException('Not implemented');
}

#[\Override]
public function getSystemEMailAddress(): ?string {
throw new \RuntimeException('Not implemented');
}

#[\Override]
public function getPrimaryEMailAddress(): ?string {
throw new \RuntimeException('Not implemented');
}

#[\Override]
public function getDisplayName() {
throw new \RuntimeException('Not implemented');
}

#[\Override]
public function setDisplayName($displayName) {
throw new \RuntimeException('Not implemented');
}

#[\Override]
public function getLastLogin(): int {
throw new \RuntimeException('Not implemented');
}

#[\Override]
public function getFirstLogin(): int {
throw new \RuntimeException('Not implemented');
}

#[\Override]
public function updateLastLoginTimestamp(): bool {
throw new \RuntimeException('Not implemented');
}

#[\Override]
public function delete() {
throw new \RuntimeException('Not implemented');
}

#[\Override]
public function setPassword($password, $recoveryPassword = null) {
throw new \RuntimeException('Not implemented');
}

#[\Override]
public function getHome() {
throw new \RuntimeException('Not implemented');
}

#[\Override]
public function getBackendClassName() {
throw new \RuntimeException('Not implemented');
}

#[\Override]
public function getBackend(): ?\OCP\UserInterface {
throw new \RuntimeException('Not implemented');
}

#[\Override]
public function canChangeAvatar() {
throw new \RuntimeException('Not implemented');
}

#[\Override]
public function canChangePassword() {
throw new \RuntimeException('Not implemented');
}

#[\Override]
public function canChangeDisplayName() {
throw new \RuntimeException('Not implemented');
}

#[\Override]
public function canChangeEmail(): bool {
throw new \RuntimeException('Not implemented');
}

#[\Override]
public function isEnabled() {
throw new \RuntimeException('Not implemented');
}

#[\Override]
public function setEnabled(bool $enabled = true) {
throw new \RuntimeException('Not implemented');
}

#[\Override]
public function getEMailAddress() {
throw new \RuntimeException('Not implemented');
}

#[\Override]
public function getAvatarImage($size) {
throw new \RuntimeException('Not implemented');
}

#[\Override]
public function setEMailAddress($mailAddress) {
throw new \RuntimeException('Not implemented');
}

#[\Override]
public function getQuota() {
throw new \RuntimeException('Not implemented');
}

#[\Override]
public function getQuotaBytes(): int|float {
throw new \RuntimeException('Not implemented');
}

#[\Override]
public function setQuota($quota) {
throw new \RuntimeException('Not implemented');
}

#[\Override]
public function setSystemEMailAddress(string $mailAddress): void {
throw new \RuntimeException('Not implemented');
}

#[\Override]
public function setPrimaryEMailAddress(string $mailAddress): void {
throw new \RuntimeException('Not implemented');
}

#[\Override]
public function getManagerUids(): array {
throw new \RuntimeException('Not implemented');
}

#[\Override]
public function setManagerUids(array $uids): void {
throw new \RuntimeException('Not implemented');
}

#[\Override]
public function getPasswordHash(): ?string {
throw new \RuntimeException('Not implemented');
}

#[\Override]
public function setPasswordHash(string $passwordHash): bool {
throw new \RuntimeException('Not implemented');
}
Expand Down
1 change: 1 addition & 0 deletions lib/Listener/AddMissingIndicesListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* @template-implements IEventListener<Event|AddMissingIndicesEvent>
*/
class AddMissingIndicesListener implements IEventListener {
#[\Override]
public function handle(Event $event): void {
if (!($event instanceof AddMissingIndicesEvent)) {
// Unrelated
Expand Down
1 change: 1 addition & 0 deletions lib/Listener/BeforeTemplateRenderedListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public function __construct(
) {
}

#[\Override]
public function handle(Event $event): void {
if (!($event instanceof BeforeTemplateRenderedEvent)) {
// Unrelated
Expand Down
1 change: 1 addition & 0 deletions lib/Listener/PostLoginListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public function __construct(
) {
}

#[\Override]
public function handle(Event $event): void {
if (!($event instanceof PostLoginEvent)) {
// Unrelated
Expand Down
1 change: 1 addition & 0 deletions lib/Listener/UserCreatedListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public function __construct(
) {
}

#[\Override]
public function handle(Event $event): void {
if (!($event instanceof UserCreatedEvent)) {
// Unrelated
Expand Down
1 change: 1 addition & 0 deletions lib/Listener/UserDeletedListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public function __construct(
) {
}

#[\Override]
public function handle(Event $event): void {
if (!($event instanceof UserDeletedEvent)) {
// Unrelated
Expand Down
Loading