BMO/inbound email

From MozillaWiki
< BMO
Jump to: navigation, search

bmo inbound email

summary

develop a bmo extension that allow users to comment on bugs by replying to bugmail.

bug 44393

limitations

  • allow creation of comments only:
    • no ability to add attachment
    • no ability to change any fields/flags
    • no ability to create bugs
  • editbugs required (initially at least)
  • not valid for bugs where secure-mail is applicable

flow

outbound

  1. skip if the recipient user not a member of the editbugs group
  2. skip if the email is encrypted with securemail (X-Bugzilla-Secure-Email exists)
  3. a unique token is generated for each message which encapsulates:
    • recipient's user-id
    • bug-id
    • token creation timestamp
  4. the message-id is set to <reply-$token@$url_base>
  5. the reply-to header is set to <reply@bugzilla.mozilla.org>
  6. the in-reply-to and references headers are set to <bug-$bug_id-$user_id@$url_base> even for "new bug" email
  7. inject a marker into the text "=== Only text above this line is added to the bug ===" or similar

inbound

  1. extract token from in-reply-to header
  2. load token data from database (user-id, bug-id)
  3. reject if the user is disabled
  4. reject if the user is not a member of the editbugs group
  5. reject if the bug has secure-mail enabled
  6. reject auto replies
    • auto-submitted == auto-generated || auto-replied || auto-notified
    • x-autoreply == yes
  7. extract text/plain content as comment
  8. clean comment
    • remove content after the injected marker
    • remove email signatures
    • remove signing wrappers
    • remove any quoted content at the end of the comment
    • trim whitespace
  9. reject if the comment is emtpy
  10. add comment to bug (no mid-air protection)
  11. delete the token

cleaning junk off the response is by far the most complicated part of this project. an alternative solution which lessens the work here is:

  1. add the following to the top of the email:
    • Type your response ABOVE THIS LINE to reply
  2. ignore all content below that line in the reply

notes

  • tokens can only be used once
  • tokens are valid for 7 days
  • if an error occurs during processing an inbound email with a well-formed in-reply-to header, notification will be sent to the sender's of the email