Commit ad2e99ff authored by Lee Tickett's avatar Lee Tickett Committed by Mayra Cabrera

Created alias to map issues `service_desk_reply_to` to `external_author`

parent a10b9c9a
...@@ -47,7 +47,7 @@ module Emails ...@@ -47,7 +47,7 @@ module Emails
def service_desk_options(email_sender, email_type) def service_desk_options(email_sender, email_type)
{ {
from: email_sender, from: email_sender,
to: @issue.service_desk_reply_to to: @issue.external_author
}.tap do |options| }.tap do |options|
next unless template_body = template_content(email_type) next unless template_body = template_content(email_type)
......
...@@ -90,6 +90,8 @@ class Issue < ApplicationRecord ...@@ -90,6 +90,8 @@ class Issue < ApplicationRecord
alias_attribute :parent_ids, :project_id alias_attribute :parent_ids, :project_id
alias_method :issuing_parent, :project alias_method :issuing_parent, :project
alias_attribute :external_author, :service_desk_reply_to
scope :in_projects, ->(project_ids) { where(project_id: project_ids) } scope :in_projects, ->(project_ids) { where(project_id: project_ids) }
scope :not_in_projects, ->(project_ids) { where.not(project_id: project_ids) } scope :not_in_projects, ->(project_ids) { where.not(project_id: project_ids) }
......
...@@ -353,7 +353,7 @@ class NotificationService ...@@ -353,7 +353,7 @@ class NotificationService
issue = note.noteable issue = note.noteable
support_bot = User.support_bot support_bot = User.support_bot
return unless issue.service_desk_reply_to.present? return unless issue.external_author.present?
return unless issue.project.service_desk_enabled? return unless issue.project.service_desk_enabled?
return if note.author == support_bot return if note.author == support_bot
return unless issue.subscribed?(support_bot, issue.project) return unless issue.subscribed?(support_bot, issue.project)
......
---
title: Add `external_author` alias to `service_desk_reply_to`
merge_request: 48363
author: Lee Tickett
type: other
...@@ -78,7 +78,7 @@ module Gitlab ...@@ -78,7 +78,7 @@ module Gitlab
title: issue_title, title: issue_title,
description: message_including_template, description: message_including_template,
confidential: true, confidential: true,
service_desk_reply_to: from_address external_author: from_address
).execute ).execute
raise InvalidIssueError unless @issue.persisted? raise InvalidIssueError unless @issue.persisted?
......
...@@ -220,6 +220,7 @@ excluded_attributes: ...@@ -220,6 +220,7 @@ excluded_attributes:
- :duplicated_to_id - :duplicated_to_id
- :promoted_to_epic_id - :promoted_to_epic_id
- :blocking_issues_count - :blocking_issues_count
- :service_desk_reply_to
merge_request: merge_request:
- :milestone_id - :milestone_id
- :sprint_id - :sprint_id
......
...@@ -61,7 +61,7 @@ ...@@ -61,7 +61,7 @@
"lock_version":0, "lock_version":0,
"time_estimate":0, "time_estimate":0,
"relative_position":1073742323, "relative_position":1073742323,
"service_desk_reply_to":null, "external_author":null,
"last_edited_at":null, "last_edited_at":null,
"last_edited_by_id":null, "last_edited_by_id":null,
"discussion_locked":null, "discussion_locked":null,
...@@ -244,7 +244,7 @@ ...@@ -244,7 +244,7 @@
"lock_version":0, "lock_version":0,
"time_estimate":0, "time_estimate":0,
"relative_position":1073742823, "relative_position":1073742823,
"service_desk_reply_to":null, "external_author":null,
"last_edited_at":null, "last_edited_at":null,
"last_edited_by_id":null, "last_edited_by_id":null,
"discussion_locked":null, "discussion_locked":null,
......
...@@ -254,7 +254,7 @@ RSpec.describe Gitlab::Email::Handler::ServiceDeskHandler do ...@@ -254,7 +254,7 @@ RSpec.describe Gitlab::Email::Handler::ServiceDeskHandler do
new_issue = Issue.last new_issue = Issue.last
expect(new_issue.service_desk_reply_to).to eq('finn@adventuretime.ooo') expect(new_issue.external_author).to eq('finn@adventuretime.ooo')
end end
end end
......
...@@ -26,7 +26,7 @@ Issue: ...@@ -26,7 +26,7 @@ Issue:
- weight - weight
- time_estimate - time_estimate
- relative_position - relative_position
- service_desk_reply_to - external_author
- last_edited_at - last_edited_at
- last_edited_by_id - last_edited_by_id
- discussion_locked - discussion_locked
......
...@@ -1284,7 +1284,7 @@ RSpec.describe Notify do ...@@ -1284,7 +1284,7 @@ RSpec.describe Notify do
context 'for service desk issues' do context 'for service desk issues' do
before do before do
issue.update!(service_desk_reply_to: 'service.desk@example.com') issue.update!(external_author: 'service.desk@example.com')
end end
def expect_sender(username) def expect_sender(username)
......
...@@ -353,7 +353,7 @@ RSpec.describe NotificationService, :mailer do ...@@ -353,7 +353,7 @@ RSpec.describe NotificationService, :mailer do
context 'a service-desk issue' do context 'a service-desk issue' do
before do before do
issue.update!(service_desk_reply_to: 'service.desk@example.com') issue.update!(external_author: 'service.desk@example.com')
project.update!(service_desk_enabled: true) project.update!(service_desk_enabled: true)
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment