You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by GitBox <gi...@apache.org> on 2021/04/06 04:43:59 UTC

[GitHub] [james-project] vttranlina commented on a change in pull request #365: JAMES-3520 MDN/parse should position forEmailId property

vttranlina commented on a change in pull request #365:
URL: https://github.com/apache/james-project/pull/365#discussion_r607496664



##########
File path: server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/MDNParseMethod.scala
##########
@@ -82,27 +83,30 @@ class MDNParseMethod @Inject()(val blobResolvers: BlobResolvers,
     val invalid: Seq[MDNParseResults] = validations.map(_.left).flatMap(_.toOption)
 
     val parsed: SFlux[MDNParseResults] = SFlux.fromIterable(parsedIds)
-      .flatMap(blobId => toParseResults(blobId, mailboxSession, mdnEmailIdResolver))
+      .flatMap(blobId => toParseResults(blobId, mailboxSession))
 
     SFlux.merge(Seq(parsed, SFlux.fromIterable(invalid)))
       .reduce(MDNParseResults.empty())(MDNParseResults.merge)
       .map(_.asResponse(request.accountId))
   }
 
-  private def toParseResults(blobId: BlobId, mailboxSession: MailboxSession, mdnEmailIdResolver: MDNEmailIdResolver): SMono[MDNParseResults] =
+  private def toParseResults(blobId: BlobId, mailboxSession: MailboxSession): SMono[MDNParseResults] =
     blobResolvers.resolve(blobId, mailboxSession)
       .flatMap(blob => parse(blob.blobId, blob.content)
-        .flatMap(mdnAndMsg =>  {
-          mdnEmailIdResolver.resolveForEmailId(mdnAndMsg._1.getReport.getOriginalMessageIdField.toScala, mdnAndMsg._1.getReport.getFinalRecipientField)
-            .map(messageId => MDNParsed.fromMDN(mdnAndMsg._1, mdnAndMsg._2, messageId))
-            .map(mdnParsed => MDNParseResults.parse(blobId, mdnParsed))
-        }))
+        .flatMap(mdnAndMsg => buildMDNParser(blobId, mdnAndMsg._1, mdnAndMsg._2)))
       .onErrorResume {
         case e: BlobNotFoundException => SMono.just(MDNParseResults.notFound(e.blobId))
         case e: BlobUnParsableException => SMono.just(MDNParseResults.notParse(e.blobId))
         case _ => SMono.just(MDNParseResults.notParse(blobId))
       }
 
+  private def buildMDNParser(blobId: BlobId, mdn: MDN, message: Message): SMono[MDNParseResults] = {
+    val session = mailboxManager.createSystemSession(Username.of(mdn.getReport.getFinalRecipientField.getFinalRecipient.formatted()))

Review comment:
       if we reuse `the mailboxSession passed as a parameter of toParseResults`, we won't get any originalMessageId when `mailboxManager.search` .
   
   




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org