Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Skip creation email when inline creating from the shareWP modal. Instead show an additional note in the Sharing Mail

Henriette Darge4a6fd00ce3c7
diff --git a/app/controllers/concerns/member_creation.rb b/app/controllers/concerns/member_creation.rb
index 3a1f0411a72..2ee87f7a8d1 100644
--- a/app/controllers/concerns/member_creation.rb
+++ b/app/controllers/concerns/member_creation.rb
@@ -29,7 +29,8 @@
module MemberCreation
module_function
- def create_members
+ def create_members(send_notification: true)
+ @send_notification = send_notification
overall_result = nil
each_new_member_param do |member_params|
@@ -60,17 +61,17 @@ module MemberCreation
end
def user_ids_for_new_members(member_params)
- invite_new_users possibly_separated_ids_for_entity(member_params, :user)
+ invite_new_users possibly_separated_ids_for_entity(member_params, :user), send_notification: @send_notification
end
- def invite_new_users(user_ids)
+ def invite_new_users(user_ids, send_notification: true)
user_ids.filter_map do |id|
if id.to_i == 0 && id.present? # we've got an email - invite that user
# Only users with the create_user permission can add users.
if current_user.allowed_globally?(:create_user) && enterprise_allow_new_users?
# The invitation can pretty much only fail due to the user already
# having been invited. So look them up if it does.
- user = UserInvitation.invite_new_user(email: id) ||
+ user = UserInvitation.invite_new_user(email: id, send_notification:) ||
User.find_by_mail(id)
user&.id
diff --git a/app/controllers/concerns/user_invitation.rb b/app/controllers/concerns/user_invitation.rb
index f84792640e2..67d2209362d 100644
--- a/app/controllers/concerns/user_invitation.rb
+++ b/app/controllers/concerns/user_invitation.rb
@@ -54,7 +54,7 @@ module UserInvitation
# @return The invited user. If the invitation failed, calling `#registered?`
# on the returned user will yield `false`. Check for validation errors
# in that case.
- def invite_new_user(email:, login: nil, first_name: nil, last_name: nil)
+ def invite_new_user(email:, login: nil, first_name: nil, last_name: nil, send_notification: true)
attributes = {
mail: email,
login:,
@@ -67,7 +67,7 @@ module UserInvitation
yield user if block_given?
- invite_user! user
+ invite_user! user, send_notification:
end
##
@@ -114,10 +114,10 @@ module UserInvitation
# Validates and saves the given user. The invitation will fail if the user is invalid.
#
# @return The invited user or nil if the invitation failed.
- def invite_user!(user)
+ def invite_user!(user, send_notification: true)
user, token = user_invitation user
- if token
+ if token && send_notification
OpenProject::Notifications.send(Events.user_invited, token)
user
diff --git a/app/controllers/work_packages/shares_controller.rb b/app/controllers/work_packages/shares_controller.rb
index adfad96bbeb..2d220b5fb7c 100644
--- a/app/controllers/work_packages/shares_controller.rb
+++ b/app/controllers/work_packages/shares_controller.rb
@@ -44,7 +44,7 @@ class WorkPackages::SharesController < ApplicationController
# In case, the user does not exist yet: create one
if user_id.to_i == 0
- service_call = create_members
+ service_call = create_members(send_notification: false)
user_id = service_call.result.user_id
end
diff --git a/app/views/sharing_mailer/shared_work_package.html.erb b/app/views/sharing_mailer/shared_work_package.html.erb
index b8d08e4d1c3..82d5aec8679 100644
--- a/app/views/sharing_mailer/shared_work_package.html.erb
+++ b/app/views/sharing_mailer/shared_work_package.html.erb
@@ -48,6 +48,19 @@
<%= render partial: 'mailer/notification_settings_table' %>
+ <% if @shared_with_user.invited? %>
+ <table <%= placeholder_table_styles(width:'100%',style: 'width:100%;') %>>
+ <tr>
+ <%= placeholder_cell('20px', vertical: false) %>
+ </tr>
+ <tr>
+ <td style="color: #333333;font-size: 16px;">
+ <%= t('mail.sharing.work_packages.create_account', instance: Setting.app_title).html_safe %>
+ </td>
+ </tr>
+ </table>
+ <% end %>
+
<table>
<tr>
<%= placeholder_cell('40px', vertical: false) %>
diff --git a/config/locales/en.yml b/config/locales/en.yml
index d9e64f1bb54..987dce43691 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -2287,6 +2287,7 @@ en:
sharing:
work_packages:
allowed_actions: 'You may %{allowed_actions} this work package. This can change depending on your project role and permissions.'
+ create_account: 'To access this work package you will need to create an %{instance} account. '
open_work_package: 'Open work package'
see_in_open_project: 'See work package in OpenProject'
subject: 'You have been shared work package #%{id}'
diff --git a/spec/features/work_packages/share_spec.rb b/spec/features/work_packages/share_spec.rb
index b22d16d1958..05188bf7b0f 100644
--- a/spec/features/work_packages/share_spec.rb
+++ b/spec/features/work_packages/share_spec.rb
@@ -301,9 +301,9 @@ RSpec.describe 'Work package sharing',
new_user = User.last
share_modal.expect_shared_with(new_user, 'View', position: 1)
- # perform_enqueued_jobs
+ perform_enqueued_jobs
# Only one combined email for create and share should be send out
- # expect(ActionMailer::Base.deliveries.size).to eq(1)
+ expect(ActionMailer::Base.deliveries.size).to eq(1)
end
end