Skip to content
GitLab Next
    • GitLab: the DevOps platform
    • Explore GitLab
    • Install GitLab
    • How GitLab compares
    • Get started
    • GitLab docs
    • GitLab Learn
  • Pricing
  • Talk to an expert
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    • Menu
    Projects Groups Snippets
  • Sign up now
  • Login
  • Sign in / Register
  • GitLab FOSS GitLab FOSS
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
    • Requirements
  • Merge requests 0
    • Merge requests 0
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Container Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Metrics
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • Code review
    • Insights
    • Issue
    • Repository
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar

GitLab 15.0 has launched! Please visit Breaking changes in 15.0 and 15.0 Removals to see which breaking changes may impact your workflow.

  • GitLab.org
  • GitLab FOSSGitLab FOSS
  • Merge requests
  • !16160

Show why a notification email was sent

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Mario de la Ossa requested to merge mdelaossa/gitlab-ce:41532-email-reason into master Dec 29, 2017
  • Overview 72
  • Commits 1
  • Pipelines 11
  • Changes 17

What does this MR do?

Adds #build_notification_recipients to NotificationRecipientService that returns the NotificationRecipient objects in order to be able to access the new attribute reason.

This new attribute is populated inside the #build! method and used in the different notifier methods in order to add the reason as a header: X-GitLab-NotificationReason.

Only the reason with the most priority gets sent, decided by the NotificationRecipientService::Builder::Base::REASON_PRIORITY array.

So far only own_activity and assigned have been implemented. Also implemented is a priority list for each 'reason' in order to send the most relevant/important reason. own_activity gets set from within NotificationRecipient#own_activity? when it is detected that the user

This MR also adds the reason in the footer of email notifications.

Are there points in the code the reviewer needs to double check?

  • NotificationRecipient#reason is a string due to ActiveJob not being able to serialize symbols
  • new_merge_request_worker_spec and new_issue_worker_spec say they're testing "creates a notification for the assignee" but they're really testing a notification for a mentioned user? The assignee(s) relationship is empty/nil.
  • In NotificationRecipientService#build!, when adding assigned notifications for new issues/MRs, I'm adding them at the :participating level since existing specs (notification_service_spec.rb:509) expect it to be at a level below :mention. Is this correct? Shouldn't an assignment count as a mention?

Why was this MR needed?

See #41532 (closed). This allows users to filter their email notifications depending on the reason they were notified.

Screenshots (if relevant)

Does this MR meet the acceptance criteria?

  • Changelog entry added, if necessary
  • Documentation created/updated
  • API support added
  • Tests added for this feature/bug
  • Review
    • Has been reviewed by UX
    • Has been reviewed by Frontend
    • Has been reviewed by Backend
    • Has been reviewed by Database
  • Conform by the merge request performance guides
  • Conform by the style guides
  • Squashed related commits together
  • Internationalization required/considered

What are the relevant issue numbers?

Closes #41532 (closed) and #1366 (closed)

Edited Jan 05, 2018 by Mario de la Ossa
Assignee
Assign to
Reviewer
Request review from
Time tracking
Source branch: 41532-email-reason