[MGNLREST-301] E-Mail attachments get ignored via commands endpoint Created: 23/Mar/21  Updated: 23/Mar/21

Status: Open
Project: Magnolia REST Framework
Component/s: tools
Affects Version/s: 2.2.6
Fix Version/s: None

Type: Bug Priority: Neutral
Reporter: Tobias Kerschbaum Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled

 Description   

Our partner acdsolutions reported a bug in the commands endpoint. I was able to reproduce it and I think this is a problem related to the commands endpoint.

Steps to reproduce

  1.  Start any Magnolia 6.2.6
  2.  Add the sendMail command under /modules/rest-services/rest-endpoints/commands/enabledCommands
  3. Try to send a mail via the endpoint

Example request:

http://localhost:8080/.rest/commands/v2/default/sendMail

{
  "type": "freemarker",
  "contentType": "html",
  "from":"tobias.kerschbaum@magnolia-cms.com",
  "subject":"subject",
  "to":"tobias.kerschbaum@magnolia-cms.com",
  "templateFile":"",
  "body":"mail body",
  "attachments":[
    {
      "url":"http://designermag.org/wp-content/uploads/2013/09/Awesome-Animal-Logo-Design.jpg",
      "name":"test",
      "fileName":"test",
      "contentType":"image/jpeg",
      "disposition":"attachment",
      "mimeMultipart":"multipart/mixed"
    }
  ]    
}

 

Expected results

The E-Mail gets send with an attachment.

Actual results

E-Mail is sent but without attachment.

Workaround

Development notes

I debugged the behaviour and I think the problem is as follows:

  • The MailCommand line 106 expects a WebContext in order to check any attachments
  • The CommandManager has a method with and one without an actual context. If no context is set a SimpleContext is created.
  • The CommandEndpoint calls the excuses always without context.

Generated at Mon Feb 12 06:58:34 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.