Skip to content
Snippets Groups Projects
Unverified Commit 75a99ec9 authored by Andrew Fontaine's avatar Andrew Fontaine Committed by Marcin Sedlak-Jakubowski
Browse files

Add state header to notification emails

This is primarily targeted at issuable entities, and unlocks further
email filtering and tagging workflows, by specifying within the email
whether or not the issuable is open/closed/merged.

It can maybe be looked at for other GitLab entities, but for now,
issuable state is enough.

Changelog: added
parent a0b2316e
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -208,6 +208,7 @@ def add_model_headers(object)
 
headers["#{prefix}-ID"] = object.id
headers["#{prefix}-IID"] = object.iid if object.respond_to?(:iid)
headers["#{prefix}-State"] = object.state if object.respond_to?(:state)
end
 
def add_project_headers
Loading
Loading
Loading
Loading
@@ -368,20 +368,21 @@ a merge request or an issue.
 
The following table lists all GitLab-specific email headers:
 
| Header | Description |
| ------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| `List-Id` | The path of the project in an RFC 2919 mailing list identifier. You can use it for email organization with filters. |
| `X-GitLab-(Resource)-ID` | The ID of the resource the notification is for. The resource, for example, can be `Issue`, `MergeRequest`, `Commit`, or another such resource. |
| `X-GitLab-ConfidentialIssue` | The boolean value indicating issue confidentiality for notifications. [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/222908) in GitLab 16.0. |
| `X-GitLab-Discussion-ID` | The ID of the thread the comment belongs to, in notification emails for comments. |
| `X-GitLab-Group-Id` | The group's ID. Only present on notification emails for [epics](../group/epics/index.md). |
| `X-GitLab-Group-Path` | The group's path. Only present on notification emails for [epics](../group/epics/index.md) |
| `X-GitLab-NotificationReason` | The reason for the notification. [See possible values.](#x-gitlab-notificationreason). |
| `X-GitLab-Pipeline-Id` | The ID of the pipeline the notification is for, in notification emails for pipelines. |
| `X-GitLab-Project-Id` | The project's ID. |
| `X-GitLab-Project-Path` | The project's path. |
| `X-GitLab-Project` | The name of the project the notification belongs to. |
| `X-GitLab-Reply-Key` | A unique token to support reply by email. |
| Header | Description |
| ----------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `List-Id` | The path of the project in an RFC 2919 mailing list identifier. You can use it for email organization with filters. |
| `X-GitLab-(Resource)-ID` | The ID of the resource the notification is for. The resource, for example, can be `Issue`, `MergeRequest`, `Commit`, or another such resource. |
| `X-GitLab-(Resource)-State` | The state of the resource the notification is for. The resource can be, for example, `Issue` or `MergeRequest`. The value can be `opened`, `closed`, `merged`, or `locked`. [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/130967) in GitLab 16.4. |
| `X-GitLab-ConfidentialIssue` | The boolean value indicating issue confidentiality for notifications. [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/222908) in GitLab 16.0. |
| `X-GitLab-Discussion-ID` | The ID of the thread the comment belongs to, in notification emails for comments. |
| `X-GitLab-Group-Id` | The group's ID. Only present on notification emails for [epics](../group/epics/index.md). |
| `X-GitLab-Group-Path` | The group's path. Only present on notification emails for [epics](../group/epics/index.md) |
| `X-GitLab-NotificationReason` | The reason for the notification. [See possible values.](#x-gitlab-notificationreason). |
| `X-GitLab-Pipeline-Id` | The ID of the pipeline the notification is for, in notification emails for pipelines. |
| `X-GitLab-Project-Id` | The project's ID. |
| `X-GitLab-Project-Path` | The project's path. |
| `X-GitLab-Project` | The name of the project the notification belongs to. |
| `X-GitLab-Reply-Key` | A unique token to support reply by email. |
 
### X-GitLab-NotificationReason
 
Loading
Loading
Loading
Loading
@@ -54,6 +54,14 @@
expect(subject.header["X-GitLab-#{model.class.name}-IID"]).to eq nil
end
end
it 'has X-GitLab-*-State header if model has state defined' do
if model.respond_to?(:state)
is_expected.to have_header "X-GitLab-#{model.class.name}-State", model.state.to_s
else
expect(subject.header["X-GitLab-#{model.class.name}-State"]).to eq nil
end
end
end
 
RSpec.shared_examples 'an email with X-GitLab headers containing project details' do
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment