Commit 9f4f9ad4 authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch 'remove_sdesk_ff' into 'master'

Remove customer service_desk_custom_address flag

See merge request gitlab-org/gitlab!51202
parents 3da55ba8 511f9415
...@@ -2491,16 +2491,12 @@ class Project < ApplicationRecord ...@@ -2491,16 +2491,12 @@ class Project < ApplicationRecord
end end
def service_desk_custom_address def service_desk_custom_address
return unless service_desk_custom_address_enabled? return unless Gitlab::ServiceDeskEmail.enabled?
key = service_desk_setting&.project_key key = service_desk_setting&.project_key
return unless key.present? return unless key.present?
::Gitlab::ServiceDeskEmail.address_for_key("#{full_path_slug}-#{key}") Gitlab::ServiceDeskEmail.address_for_key("#{full_path_slug}-#{key}")
end
def service_desk_custom_address_enabled?
::Gitlab::ServiceDeskEmail.enabled? && ::Feature.enabled?(:service_desk_custom_address, self, default_enabled: true)
end end
def root_namespace def root_namespace
......
...@@ -5,10 +5,6 @@ module ServiceDeskSettings ...@@ -5,10 +5,6 @@ module ServiceDeskSettings
def execute def execute
settings = ServiceDeskSetting.safe_find_or_create_by!(project_id: project.id) settings = ServiceDeskSetting.safe_find_or_create_by!(project_id: project.id)
unless ::Feature.enabled?(:service_desk_custom_address, project, default_enabled: true)
params.delete(:project_key)
end
params[:project_key] = nil if params[:project_key].blank? params[:project_key] = nil if params[:project_key].blank?
if settings.update(params) if settings.update(params)
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
enabled: "#{@project.service_desk_enabled}", enabled: "#{@project.service_desk_enabled}",
incoming_email: (@project.service_desk_incoming_address if @project.service_desk_enabled), incoming_email: (@project.service_desk_incoming_address if @project.service_desk_enabled),
custom_email: (@project.service_desk_custom_address if @project.service_desk_enabled), custom_email: (@project.service_desk_custom_address if @project.service_desk_enabled),
custom_email_enabled: "#{@project.service_desk_custom_address_enabled?}", custom_email_enabled: "#{Gitlab::ServiceDeskEmail.enabled?}",
selected_template: "#{@project.service_desk_setting&.issue_template_key}", selected_template: "#{@project.service_desk_setting&.issue_template_key}",
outgoing_name: "#{@project.service_desk_setting&.outgoing_name}", outgoing_name: "#{@project.service_desk_setting&.outgoing_name}",
project_key: "#{@project.service_desk_setting&.project_key}", project_key: "#{@project.service_desk_setting&.project_key}",
......
---
name: service_desk_custom_address
introduced_by_url:
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/284656
milestone:
type: development
group: group::certify
default_enabled: true
...@@ -140,15 +140,12 @@ To edit the custom email display name: ...@@ -140,15 +140,12 @@ To edit the custom email display name:
### Using custom email address ### Using custom email address
> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/2201) in [GitLab Premium](https://about.gitlab.com/pricing/) 13.0. > - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/2201) in [GitLab Premium](https://about.gitlab.com/pricing/) 13.0.
> - It was [deployed behind a feature flag](../feature_flags.md), disabled by default. > - [Feature flag removed](https://gitlab.com/gitlab-org/gitlab/-/issues/284656) in GitLab 13.8.
> - [Became enabled by default](https://gitlab.com/gitlab-org/gitlab/-/issues/284656) on GitLab 13.7.
> - It's enabled on GitLab.com.
> - It's recommended for production use.
> - For GitLab self-managed instances, GitLab administrators can opt to [disable it](#disable-custom-email-address). **(CORE ONLY)**
If the `service_desk_email` feature flag is enabled, then you can If the `service_desk_email` is configured, then you can create Service Desk
create Service Desk issues by sending emails to the Service Desk email address. issues by sending emails to the Service Desk email address. The default
The default address has the following format: `project_contact+%{key}@example.com`. address has the following format:
`project_contact+%{key}@example.com`.
The `%{key}` part is used to find the project where the issue should be created. The The `%{key}` part is used to find the project where the issue should be created. The
`%{key}` part combines the path to the project and configurable project name suffix: `%{key}` part combines the path to the project and configurable project name suffix:
...@@ -163,7 +160,7 @@ always use separate mailboxes. This is important, because emails picked from ...@@ -163,7 +160,7 @@ always use separate mailboxes. This is important, because emails picked from
`service_desk_email` mailbox are processed by a different worker and it would `service_desk_email` mailbox are processed by a different worker and it would
not recognize `incoming_email` emails. not recognize `incoming_email` emails.
You can add the following snippets to your configuration: To configure a custom email address for Service Desk, add the following snippets to your configuration file:
- Example for installations from source: - Example for installations from source:
...@@ -216,23 +213,6 @@ As a result, a new Service Desk issue is created from this email in the `mygroup ...@@ -216,23 +213,6 @@ As a result, a new Service Desk issue is created from this email in the `mygroup
The configuration options are the same as for configuring The configuration options are the same as for configuring
[incoming email](../../administration/incoming_email.md#set-it-up). [incoming email](../../administration/incoming_email.md#set-it-up).
#### Disable custom email address **(CORE ONLY)**
Service Desk custom email is under development but ready for production use.
It is deployed behind a feature flag that is **enabled by default**.
To disable it:
```ruby
Feature.disable(:service_desk_custom_address)
```
To enable it:
```ruby
Feature.enable(:service_desk_custom_address)
```
## Using Service Desk ## Using Service Desk
There are a few ways Service Desk can be used. There are a few ways Service Desk can be used.
......
...@@ -68,7 +68,7 @@ module Gitlab ...@@ -68,7 +68,7 @@ module Gitlab
end end
def valid_project_key?(project, slug) def valid_project_key?(project, slug)
project.present? && slug == project.full_path_slug && Feature.enabled?(:service_desk_custom_address, project, default_enabled: true) project.present? && slug == project.full_path_slug
end end
def create_issue! def create_issue!
......
...@@ -191,16 +191,6 @@ RSpec.describe Gitlab::Email::Handler::ServiceDeskHandler do ...@@ -191,16 +191,6 @@ RSpec.describe Gitlab::Email::Handler::ServiceDeskHandler do
expect { receiver.execute }.to raise_error(Gitlab::Email::ProjectNotFound) expect { receiver.execute }.to raise_error(Gitlab::Email::ProjectNotFound)
end end
end end
context 'when service_desk_custom_address feature is disabled' do
before do
stub_feature_flags(service_desk_custom_address: false)
end
it 'bounces the email' do
expect { receiver.execute }.to raise_error(Gitlab::Email::ProjectNotFound)
end
end
end end
end end
......
...@@ -1499,63 +1499,13 @@ RSpec.describe Project, factory_default: :keep do ...@@ -1499,63 +1499,13 @@ RSpec.describe Project, factory_default: :keep do
allow(::Gitlab::ServiceDeskEmail).to receive(:config).and_return(config) allow(::Gitlab::ServiceDeskEmail).to receive(:config).and_return(config)
end end
context 'when service_desk_custom_address flag is enabled' do it 'returns custom address when project_key is set' do
before do create(:service_desk_setting, project: project, project_key: 'key1')
stub_feature_flags(service_desk_custom_address: true)
end
it 'returns custom address when project_key is set' do
create(:service_desk_setting, project: project, project_key: 'key1')
expect(subject).to eq("foo+#{project.full_path_slug}-key1@bar.com")
end
it_behaves_like 'with incoming email address'
end
context 'when service_desk_custom_address flag is disabled' do
before do
stub_feature_flags(service_desk_custom_address: false)
end
it_behaves_like 'with incoming email address'
end
end
end
describe '.service_desk_custom_address_enabled?' do
let_it_be(:project) { create(:project, service_desk_enabled: true) }
subject(:address_enabled) { project.service_desk_custom_address_enabled? }
context 'when service_desk_email is enabled' do
before do
allow(::Gitlab::ServiceDeskEmail).to receive(:enabled?).and_return(true)
end
it 'returns true' do
expect(address_enabled).to be_truthy
end
context 'when service_desk_custom_address flag is disabled' do
before do
stub_feature_flags(service_desk_custom_address: false)
end
it 'returns false' do
expect(address_enabled).to be_falsey
end
end
end
context 'when service_desk_email is disabled' do expect(subject).to eq("foo+#{project.full_path_slug}-key1@bar.com")
before do
allow(::Gitlab::ServiceDeskEmail).to receive(:enabled?).and_return(false)
end end
it 'returns false when service_desk_email is disabled' do it_behaves_like 'with incoming email address'
expect(address_enabled).to be_falsey
end
end end
end end
......
...@@ -16,19 +16,6 @@ RSpec.describe ServiceDeskSettings::UpdateService do ...@@ -16,19 +16,6 @@ RSpec.describe ServiceDeskSettings::UpdateService do
expect(settings.reload.outgoing_name).to eq 'some name' expect(settings.reload.outgoing_name).to eq 'some name'
expect(settings.reload.project_key).to eq 'foo' expect(settings.reload.project_key).to eq 'foo'
end end
context 'when service_desk_custom_address is disabled' do
before do
stub_feature_flags(service_desk_custom_address: false)
end
it 'ignores project_key parameter' do
result = described_class.new(settings.project, user, params).execute
expect(result[:status]).to eq :success
expect(settings.reload.project_key).to be_nil
end
end
end end
context 'when project_key is an empty string' do context 'when project_key is an empty string' do
......
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