feat(HDNEXT-1010): intercept file-request send-email via IONOS mailer API#17
Open
printminion-co wants to merge 6 commits into
Open
feat(HDNEXT-1010): intercept file-request send-email via IONOS mailer API#17printminion-co wants to merge 6 commits into
printminion-co wants to merge 6 commits into
Conversation
5 tasks
35d3a58 to
f555ea2
Compare
There was a problem hiding this comment.
Pull request overview
Adds support for routing “send-email” (share email resend) requests through the IONOS mailer API by introducing a new listener for BeforeShareMailNotifiedEvent, while also hardening existing share-created handling against empty recipients to prevent IONOS API errors.
Changes:
- Add
BeforeShareMailNotifiedEventListenerto intercept email resend events and forward them toIonosMailerService. - Add an early-return guard in
ShareCreatedEventListenerwhengetSharedWith()is empty. - Extend unit tests and test bootstrap to support the new event (via stub fallback) and validate listener registrations.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
lib/Listener/ShareCreatedEventListener.php |
Adds empty-recipient guard before sending to the mailer service. |
lib/Listener/BeforeShareMailNotifiedEventListener.php |
New listener for resend/send-email flow, sends share-by-link payload via IONOS mailer. |
lib/AppInfo/Application.php |
Registers the new listener in the app bootstrap. |
tests/Listener/ShareCreatedEventListenerTest.php |
Adds unit test for empty-recipient guard behavior. |
tests/Listener/BeforeShareMailNotifiedEventListenerTest.php |
New unit tests for the new listener’s behavior and error paths. |
tests/stubs/BeforeShareMailNotifiedEvent.php |
Provides test-only fallback event class when not available in the runtime. |
tests/bootstrap.php |
Loads the fallback event stub conditionally for unit tests. |
tests/AppInfo/ApplicationTest.php |
Updates expectations to verify both event listener registrations. |
psalm.xml |
Adds the new event stub file to Psalm stubs to satisfy static analysis. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+46
to
+47
| $context->registerEventListener(ShareCreatedEvent::class, ShareCreatedEventListener::class); | ||
| $context->registerEventListener(BeforeShareMailNotifiedEvent::class, BeforeShareMailNotifiedEventListener::class); |
24adfb6 to
892cc4c
Compare
Comment on lines
+16
to
+18
| use OCA\IonosProcesses\Service\IonosMailerService; | ||
| use OCP\EventDispatcher\Event; | ||
| use OCP\Files\Node; |
…lock Signed-off-by: Misha M.-Kupriyanov <kupriyanov@strato.de>
…n composer.lock Signed-off-by: Misha M.-Kupriyanov <kupriyanov@strato.de>
Signed-off-by: Misha M.-Kupriyanov <kupriyanov@strato.de>
…it to version ^8.5.52 || ^9.6.34 in composer.lock Signed-off-by: Misha M.-Kupriyanov <kupriyanov@strato.de>
da3dcb8 to
fbce3b2
Compare
…lSentEventListener (HDNEXT-1010) Delivery is now triggered by BeforeShareMailSentEvent fired from inside ShareByMailProvider.sendEmail() (nc-server PR#262). This covers both Manager::createShare() and the sendShareEmail() Controller path with a single listener — eliminating the previous double-send on regular shares. The event carries pre-computed mail data (senderUserId, fileName, resourceUrl, note, expiration) so the listener no longer needs IUserManager or IURLGenerator injections. markMailHandled() is called unconditionally in every TYPE_EMAIL code path so native Nextcloud SMTP is suppressed in all branches. IONOS send failures propagate as exceptions without falling back to SMTP. Non-TYPE_EMAIL share types are not marked handled — native SMTP still runs for them. Retires ShareCreatedEventListener which caused double-sends when combined with the native sendMailNotification() call in Manager::createShare(). Adds tests/stubs/BeforeShareMailSentEvent.php for CI environments without the nc-server sharebymail app. Adds sharebymail event path to psalm.xml for static analysis.
…NEXT-1010) BeforeShareMailSentEvent now exposes named typed getters (getSenderUserId(), getFileName(), getResourceUrl(), getNote(), getExpiration()) instead of a generic getMailData(): array<string,mixed>. Drop all defensive is_string() / null checks in the listener — types are guaranteed by the event class. Remove testMissingSenderUserIdMarkHandledAndLogsError (the corresponding listener guard no longer exists). Update the CI stub and makeEvent() to use the new constructor shape ($templateData with Nextcloud template-convention key names: 'filename', 'link', 'initiator', … instead of the old camelCase event keys).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces
ShareCreatedEventListenerwithBeforeShareMailSentEventListener— the single handler for all share-by-link email delivery via the IONOS internal mail API.What changed
BeforeShareMailSentEventListenerhandlesBeforeShareMailSentEventfired byShareByMailProvider.sendEmail()(nc-server PR#262). CallsmarkMailHandled()unconditionally in every TYPE_EMAIL code path, suppressing native Nextcloud SMTP.ShareCreatedEventListenercaused double-sends — it called the IONOS API atShareCreatedEventtime while native SMTP also ran viasendMailNotification().IUserManagerandIURLGenerator— the event now carries pre-computedmailData(senderUserId, fileName, resourceUrl, note, expiration).../../apps/sharebymail/lib/Eventas extra files so psalm resolves the event class.BeforeShareMailSentEventstub for CI environments without nc-server.markMailHandled() coverage
Related PRs
Test plan
composer test:unit— 14/14 passcomposer cs:fix— no changescomposer psalm— no errors