Skip to content

Commit 976b241

Browse files
authored
Merge pull request #6353 from ConductionNL/quality/build-case-notes-stay-in-dossiq
feat(dossiq): build case-notes-stay-in-dossiq
2 parents 6a25522 + ea97ffc commit 976b241

20 files changed

Lines changed: 22 additions & 3141 deletions

‎appinfo/routes.php‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -449,13 +449,6 @@
449449
// dossiq-side side-effect: turning a saved note's @mention
450450
// tokens into real Nextcloud notifications.
451451
['name' => 'notes#mention', 'url' => '/api/notes/mention', 'verb' => 'POST'],
452-
// a-case-note-reaches-the-neighbouring-register: sending ONE note to a
453-
// neighbouring ZGW register, as a zaakinformatieobject of a reserved
454-
// type. A deliberate act rather than a hook on save, because note
455-
// storage is OpenRegister's entirely and it dispatches no note-saved
456-
// event dossiq could listen for; `notes#mention` above is called the
457-
// same way, after the note is already stored.
458-
['name' => 'notes#push', 'url' => '/api/cases/{caseId}/notes/push', 'verb' => 'POST'],
459452

460453
// ── Workflow Definitions (workflowTemplate) ─────────────────────
461454
// CRUD on workflowTemplate is served by the manifest renderer +

‎lib/Controller/NotesController.php‎

Lines changed: 0 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
use OCA\Dossiq\Kernel\AppIdentity;
3636
use OCA\Dossiq\Kernel\Contracts\CaseAccessGuardInterface;
3737
use OCA\Dossiq\Kernel\Contracts\MentionNotificationServiceInterface;
38-
use OCA\Dossiq\Kernel\Contracts\NotePushInterface;
3938
use OCA\Dossiq\Service\Notes\MentionedNote;
4039
use OCP\AppFramework\Controller;
4140
use OCP\AppFramework\Http;
@@ -60,7 +59,6 @@ class NotesController extends Controller {
6059
* @param MentionNotificationServiceInterface $mentionSvc The mention notification service
6160
* @param IUserSession $userSession The user session
6261
* @param LoggerInterface $logger The logger
63-
* @param NotePushInterface $notePush Hands a note to integriq for the neighbouring register, or says why it did not
6462
* @param CaseAccessGuardInterface $caseAccessGuard Decides whether the caller may write notes on this case
6563
* @param IUserManager $userManager Tells which mentioned user ids have an account
6664
*/
@@ -69,110 +67,12 @@ public function __construct(
6967
private readonly MentionNotificationServiceInterface $mentionSvc,
7068
private readonly IUserSession $userSession,
7169
private readonly LoggerInterface $logger,
72-
private readonly NotePushInterface $notePush,
7370
private readonly CaseAccessGuardInterface $caseAccessGuard,
7471
private readonly IUserManager $userManager,
7572
) {
7673
parent::__construct(appName: AppIdentity::APP_ID, request: $request);
7774
}//end __construct()
7875

79-
/**
80-
* Send one case note to the neighbouring register, or say why it stayed.
81-
*
82-
* A DELIBERATE ACT RATHER THAN A HOOK ON SAVE, and that is measured rather
83-
* than preferred. Note storage is OpenRegister's entirely (ADR-022): this
84-
* app never reads or writes a note, and OpenRegister dispatches no
85-
* note-saved event dossiq could listen for. `notes#mention` beside this
86-
* method exists for the same reason and works the same way, as a call the
87-
* frontend makes after the note is already stored. Pushing on save needs
88-
* an event that does not exist yet, and that is an openregister row.
89-
*
90-
* The GUARD IS MUTATION, not read. Sending a note to another organisation
91-
* is externally visible and not undoable, so it refuses what a change to
92-
* the case would refuse rather than what reading it would.
93-
*
94-
* @param string $caseId The case the note is on.
95-
*
96-
* @return JSONResponse The outcome, or a refusal.
97-
*
98-
* @spec openspec/specs/zgw-api-mapping/spec.md
99-
*/
100-
#[NoAdminRequired]
101-
public function push(string $caseId): JSONResponse {
102-
$refusal = $this->pushRefusal(caseId: $caseId);
103-
if ($refusal !== null) {
104-
return $refusal;
105-
}
106-
107-
$data = $this->readJsonBody();
108-
$note = $data['note'] ?? null;
109-
if (is_array($note) === false || $note === []) {
110-
return new JSONResponse(['error' => 'A note is required'], Http::STATUS_BAD_REQUEST);
111-
}
112-
113-
return $this->pushNote(caseId: $caseId, note: $note);
114-
}//end push()
115-
116-
/**
117-
* Refuse a push without a session (401), without a case id (400) or by a
118-
* caller who may not change the case (403).
119-
*
120-
* @param string $caseId The case the note is on.
121-
*
122-
* @return JSONResponse|null The refusal, or null when the push may go ahead.
123-
*
124-
* @spec openspec/specs/zgw-api-mapping/spec.md
125-
*/
126-
private function pushRefusal(string $caseId): ?JSONResponse {
127-
$actor = $this->userSession->getUser();
128-
if ($actor === null) {
129-
return new JSONResponse(['error' => 'Not authenticated'], Http::STATUS_UNAUTHORIZED);
130-
}
131-
132-
if (trim($caseId) === '') {
133-
return new JSONResponse(['error' => 'A case id is required'], Http::STATUS_BAD_REQUEST);
134-
}
135-
136-
if ($this->caseAccessGuard->hasCaseMutationAccess(caseId: $caseId, user: $actor) === false) {
137-
return new JSONResponse(['error' => 'Not authorized'], Http::STATUS_FORBIDDEN);
138-
}
139-
140-
return null;
141-
}//end pushRefusal()
142-
143-
/**
144-
* Push the note and answer with its outcome; a push that throws is a logged 500.
145-
*
146-
* @param string $caseId The case the note is on.
147-
* @param array<string, mixed> $note The note.
148-
*
149-
* @return JSONResponse
150-
*
151-
* @spec openspec/specs/zgw-api-mapping/spec.md
152-
*/
153-
private function pushNote(string $caseId, array $note): JSONResponse {
154-
try {
155-
$outcome = $this->notePush->push(caseId: $caseId, note: $note);
156-
} catch (\Throwable $e) {
157-
$this->logger->error(
158-
'NotesController: a note push failed',
159-
['caseId' => $caseId, 'exception' => $e->getMessage()]
160-
);
161-
162-
return new JSONResponse(
163-
['error' => 'The note could not be sent'],
164-
Http::STATUS_INTERNAL_SERVER_ERROR
165-
);
166-
}
167-
168-
// 200 for every outcome INCLUDING a failure, because the caller asked
169-
// what happened and every answer here is a real answer. The outcome is
170-
// in the body, where the notes panel reads it; a 500 for a refused
171-
// push would be this app reporting its own success or failure rather
172-
// than the note's.
173-
return new JSONResponse($outcome);
174-
}//end pushNote()
175-
17676
/**
17777
* Notify every user mentioned in a just-saved note.
17878
*

‎lib/Kernel/Contracts/NotePushInterface.php‎

Lines changed: 0 additions & 49 deletions
This file was deleted.

‎lib/Service/ContractBindings.php‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,6 @@
326326
use OCA\Dossiq\Kernel\Contracts\MoveActionInterface;
327327
use OCA\Dossiq\Kernel\Contracts\MunicipalRoleSetServiceInterface;
328328
use OCA\Dossiq\Kernel\Contracts\NeedsInputDispatcherInterface;
329-
use OCA\Dossiq\Kernel\Contracts\NotePushInterface;
330329
use OCA\Dossiq\Kernel\Contracts\NoticeOfDefaultRowsInterface;
331330
use OCA\Dossiq\Kernel\Contracts\ObjectSchemaSlugResolverInterface;
332331
use OCA\Dossiq\Kernel\Contracts\ObjectTypeCatalogueInterface;
@@ -645,7 +644,6 @@
645644
use OCA\Dossiq\Service\Money\SettlementOverview;
646645
use OCA\Dossiq\Service\Money\SignedPayoutCallback;
647646
use OCA\Dossiq\Service\Money\UnpaidCaseGate;
648-
use OCA\Dossiq\Service\Notes\NotePush;
649647
use OCA\Dossiq\Service\Notice\CaseActNotices;
650648
use OCA\Dossiq\Service\Notification\PlatformEventTemplates;
651649
use OCA\Dossiq\Service\Onboarding\WalkthroughCompletion;
@@ -1145,7 +1143,6 @@ public function register(IRegistrationContext $context): void {
11451143
$context->registerServiceAlias(MoveActionInterface::class, MoveAction::class);
11461144
$context->registerServiceAlias(MunicipalRoleSetServiceInterface::class, MunicipalRoleSetService::class);
11471145
$context->registerServiceAlias(NeedsInputDispatcherInterface::class, NeedsInputDispatcher::class);
1148-
$context->registerServiceAlias(NotePushInterface::class, NotePush::class);
11491146
$context->registerServiceAlias(NoticeOfDefaultRowsInterface::class, NoticeOfDefaultRows::class);
11501147
$context->registerServiceAlias(ObjectSchemaSlugResolverInterface::class, ObjectSchemaSlugResolver::class);
11511148
$context->registerServiceAlias(ObjectTypeCatalogueInterface::class, ObjectTypeCatalogue::class);

‎lib/Service/Notes/NoteAttempt.php‎

Lines changed: 0 additions & 43 deletions
This file was deleted.

0 commit comments

Comments
 (0)