{"action":"created","issue":{"url":"https://api.github.com/repos/ivaldi/brimir/issues/265","repository_url":"https://api.github.com/repos/ivaldi/brimir","labels_url":"https://api.github.com/repos/ivaldi/brimir/issues/265/labels{/name}","comments_url":"https://api.github.com/repos/ivaldi/brimir/issues/265/comments","events_url":"https://api.github.com/repos/ivaldi/brimir/issues/265/events","html_url":"https://github.com/ivaldi/brimir/pull/265","id":141732210,"number":265,"title":"Do not notify other clients silently, when a client replies via email.","user":{"login":"fiedl","id":1679688,"avatar_url":"https://avatars.githubusercontent.com/u/1679688?v=3","gravatar_id":"","url":"https://api.github.com/users/fiedl","html_url":"https://github.com/fiedl","followers_url":"https://api.github.com/users/fiedl/followers","following_url":"https://api.github.com/users/fiedl/following{/other_user}","gists_url":"https://api.github.com/users/fiedl/gists{/gist_id}","starred_url":"https://api.github.com/users/fiedl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fiedl/subscriptions","organizations_url":"https://api.github.com/users/fiedl/orgs","repos_url":"https://api.github.com/users/fiedl/repos","events_url":"https://api.github.com/users/fiedl/events{/privacy}","received_events_url":"https://api.github.com/users/fiedl/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-03-17T23:19:20Z","updated_at":"2016-03-18T11:26:19Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/ivaldi/brimir/pulls/265","html_url":"https://github.com/ivaldi/brimir/pull/265","diff_url":"https://github.com/ivaldi/brimir/pull/265.diff","patch_url":"https://github.com/ivaldi/brimir/pull/265.patch"},"body":"This pull request solves https://github.com/ivaldi/brimir/issues/259.\r\n\r\nWhile brimir always stores recipients in `reply#notified_users`, it is not always responsible to deliver these notifications. (https://github.com/ivaldi/brimir/commit/3f05af8905dce36fed9b3c39e408cd5fc4ff2846)\r\n\r\n<img width=\"672\" alt=\"bildschirmfoto 2016-03-17 um 23 36 50\" src=\"https://cloud.githubusercontent.com/assets/1679688/13863676/d2b42b2e-ec9b-11e5-9169-6dc7fe07e460.png\">\r\n\r\nInstead, include the other clients in the `To` field when replying to a client to allow the client to send his reply explicitly to other clients or to refrain from doing so. (https://github.com/ivaldi/brimir/commit/fb3025e0e0a53dc5edf1a939e8d8634006bdac48)\r\n\r\n## Considerations\r\n\r\n### How is the reply sent?\r\n\r\n**(1) The user may reply via the web ui of brimir.**\r\n\r\n   - The ticket system suggests recipients based on the former\r\n     conversation.\r\n   - The user can change the recipients in the web form before\r\n     sending the reply.\r\n\r\n**(2) The user may reply via email to support@example.com.**\r\n\r\n  - The ticket system has to determine who, at least, needs to\r\n    be notified, since the user just writes to support@example.com,\r\n    not to the separate clients or agents.\r\n  - The user might add additional recipients by including them\r\n    in the `To`, `CC` or `BCC` fields in the email client.\r\n\r\n\r\n### Who is sending the reply?\r\n\r\n**(a) The reply author can be an agent.**\r\n\r\n  - Agents can reply to agents and clients via email to\r\n    support@example.com.\r\n  - This mechanism mainly is a convenience shortcut if there is\r\n    only one possible recipient, i.e. the client that\r\n    asked the question.\r\n\r\n**(b) The reply author can be a client.**\r\n\r\n  - Clients can only reply to agents via email to\r\n    support@example.com.\r\n  - This is to make sure that it is always transparent\r\n    who will get the reply.\r\n  - If they need to add other recipients, they can add them\r\n    in the `To`, `CC` or `BCC` field.\r\n\r\n\r\n### Who is added to `notified_users`?\r\n\r\nThe association `Reply#notified_users` saves who has been notified\r\nabout a certain reply.\r\n\r\n**(i) Users that have received a notification through brimir.**\r\n      These can be agents or clients.\r\n\r\n**(ii) Users that are listed in `To` or `CC`** when the reply created\r\n      via email. These notifications are not sent by brimir,\r\n      since these recipients receive emails directly from the\r\n      sender.\r\n\r\n\r\n### Who will be notified by brimir?\r\n\r\n**(a) If the reply author is an agent:**\r\n\r\n  The agent always sends replies through the ticket system, either\r\n  through the web ui (1) or via email to support@example.com (2).\r\n  Thus, the ticket system is responsible to deliver the reply to the\r\n  recipients.\r\n\r\n  ⇒ Send notifications to agents and clients. (1)(a)(i), (2)(a)(i)\r\n\r\n**(b) If the reply author is a client:**\r\n\r\n* (1) Through the web ui, there is no sending email client involved.\r\n\r\n  ⇒ Send notifications to agents and clients. (1)(b)(i)\r\n\r\n* (2) Via email to support@example.com, the clients explicitly sends\r\n         to other clients using the `To`, `CC`, `BCC` fields of his email\r\n         client. Thus, the ticket system is only responsible to deliver\r\n         to the agents.\r\n\r\n    ⇒ Send notifications only to agents. (2)(b)(i)\r\n\r\n\r\n### Who will be listed in `To`, who in `BCC`?\r\n\r\n - (a) In emails to clients, agents are never listed as `To`\r\n         in order not to reveal the private email addresses\r\n         of the agents.\r\n\r\n - (b) In emails to clients, other client-recipients' email addresses\r\n         are listed in `To`. This way, the clients can include\r\n         the other recipients in their replies intentionally.\r\n\r\nIn order to distinguish notifications that are to be delivered through brimir and notifications that are already sent, the other recipients from the `original_message` are added after `reply#notify_users` in the [NotificationMailer](https://github.com/fiedl/brimir/blob/3f05af8905dce36fed9b3c39e408cd5fc4ff2846/app/mailers/notification_mailer.rb#L25L67).\r\n\r\n\r\n### Why is this important.\r\n\r\nFor an example test case, see:\r\n  [ReplyTest#test_should_not_notify_other_clients_when_one_of_the_clients_replies,  test/models/reply_test.rb](https://github.com/ivaldi/brimir/compare/master...fiedl:sf/259-notifications?expand=1#diff-56a15b0c989c4a93a20965dd638478f0R75)\r\n\r\nThe issue is discussed on github:\r\nhttps://github.com/ivaldi/brimir/issues/259\r\n\r\n## Notable changes\r\n\r\n* (https://github.com/ivaldi/brimir/commit/fb3025e0e0a53dc5edf1a939e8d8634006bdac48) **notification mailer: Include other clients in the `To` email field.**\r\n\r\n  To allow clients to choose to which other clients they would like to\r\n  reply, include other clients in the `To` email field.\r\n  \r\n  Agents are not included in the `To` email field to prevent their\r\n  personal email addresses from becoming public.\r\n* (https://github.com/ivaldi/brimir/commit/3f05af8905dce36fed9b3c39e408cd5fc4ff2846) **Do not notify other clients silently, when a client replies via email.**"},"comment":{"url":"https://api.github.com/repos/ivaldi/brimir/issues/comments/198314737","html_url":"https://github.com/ivaldi/brimir/pull/265#issuecomment-198314737","issue_url":"https://api.github.com/repos/ivaldi/brimir/issues/265","id":198314737,"user":{"login":"frenkel","id":121169,"avatar_url":"https://avatars.githubusercontent.com/u/121169?v=3","gravatar_id":"","url":"https://api.github.com/users/frenkel","html_url":"https://github.com/frenkel","followers_url":"https://api.github.com/users/frenkel/followers","following_url":"https://api.github.com/users/frenkel/following{/other_user}","gists_url":"https://api.github.com/users/frenkel/gists{/gist_id}","starred_url":"https://api.github.com/users/frenkel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/frenkel/subscriptions","organizations_url":"https://api.github.com/users/frenkel/orgs","repos_url":"https://api.github.com/users/frenkel/repos","events_url":"https://api.github.com/users/frenkel/events{/privacy}","received_events_url":"https://api.github.com/users/frenkel/received_events","type":"User","site_admin":false},"created_at":"2016-03-18T11:26:19Z","updated_at":"2016-03-18T11:26:19Z","body":"Thanks for your thorough explanation. This solution seems great indeed, I'll test it today.\r\n\r\nYes, we need that message_id and it causes us all kinds of headache. I believe it is possible to manually set the message_id, so we might indeed set it beforehand and store it with the reply. It looks like the mail gem even has code to generate the message_id: https://github.com/mikel/mail/blob/6343e70be5ef5cc373f460933477fb1a6d751bf8/lib/mail/fields/message_id_field.rb\r\n\r\nWould you be able to refactor it and move the mail sending out of the model?\r\n\r\nThanks again!"}}