Send email to user after placeholder contribution reassignment when confirmation is skipped (through either group and admin bypass)

What does this MR do and why?

This merge request adds a new email notification that's sent to a user after they have been reassigned placeholder contributions without their consent. Without this email or an email asking them to confirm their contributions, there's no other notification to a user that they have been reassigned contributions and memberships in a group.

References

Screenshots or screen recordings

HTML email:

image

Plain text email:

image

How to set up and validate locally

Actually sending an email after bypassing reassignment

  1. Enable the importer_user_mapping_allow_bypass_of_confirmation and turn on the "Skip confirmation when reassigning placeholder users" admin setting
  2. Perform an import with user contributions to generate placeholder users if there are none awaiting reassignment
  3. Reassign a placeholder user to a real user
  4. The reassigned user should receive the email added in this MR once all contributions have been reassigned. If the user is not active, they should not receive this email.

Note: To view the email sent by the application, the simplest way is to use Letter Opener at /rails/letter_opener

Using notify previews

  1. Perform an import with user contributions to generate placeholder users if there are none awaiting reassignment. This can also be done via the console instead of performing an import:
Gitlab::Import::SourceUserMapper.new(
  namespace: # top-level namespace of your choice (must be top-level and not a personal namespace),
  import_type: Import::SOURCE_DIRECT_TRANSFER,
  source_hostname: 'http://gdk.test:3000'
).find_or_create_source_user(
  source_name: 'Dr. Source User',
  source_username: 'expert_source_user',
  source_user_identifier: 1,
  cache: false
)
  1. Ensure that the last Import::SourceUser has a reassign_to_user. This can be done by reassigning a real user to the last placeholder user created in the UI regardless of the admin bypass setting or feature flag state. Or via the console:
admin = User.where(admin: true).first
assignee = User.human.active.last
Import::SourceUsers::ReassignService.new(Import::SourceUser.last, assignee, current_user: admin).execute
  1. Visit the /rails/mailers/notify/import_source_user_complete path in your local environment
  2. View what the new email would look like in HTML or plain text for your last without going through the reassign process.

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #534334 (closed)

Edited by Sam Word

Merge request reports

Loading