Skip to content

feat(filinq): build letter-email-sending - #2192

Open
rubenvdlinde wants to merge 2 commits into
developmentfrom
quality/build-letter-email-sending
Open

rubenvdlinde wants to merge 2 commits into
developmentfrom
quality/build-letter-email-sending

Conversation

@rubenvdlinde

Copy link
Copy Markdown
Contributor

Builds openspec/changes/letter-email-sending: an officer can send a composed letter by email, and the send is recorded.

Tasks done

  • Task 1, send and log. CorrespondenceService::compose() is the composing half of generate() (generate() still logs as before), and logSent() writes the send's entry. CorrespondenceSendService::send() reads the recipient, composes the email body (and, when asked, the PDF of the same letter), sends through IMailer and logs one correspondence entry: sent with sentAt, sentTo and sentBy, or failed with the reason. Schema correspondence 1.4.0 (sent status, three fields), register 8.73.0, app version moved.
  • Task 2, refusals and failures. A request that names no recipient gets 400. A recipient the caller cannot read gets 404, before anything is composed. A recipient without an email address, or an instance whose mail mode is null, gets 422 with a message that names the cause. If the mailer throws or refuses the address, the send is logged as failed and the route answers 502 with a plain sentence and no server details. Routes correspondence#send and correspondence#sendPreview (#[NoAdminRequired]) are added to openapi.json.
  • Task 3, the Correspondence page. A "Send by email" button opens src/dialogs/CorrespondenceSendDialog.vue. The dialog asks the preview route for the address and subject (it gives the same refusals as a send) and has a PDF checkbox. On confirm, the store's sendByEmail() sends and the page shows "Sent to {address}". A refused send keeps the dialog open with the reason.

Tasks left, and why

  • Task 4, email-leaf link. OpenRegister's email leaf links Nextcloud Mail messages by mail account and message id (EmailLinkService::linkEmail(LinkTarget, EmailMessageRef)). A message sent through IMailer has neither, so there is nothing to link. The send does not touch the leaf, which is the absent-leaf behaviour the task's criterion asks for. Linking needs either sending through the Mail app or an OpenRegister link type for outbound mail.
  • Task 5, e2e against a dev mail catcher, and the parity row. Live work, not run here.

Tests added

  • tests/unit/Service/CorrespondenceServiceSendTest.php (10): runs the real CorrespondenceService and CorrespondenceSendService over a doubled mailer, object store and renderer. Covers one message to the address with the composed body, one sent entry with who and when, the PDF attachment, no address (422), unreadable recipient (404, nothing composed), failing read, no recipient (400), no mail server (422), a mailer that throws (failed with the reason), a refused address, and the preview. Mutation check: dropping the mail-server guard makes testNoMailServerIsRefused fail.
  • tests/unit/Controller/CorrespondenceControllerSendTest.php (7): 201, 502, 422, 404, 401, the preview, and the route attributes.
  • jest: src/dialogs/CorrespondenceSendDialog.spec.js (6) and src/store/modules/correspondence.spec.js (4).

Suite

  • PHPUnit (unit): development 7288 tests, 0 failures. This branch: 7305 tests, 0 failures (6 skipped, as on development).
  • vitest: 857 passed. jest: all suites passed.
  • phpcs and phpstan are clean on the changed lib files, and phpmd reports nothing. psalm's two errors on CorrespondenceService are the same ObjectSaveOptions/ObjectFindTarget stub errors development has.
  • check:schema-l10n: 318 uncovered strings on development and 318 on this branch, so this change adds none. All new UI and schema strings are in en and nl.

Generated by Claude Code

Send a composed letter by email: POST api/correspondence/send composes the
letter as an email, attaches the PDF of the same letter when asked, sends it
through Nextcloud's mailer to the address on the recipient object and logs
one correspondence entry (sent with sentAt, sentTo and sentBy, or failed with
the reason). A recipient the caller cannot read is a 404, a recipient without
an address or an instance without a mail server a 422, before anything is
composed. The Correspondence page gets a Send by email button and a confirm
dialog that previews the address and subject.

Assisted-by: ClaudeCode:claude-opus-5-5
Conflicts only in the app version and the register description; both lines' schemas kept, register bumped to 8.74.0.

Assisted-by: ClaudeCode:claude-opus-5-5

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant