Module: Emails::Imports

Included in:
Notify
Defined in:
app/mailers/emails/imports.rb

Instance Method Summary collapse

Instance Method Details

#bulk_import_complete(user_id, bulk_import_id) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'app/mailers/emails/imports.rb', line 40

def bulk_import_complete(user_id, bulk_import_id)
  user = User.find(user_id)
  @bulk_import = BulkImport.find(bulk_import_id)
  @hostname = @bulk_import.configuration.safe_url
  title = safe_format(
    s_('Import|Import from %{hostname} completed'),
    hostname: @hostname
  )

  email_with_layout(
    to: user.notification_email_or_default,
    subject: subject(title)
  )
end

#bulk_import_csv_user_mapping(user_id, group_id, success_count:, failed_count: 0, skipped_count: 0, failures_csv_data: nil) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'app/mailers/emails/imports.rb', line 55

def bulk_import_csv_user_mapping(
  user_id,
  group_id,
  success_count:,
  failed_count: 0,
  skipped_count: 0,
  failures_csv_data: nil
)
  user = User.find(user_id)
  @group = Group.find(group_id)
  @success_count = success_count
  @failed_count = failed_count
  @skipped_count = skipped_count

  @has_errors = failed_count > 0
  @title = if @has_errors
             s_('BulkImport|Placeholder reassignments completed with errors')
           else
             s_('BulkImport|Placeholder reassignments completed successfully')
           end

  if @has_errors
    filename = "reassignment_failures_#{Time.zone.today.iso8601}.csv"
    attachments[filename] = { content: failures_csv_data, mime_type: 'text/csv' }
  end

  email_with_layout(
    to: user.notification_email_or_default,
    subject: subject(@title)
  )
end

#csv_placeholder_reassignment_failed(user_id, group_id) ⇒ Object



87
88
89
90
91
92
93
94
95
96
# File 'app/mailers/emails/imports.rb', line 87

def csv_placeholder_reassignment_failed(user_id, group_id)
  user = User.find(user_id)
  @group = Group.find(group_id)
  @title = s_('BulkImport|Bulk reassignment failed')

  email_with_layout(
    to: user.notification_email_or_default,
    subject: subject(@title)
  )
end

#github_gists_import_errors_email(user_id, errors) ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'app/mailers/emails/imports.rb', line 5

def github_gists_import_errors_email(user_id, errors)
  @errors = errors
  user = User.find(user_id)

  email_with_layout(
    to: user.notification_email_or_default,
    subject: subject(s_('GithubImporter|GitHub Gists import finished with errors'))
  )
end

#import_source_user_complete(source_user_id) ⇒ Object



125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'app/mailers/emails/imports.rb', line 125

def import_source_user_complete(source_user_id)
  @source_user = Import::SourceUser.find(source_user_id)
  @reassign_to_user = @source_user.reassign_to_user
  # We don't need to check if admin bypass is fully enabled, only if this was sent due to admin or group bypass
  @admin_bypass_enabled = Gitlab::CurrentSettings.allow_bypass_placeholder_confirmation

  title = safe_format(
    s_('UserMapping|Reassignments in %{group} completed'),
    group: @source_user.namespace.full_path
  )

  email_with_layout(
    to: @reassign_to_user.notification_email_or_default,
    subject: subject(title)
  )
end

#import_source_user_reassign(source_user_id) ⇒ Object



98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'app/mailers/emails/imports.rb', line 98

def import_source_user_reassign(source_user_id)
  @source_user = Import::SourceUser.find(source_user_id)
  @reassign_to_user = @source_user.reassign_to_user
  title = safe_format(
    s_('UserMapping|Reassignments in %{group} waiting for review'),
    group: @source_user.namespace.full_path
  )

  email_with_layout(
    to: @reassign_to_user.notification_email_or_default,
    subject: subject(title)
  )
end

#import_source_user_rejected(source_user_id) ⇒ Object



112
113
114
115
116
117
118
119
120
121
122
123
# File 'app/mailers/emails/imports.rb', line 112

def import_source_user_rejected(source_user_id)
  @source_user = Import::SourceUser.find(source_user_id)
  title = safe_format(
    s_('UserMapping|Reassignments in %{group} rejected'),
    group: @source_user.namespace.full_path
  )

  email_with_layout(
    to: @source_user.reassigned_by_user.notification_email_or_default,
    subject: subject(title)
  )
end

#project_import_complete(project_id, user_id, user_mapping_enabled, safe_import_url) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/mailers/emails/imports.rb', line 15

def project_import_complete(project_id, user_id, user_mapping_enabled, safe_import_url)
  user = User.find(user_id)
  @project = Project.find(project_id)
  @namespace = @project.root_ancestor
  @hostname = safe_import_url

  @user_mapping_available = user_mapping_enabled &&
    !@namespace.user_namespace? &&
    !@project.import_failed? &&
    @namespace.import_source_users.awaiting_reassignment.any?

  @is_group_owner = user.can?(:admin_namespace, @namespace)
  @is_project_creator = user_id == @project.creator_id

  title = safe_format(
    s_('Import|Import from %{hostname} completed'),
    hostname: @hostname
  )

  email_with_layout(
    to: user.notification_email_or_default,
    subject: subject(title)
  )
end