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
21 changes: 20 additions & 1 deletion lib/ContextChat/ContextChatRegistrar.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
use OCP\AppFramework\Bootstrap\IRegistrationContext;

/**
* Binds the interfaces other components type against to the ContextChat classes.
* Binds the interfaces other components type against to the ContextChat classes,
* and registers the component's event listeners.
*
* An alias only names the class; nothing here loads ContentProvider, whose
* parent interface is missing before Nextcloud 32.
Expand Down Expand Up @@ -55,4 +56,22 @@ public static function register(IRegistrationContext $context): void {
$context->registerServiceAlias($contract, $service);
}
}//end register()

/**
* Register the ContextChat component's event listeners.
*
* The content provider registers softly gated by
* IContentManager::isContextChatAvailable() inside the listener body, so an
* instance without the `context_chat` app installed is entirely unaffected.
* `::class` does not load the event, whose class is missing before Nextcloud 32.
*
* @param IRegistrationContext $context The registration context.
*
* @return void
*
* @spec exclude Container wiring; no behaviour of its own.
*/
public static function registerListeners(IRegistrationContext $context): void {
$context->registerEventListener(\OCP\ContextChat\Events\ContentProviderRegisterEvent::class, ContentProviderRegistrationListener::class);
}//end registerListeners()
}//end class
5 changes: 2 additions & 3 deletions lib/Controller/AnalyticsSeriesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

namespace OCA\OpenRegister\Controller;

use OCA\OpenRegister\Kernel\Contracts\AppIdentity;
use OCA\OpenRegister\Service\AnalyticsSeriesServiceInterface;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http;
Expand All @@ -52,18 +53,16 @@ class AnalyticsSeriesController extends Controller {
/**
* Constructor.
*
* @param string $appName App name (injected by NC).
* @param IRequest $request Current request.
* @param AnalyticsSeriesServiceInterface $seriesService Series register/fetch service.
*
* @return void
*/
public function __construct(
string $appName,
IRequest $request,
private AnalyticsSeriesServiceInterface $seriesService,
) {
parent::__construct(appName: $appName, request: $request);
parent::__construct(appName: AppIdentity::APP_ID, request: $request);
}//end __construct()

/**
Expand Down
19 changes: 13 additions & 6 deletions lib/Files/Service/TextExtraction/PatternSet/NlPatternSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,16 @@

namespace OCA\OpenRegister\Files\Service\TextExtraction\PatternSet;

use OCA\OpenRegister\Formats\BsnFormat;
use OCA\OpenRegister\Formats\IdentifierFormats;
use Opis\JsonSchema\Format;
use OCA\OpenRegister\Files\Service\TextExtraction\EntityRecognitionHandler;

/**
* Recognises Dutch identifiers in text.
*
* A BSN is a nine-digit token, written plain or in the groups 4-2-3 or 3-2-4
* separated by a dot or a space, that passes the elfproef. The elfproef is
* the one in {@see BsnFormat}; no second copy is written here. A nine-digit
* the one in the Formats component; no second copy is written here. A nine-digit
* token that fails it is not a BSN and is not reported. A BSN is reported as
* {@see EntityRecognitionHandler::ENTITY_TYPE_SSN}, the citizen service number
* type the risk service rates very high.
Expand All @@ -58,14 +59,20 @@ class NlPatternSet implements JurisdictionPatternSet {
*/
private const BSN_CONFIDENCE = 0.85;

/**
* The elfproef.
*
* @var Format
*/
private readonly Format $bsnFormat;

/**
* Constructor.
*
* @param BsnFormat $bsnFormat The elfproef.
* @param Format|null $bsnFormat The elfproef; the Formats component's BSN check when null.
*/
public function __construct(
private readonly BsnFormat $bsnFormat = new BsnFormat(),
) {
public function __construct(?Format $bsnFormat=null) {
$this->bsnFormat = $bsnFormat ?? IdentifierFormats::bsn();
}//end __construct()

/**
Expand Down
48 changes: 48 additions & 0 deletions lib/Formats/IdentifierFormats.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

/**
* OpenRegister IdentifierFormats
*
* Hands out the identifier checks of this component behind the JSON Schema
* format interface, so callers outside lib/Formats never name the concrete
* check.
*
* SPDX-License-Identifier: EUPL-1.2
* SPDX-FileCopyrightText: 2026 Conduction B.V.
*
* @category Format
* @package OCA\OpenRegister\Formats
*
* @author Conduction Development Team <info@conduction.nl>
* @copyright 2026 Conduction B.V.
* @license EUPL-1.2 https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
*
* @version GIT: <git-id>
*
* @link https://OpenRegister.app
*/

declare(strict_types=1);

namespace OCA\OpenRegister\Formats;

use Opis\JsonSchema\Format;

/**
* Factory for the identifier checks of the Formats component.
*
* @spec openspec/specs/data-import-export/spec.md
*/
final class IdentifierFormats {

/**
* The BSN elfproef.
*
* @return Format
*
* @spec openspec/specs/data-import-export/spec.md
*/
public static function bsn(): Format {
return new BsnFormat();
}//end bsn()
}//end class
10 changes: 5 additions & 5 deletions lib/Listener/NotifyPushListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
use OCA\OpenRegister\Event\ObjectDeletedEvent;
use OCA\OpenRegister\Event\ObjectUpdatedEvent;
use OCA\OpenRegister\Listener\Support\PushSlugResolver;
use OCA\OpenRegister\Push\PushEvents;
use OCA\OpenRegister\Push\PushChannels;
use OCA\OpenRegister\Service\Object\ObjectReadersInterface;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
Expand Down Expand Up @@ -291,7 +291,7 @@ private function accumulateBatchEntry(ObjectEntity $object): void {
private function dispatchPushes(string $action, ObjectEntity $object, object $queue): void {
$payload = $this->lifecyclePayload(action: $action, object: $object);
$userIds = $this->permissionHandler->getReadableByUsers(object: $object);
$objectChannel = PushEvents::OR_OBJECT . '-' . $payload['uuid'];
$objectChannel = PushChannels::OR_OBJECT . '-' . $payload['uuid'];
$pushed = $this->pushToUsers(queue: $queue, userIds: $userIds, channel: $objectChannel, payload: $payload);

$collectionChannel = $this->collectionChannel(payload: $payload);
Expand Down Expand Up @@ -339,7 +339,7 @@ private function collectionChannel(array $payload): ?string {
return null;
}

return PushEvents::OR_COLLECTION . '-' . $payload['register'] . '-' . $payload['schema'];
return PushChannels::OR_COLLECTION . '-' . $payload['register'] . '-' . $payload['schema'];
}//end collectionChannel()

/**
Expand Down Expand Up @@ -519,7 +519,7 @@ private static function broadcastCollection(object $queue, array $entry): void {
$queue->push(
'notify_custom',
[
'message' => PushEvents::OR_COLLECTION . '-' . $entry['register'] . '-' . $entry['schema'],
'message' => PushChannels::OR_COLLECTION . '-' . $entry['register'] . '-' . $entry['schema'],
'body' => [
'action' => 'batch',
'register' => $entry['register'],
Expand Down Expand Up @@ -608,6 +608,6 @@ public function pushPresence(ObjectEntity $object, array $present): bool {
$payload = ['action' => 'presence', 'uuid' => $uuid, 'present' => array_values($present)];
$readers = $this->permissionHandler->getReadableByUsers(object: $object);

return $this->pushToUsers(queue: $queue, userIds: $readers, channel: PushEvents::OR_OBJECT . '-' . $uuid, payload: $payload);
return $this->pushToUsers(queue: $queue, userIds: $readers, channel: PushChannels::OR_OBJECT . '-' . $uuid, payload: $payload);
}//end pushPresence()
}//end class
8 changes: 3 additions & 5 deletions lib/Listener/Registrar/FlowsListenerRegistrar.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

namespace OCA\OpenRegister\Listener\Registrar;

use OCA\OpenRegister\ContextChat\ContentProviderRegistrationListener;
use OCA\OpenRegister\ContextChat\ContextChatRegistrar;
use OCA\OpenRegister\Event\BulkActionRegistrationEvent;
use OCA\OpenRegister\Event\ObjectLockedEvent;
use OCA\OpenRegister\Event\ObjectRevertedEvent;
Expand Down Expand Up @@ -141,10 +141,8 @@ private static function registerFileAndDiscoveryListeners(IRegistrationContext $
$context->registerEventListener(\OCP\OCM\Events\ResourceTypeRegisterEvent::class, OcmResourceTypeListener::class);

// Register OpenRegister as a Context Chat (OCP\ContextChat) content
// provider — softly gated by IContentManager::isContextChatAvailable()
// inside the listener body, so an instance without the `context_chat`
// app installed is entirely unaffected.
$context->registerEventListener(\OCP\ContextChat\Events\ContentProviderRegisterEvent::class, ContentProviderRegistrationListener::class);
// provider; the ContextChat component names its own listener.
ContextChatRegistrar::registerListeners(context: $context);
}//end registerFileAndDiscoveryListeners()

/**
Expand Down
70 changes: 70 additions & 0 deletions lib/Push/PushChannels.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php

/**
* OpenRegister PushChannels
*
* Defines the canonical event strings used by OpenRegister when pushing
* real-time notifications to connected browser clients via the Nextcloud
* notify_push app.
*
* Naming convention (mirrors OCA\Deck\NotifyPushEvents):
* - OR_OBJECT → `or-object` — base string; append `-{uuid}` to target a single object.
* - OR_COLLECTION → `or-collection` — base string; append `-{register-slug}-{schema-slug}` to target a collection.
*
* SPDX-License-Identifier: EUPL-1.2
* SPDX-FileCopyrightText: 2026 Conduction B.V.
*
* @category Push
* @package OCA\OpenRegister\Push
*
* @author Conduction Development Team <dev@conductio.nl>
* @copyright 2024 Conduction B.V.
* @license EUPL-1.2 https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
*
* @version GIT: <git-id>
*
* @link https://OpenRegister.app
*/

declare(strict_types=1);

namespace OCA\OpenRegister\Push;

/**
* The notify_push channel names OpenRegister pushes on.
*
* Consumers (e.g. @conduction/nextcloud-vue) subscribe to:
* - `or-object-{uuid}` — single-object updates
* - `or-collection-{register-slug}-{schema-slug}` — collection-level invalidation (create/delete)
*/
interface PushChannels {

/**
* Base event string for single-object updates.
*
* Append `-{uuid}` when pushing to specific listeners:
* ```
* $eventString = PushChannels::OR_OBJECT . '-' . $uuid;
* ```
*
* Fired on every object lifecycle action (create, update, delete).
*
* @var string
*/
public const OR_OBJECT = 'or-object';

/**
* Base event string for collection-level invalidation.
*
* Append `-{register-slug}-{schema-slug}` when pushing to collection listeners:
* ```
* $eventString = PushChannels::OR_COLLECTION . '-' . $registerSlug . '-' . $schemaSlug;
* ```
*
* Fired on create and delete only (not on update, to avoid redundant
* collection refreshes when only content changes).
*
* @var string
*/
public const OR_COLLECTION = 'or-collection';
}//end interface
37 changes: 3 additions & 34 deletions lib/Push/PushEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,39 +33,8 @@
/**
* Constants for notify_push event strings used by OpenRegister.
*
* Consumers (e.g. @conduction/nextcloud-vue) subscribe to:
* - `or-object-{uuid}` — single-object updates
* - `or-collection-{register-slug}-{schema-slug}` — collection-level invalidation (create/delete)
* The names themselves live on {@see PushChannels}; this class keeps them
* reachable as PushEvents::OR_OBJECT and PushEvents::OR_COLLECTION.
*/
class PushEvents {

/**
* Base event string for single-object updates.
*
* Append `-{uuid}` when pushing to specific listeners:
* ```
* $eventString = PushEvents::OR_OBJECT . '-' . $uuid;
* ```
*
* Fired on every object lifecycle action (create, update, delete).
*
* @var string
*/
public const OR_OBJECT = 'or-object';

/**
* Base event string for collection-level invalidation.
*
* Append `-{register-slug}-{schema-slug}` when pushing to collection listeners:
* ```
* $eventString = PushEvents::OR_COLLECTION . '-' . $registerSlug . '-' . $schemaSlug;
* ```
*
* Fired on create and delete only (not on update, to avoid redundant
* collection refreshes when only content changes).
*
* @var string
*/
public const OR_COLLECTION = 'or-collection';

class PushEvents implements PushChannels {
}//end class
11 changes: 0 additions & 11 deletions lib/Service/Integration/BuiltinIntegrationServices.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,24 +208,13 @@ final class BuiltinIntegrationServices {
'logger' => \Psr\Log\LoggerInterface::class,
'container' => self::CONTAINER,
],
\OCA\OpenRegister\Controller\CaseTokenController::class => [
'request' => \OCP\IRequest::class,
'tokenService' => \OCA\OpenRegister\Service\CaseTokenService::class,
'throttler' => \OCP\Security\Bruteforce\IThrottler::class,
'logger' => \Psr\Log\LoggerInterface::class,
],
// @spec openspec/specs/integration-leaf-foundation/spec.md
\OCA\OpenRegister\Service\AnalyticsSeriesService::class => [
'mapper' => \OCA\OpenRegister\Db\AnalyticsSeriesMapperInterface::class,
'registry' => \OCA\OpenRegister\Service\Integration\IntegrationRegistry::class,
'userSession' => \OCP\IUserSession::class,
'groupManager' => \OCP\IGroupManager::class,
],
\OCA\OpenRegister\Controller\AnalyticsSeriesController::class => [
'appName' => self::APP_NAME,
'request' => \OCP\IRequest::class,
'seriesService' => \OCA\OpenRegister\Service\AnalyticsSeriesService::class,
],
// @spec openspec/specs/integration-bookmarks/spec.md
\OCA\OpenRegister\Service\Integration\Providers\BookmarksProvider::class => [
'bookmarkLinkMapper' => \OCA\OpenRegister\Db\BookmarkLinkMapperInterface::class,
Expand Down
10 changes: 0 additions & 10 deletions tests/Unit/AppInfo/BuiltinIntegrationProviderRegistrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,22 +155,12 @@ class BuiltinIntegrationProviderRegistrationTest extends TestCase {
'OCP\IURLGenerator',
'Psr\Log\LoggerInterface',
],
'OCA\OpenRegister\Controller\CaseTokenController' => [
'OCP\IRequest',
'OCA\OpenRegister\Service\CaseTokenService',
'OCP\Security\Bruteforce\IThrottler',
'Psr\Log\LoggerInterface',
],
'OCA\OpenRegister\Service\AnalyticsSeriesService' => [
'OCA\OpenRegister\Db\AnalyticsSeriesMapperInterface',
'OCA\OpenRegister\Service\Integration\IntegrationRegistry',
'OCP\IUserSession',
'OCP\IGroupManager',
],
'OCA\OpenRegister\Controller\AnalyticsSeriesController' => [
'OCP\IRequest',
'OCA\OpenRegister\Service\AnalyticsSeriesService',
],
'OCA\OpenRegister\Service\Integration\Providers\BookmarksProvider' => [
'OCA\OpenRegister\Db\BookmarkLinkMapperInterface',
'OCP\App\IAppManager',
Expand Down
Loading
Loading