Remove set of thread variables

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Remove thread vars usage from API notes and mr's

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Replace milestone observer with services

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Send notification emails to the "project", and put people in Cc

This fixes email threading in Mail.app, that doesn't like when a thread
doesn't have stable recipients.

For instance, here is a possible sender-recipient combinations before:

From: A
To: Me
New issue

From: B
To: Me
Reply on new issue

From: A
To: Me
Another reply

Mail.app doesn't see B as a participant to the original email thread,
and decides to break the thread: it will group all messages from A
together, and separately all messages from B.

This commit makes the thread look like this:

From: A
To: gitlab/project
Cc: Me
New issue

From: B
To: gitlab/project
Cc: Me
Reply on new issue

From: A
To: gitlab/project
Cc: Me
Another reply

Mail.app sees a common recipient, and group the thread correctly.
Allow more mail clients to group emails by thread

* send a ‘In-Reply-To’ header along the ‘References’ header
* subject of answers to an existing thread begins with ‘Re: ’

This fixes threading with at least Mail.app and Airmail.
Merge branch 'fix-email-threading' into 'master'

Fix broken email threading

The email threading support introduced in GitLab CE 6.9 is broken on several popular email clients (including Mail.app and Airmail on Mac OS X).

This MR makes the following changes to improve email threading compatibility:

* Subject of answers to an existing thread begins with `Re: ` (required by Mail.app)
* The recipient of every email in a thread is stable (required by Mail.app ; otherwise it groups emails by sender)
* Send a ‘In-Reply-To’ header along the ‘References’ header (for compatibility with the spec)

In order to do this, these commits:

* Change the `To:` field to `namespace/project` ; the actual receiver is now in the `Cc:` field.
* Introduce the `mail_new_thread` and `mail_answer_thread` methods ; they format the message correctly for threading, and can generate the `Message-ID` automatically from a model instance.
* Refactor the tests to shared behaviors for email threading.

We've been using these patches at @capitainetrain for a few months now ; I just ported them to work nicely with the recent threading commits.
Fix milestone reopen

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Fix issue/mr close/reopen via API

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Merge branch 'remove-thread-var' into 'master'

Remove thread variables

Lets get rid of thread variables. It produces additional complexity and weird stack trace.

Also part of !1133

- - -

Also it fixes issue/merge_request close and reopen bug via API when no dashboard event and comment was created.
Merge branch 'master' of gitlab.com:gitlab-org/gitlab-ce