Ejemplo n.º 1
0
  @Transactional
  public static Issue saveIssue(
      String subject,
      Project project,
      User sender,
      Content parsedMessage,
      String messageId,
      Address[] recipients)
      throws MessagingException, IOException, NoSuchAlgorithmException {
    Issue issue = new Issue(project, sender, subject, parsedMessage.body);
    issue.save();

    NotificationEvent event = NotificationEvent.forNewIssue(issue, sender);

    Map<String, Attachment> relatedAttachments =
        saveAttachments(parsedMessage.attachments, issue.asResource());

    if (new ContentType(parsedMessage.type).match(MimeType.HTML)) {
      // replace cid with attachments
      issue.body = replaceCidWithAttachments(issue.body, relatedAttachments);
      issue.update();
    }

    new OriginalEmail(messageId, issue.asResource()).save();

    // Add the event
    addEvent(event, recipients, sender);

    return issue;
  }