[28.2] Multiple runs of email retrieval on the same emails don't persist again - #11618
Joshua (mynjj) wants to merge 1 commit into
Conversation
Good Sense Reviewer - Round 1Recommendation: Request ChangesWhat this PR doesThis change adds a shared lookup for previously retrieved emails, adds an Email Inbox key, and exposes an attachment overload that can add missing attachments to a received email without modifying the email message. The direction matches the shared email module layer, but the current implementation does not make duplicate creation safe under concurrent retrieval and leaves the attachment guard controlled by a caller-provided flag. Problem-solution fitFit: Partial The code fits the sequential duplicate-retrieval case and adds the shared API pieces needed by the branch. It does not make the duplicate check atomic, and the user-visible retrieval path still depends on the connector-side change in the branch that owns the connector. SuggestionsS1 (🔴 High): Make the duplicate lookup atomic S2 (🔴 High): Validate the attachment bypass inside the implementation Risk assessment and necessityRisk: This area stores retrieved email metadata and customer attachments, and the new methods are public System Application surface. The current CI run also failed the System Application builds in an unchanged file, so I did not anchor that as a code suggestion, but the branch still needs a clean build before merge. Necessity: Avoiding duplicate inbox entries is important because repeated retrieval should not create extra stored emails. The shared API is useful, but it needs the concurrency and guard checks above so the fix does not leave the same data-integrity problem open or weaken received-email immutability.
|
Backport of #11612.
Fix at the email module layer of the bug causing additional entries to be persisted when retrieving the same email.
If the email had already been retrieved and stored, then such email is returned without further persisting, unless the previous email was stored without attachments, in which case only the attachment is added to such email message.
Tested the behavior against my email inbox locally.
Fix overview
FindRetrievedEmailon the email module lets connectors check whether an email had been retrieved before, with the idea of centralizing this potentially tricky logic and benefitting other connectors.AddAttachmentwas needed, since theModifyon the email message that was run after, triggers a subscriber that errors when modifying a received email (rationale of the error is that the system shouldn't modify emails after they have been received, but in this scenario we are not modifying the EmailMessage, but rather adding an attachment and leaving the message as it was, so we don't want this validation to run)Note
In this version the
Email - Outlook REST APIapp does not live in BCApps, so this PR carries the System Application part only. The consuming change in the Outlook connector (Email - Outlook API Helper) has to be done in the NAV repository for this branch.Fixes AB#650461