Class: Readiness::SupportSuperFormProcessor::Shared

Inherits:
Client
  • Object
show all
Defined in:
lib/support_readiness/support_super_form_processor/shared.rb

Overview

Defines the class Shared within the module Zendesk.

Author:

  • Jason Colyer

Since:

  • 1.0.42

Class Method Summary collapse

Methods inherited from Client

auth_error, bad_request_error, convert_actions, convert_conditions, convert_standard_names_to_ids, convert_ticket_form_agent_conditions, convert_ticket_form_brands, convert_ticket_form_end_user_conditions, convert_ticket_form_names_to_ids, convert_view_names_to_ids, convert_view_restrictions, covert_ticket_form_field_ids, create_package!, erb_renderer, handle_request_error, not_found_error, not_processible_error, put_into_archive, recursively_deflate_directory, timestamp_filename, to_clean_json, to_clean_json_with_key, to_hash, to_nearly_clean_json, to_nearly_clean_json_with_key, to_param_string, write_entries

Class Method Details

.cannot_self_approve(address) ⇒ Object

Sends an email if not a valid Wider Community License request

Parameters:

  • address (String)

    The email addresses used

Author:

  • Jason Colyer

Since:

  • 1.0.42



179
180
181
182
183
184
185
186
187
188
# File 'lib/support_readiness/support_super_form_processor/shared.rb', line 179

def self.cannot_self_approve(address)
  email = Readiness::Mailgun::Emails.new
  email.from = 'GitLab Support <techsupport@gitlab.com>'
  email.to = address
  email.subject = 'Invalid Support Super Form submission'
  email.text = cannot_self_approve_message
  Readiness::Mailgun::Emails.send!(mailgun_client, email)
  puts "Invalid WCL request made by #{address}"
  exit 0
end

.cannot_self_approve_messageString

Returns the email body message when not a valid Wider Community License request

Returns:

  • (String)

Author:

  • Jason Colyer

Since:

  • 1.0.42



436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
# File 'lib/support_readiness/support_super_form_processor/shared.rb', line 436

def self.cannot_self_approve_message
  <<~STRING
    Greetings,

    The Internal Request Form submission you recently filed was not able to be filed due to one of the following issues:

    - You cannot be the approver for community licenses lasting more than 90 days.

    Please rectify the above issues and re-submit your Internal Request via the form.

    Thank you,

    GitLab Support

    Please note this is sent from an unmonitored inbox and replies to it will not be followed up on.
  STRING
end

.generate_mailgun_connectionObject

Generates a Mailgun connection

Returns:

Author:

  • Jason Colyer

Since:

  • 1.0.42



254
255
256
257
258
259
# File 'lib/support_readiness/support_super_form_processor/shared.rb', line 254

def self.generate_mailgun_connection
  mailgun_config = Readiness::Mailgun::Configuration.new
  mailgun_config.domain = 'mg.gitlab.com'
  mailgun_config.token = ENV.fetch('MAILGUN_KEY')
  Readiness::Mailgun::Client.new(mailgun_config)
end

.gitlab_user_check(client, email) ⇒ Object

Performs a gitlab.com user check

Parameters:

  • client (Object)

    An instance of GitLab::Client

  • email (String)

    The email to search for

Author:

  • Jason Colyer

Since:

  • 1.0.42



33
34
35
36
37
38
# File 'lib/support_readiness/support_super_form_processor/shared.rb', line 33

def self.gitlab_user_check(client, email)
  user_search = Readiness::GitLab::Users.search_by_email(client, email)
  requester = user_search.detect { |u| u.email == email }
  no_such_gitlab_user(email) if requester.nil?
  requester
end

.invalid_article_creation(requester, errors) ⇒ Object

Sends an email if not a valid article creation request

Author:

  • Jason Colyer

Since:

  • 1.0.42



195
196
197
198
199
200
201
202
203
204
# File 'lib/support_readiness/support_super_form_processor/shared.rb', line 195

def self.invalid_article_creation(requester, errors)
  email = Readiness::Mailgun::Emails.new
  email.from = 'GitLab Support <techsupport@gitlab.com>'
  email.to = requester.email
  email.subject = 'Invalid Support Super Form submission'
  email.text = invalid_article_creation_message(requester, errors)
  Readiness::Mailgun::Emails.send!(mailgun_client, email)
  puts "Invalid article creation submission by #{requester.email}"
  exit 0
end

.invalid_article_creation_message(requester, errors) ⇒ String

Returns the email body message when not a valid article creation submission

Returns:

  • (String)

Author:

  • Jason Colyer

Since:

  • 1.0.42



460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
# File 'lib/support_readiness/support_super_form_processor/shared.rb', line 460

def self.invalid_article_creation_message(requester, errors)
  <<~STRING
    Greetings @#{requester.username} ,

    Your recent request to create a Zendesk article was not able to be filed due to the following issues:

    #{errors.map { |e| "- #{e}" }.join("\n")}

    Please rectify the above issues and re-submit your request via the form.

    Thank you,

    GitLab Support

    Please note this is sent from an unmonitored inbox and replies to it will not be followed up on.
  STRING
end

.invalid_enable_usgov(requester, errors) ⇒ Object

Sends an email if not a valid enable us gov request

Author:

  • Jason Colyer

Since:

  • 1.0.42



211
212
213
214
215
216
217
218
219
220
# File 'lib/support_readiness/support_super_form_processor/shared.rb', line 211

def self.invalid_enable_usgov(requester, errors)
  email = Readiness::Mailgun::Emails.new
  email.from = 'GitLab Support <techsupport@gitlab.com>'
  email.to = requester.email
  email.subject = 'Invalid Support Super Form submission'
  email.text = invalid_enable_usgov_message(requester, errors)
  Readiness::Mailgun::Emails.send!(mailgun_client, email)
  puts "Invalid enable/disable us gov submission by #{requester.email}"
  exit 0
end

.invalid_enable_usgov_message(requester, errors) ⇒ String

Returns the email body message when not a valid enable us gov submission

Returns:

  • (String)

Author:

  • Jason Colyer

Since:

  • 1.0.42



484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
# File 'lib/support_readiness/support_super_form_processor/shared.rb', line 484

def self.invalid_enable_usgov_message(requester, errors)
  <<~STRING
    Greetings @#{requester.username} ,

    Your recent request to enable/disable US Goverment support was not able to be filed due to the following issues:

    #{errors.map { |e| "- #{e}" }.join("\n")}

    Please rectify the above issues and re-submit your request via the form.

    Thank you,

    GitLab Support

    Please note this is sent from an unmonitored inbox and replies to it will not be followed up on.
  STRING
end

.invalid_namespace(address, namespace) ⇒ Object

Sends an email if the namespace provided was invalid

Parameters:

  • address (String)

    The email addresses used

Author:

  • Jason Colyer

Since:

  • 1.0.42



128
129
130
131
132
133
134
135
136
137
# File 'lib/support_readiness/support_super_form_processor/shared.rb', line 128

def self.invalid_namespace(address, namespace)
  email = Readiness::Mailgun::Emails.new
  email.from = 'GitLab Support <techsupport@gitlab.com>'
  email.to = address
  email.subject = 'Invalid Support Super Form submission'
  email.text = invalid_namespace_message(namespace)
  Readiness::Mailgun::Emails.send!(mailgun_client, email)
  puts "#{address} provided invalid namespace - #{namespace}"
  exit 0
end

.invalid_namespace_message(namespace) ⇒ String

Returns the email body message when the namespace is invalid

Returns:

  • (String)

Author:

  • Jason Colyer

Since:

  • 1.0.42



363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
# File 'lib/support_readiness/support_super_form_processor/shared.rb', line 363

def self.invalid_namespace_message(namespace)
  <<~STRING
    Greetings,

    The Internal Request Form submission you recently filed was not able to be filed due to the following issues:

    - Invalid namespace: '#{namespace}'. Ensure the provided namespace is an existing top-level group, as only those are accepted.

    Please rectify the above issues and re-submit your Internal Request via the form.

    Thank you,

    GitLab Support

    Please note this is sent from an unmonitored inbox and replies to it will not be followed up on.
  STRING
end

.invalid_nfr_request(address) ⇒ Object

Sends an email if not a valid NFR request

Parameters:

  • address (String)

    The email addresses used

Author:

  • Jason Colyer

Since:

  • 1.0.42



162
163
164
165
166
167
168
169
170
171
# File 'lib/support_readiness/support_super_form_processor/shared.rb', line 162

def self.invalid_nfr_request(address)
  email = Readiness::Mailgun::Emails.new
  email.from = 'GitLab Support <techsupport@gitlab.com>'
  email.to = address
  email.subject = 'Invalid Support Super Form submission'
  email.text = invalid_nfr_request_message
  Readiness::Mailgun::Emails.send!(mailgun_client, email)
  puts "Invalid NFR request made by #{address}"
  exit 0
end

.invalid_nfr_request_messageString

Returns the email body message when not a valid NFR request

Returns:

  • (String)

Author:

  • Jason Colyer

Since:

  • 1.0.42



411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
# File 'lib/support_readiness/support_super_form_processor/shared.rb', line 411

def self.invalid_nfr_request_message
  <<~STRING
    Greetings,

    The Internal Request Form submission you recently filed was not able to be filed due to one of the following issues:

    - NFR licenses cannot exceed 25 seats
    - NFR licenses cannot have an expiration more than one year in the future

    Please rectify the above issues and re-submit your Internal Request via the form.

    Thank you,

    GitLab Support

    Please note this is sent from an unmonitored inbox and replies to it will not be followed up on.
  STRING
end

Sends an email if not a valid opportunity link for a gratis request

Author:

  • Jason Colyer

Since:

  • 1.0.65



227
228
229
230
231
232
233
234
235
236
# File 'lib/support_readiness/support_super_form_processor/shared.rb', line 227

def self.invalid_opportunity_link(requester, opportunity_link)
  email = Readiness::Mailgun::Emails.new
  email.from = 'GitLab Support <techsupport@gitlab.com>'
  email.to = requester.email
  email.subject = 'Invalid Support Super Form submission'
  email.text = invalid_opportunity_link_message(requester, opportunity_link)
  Readiness::Mailgun::Emails.send!(mailgun_client, email)
  puts "Invalid opportunity link provided for gratis request by #{requester.email}"
  exit 0
end

Returns the email body message when not a valid SFDC opportunity link for gratis requests

Returns:

  • (String)

Author:

  • Jason Colyer

Since:

  • 1.0.65



508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
# File 'lib/support_readiness/support_super_form_processor/shared.rb', line 508

def self.invalid_opportunity_link_message(requester, opportunity_link)
  <<~STRING
    Greetings @#{requester.username} ,

    Your recent gratis request was not able to be filed due to the following issues:

    - Invalid SFDC opportunity link provided: #{opportunity_link}

    Please rectify the above issues and re-submit your request via the form.

    Thank you,

    GitLab Support

    Please note this is sent from an unmonitored inbox and replies to it will not be followed up on.
  STRING
end

.mailgun_clientObject

Sets a global variable for an instance of Mailgun::Client

Returns:

Author:

  • Jason Colyer

Since:

  • 1.0.42



244
245
246
# File 'lib/support_readiness/support_super_form_processor/shared.rb', line 244

def self.mailgun_client
  @mailgun_client ||= generate_mailgun_connection
end

.namespace_exists?(client, namespace) ⇒ Boolean

Performs a gitlab.com namespace check

Parameters:

  • client (Object)

    An instance of GitLab::Client

  • email (String)

    The email to search for

Returns:

  • (Boolean)

Author:

  • Jason Colyer

Since:

  • 1.0.81



20
21
22
23
24
# File 'lib/support_readiness/support_super_form_processor/shared.rb', line 20

def self.namespace_exists?(client, namespace)
  return Readiness::GitLab::Namespaces.exists?(client, namespace) if namespace.to_i.zero?

  Readiness::GitLab::Namespaces.find(client, namespace).is_a? Readiness::GitLab::Namespaces
end

.no_such_gitlab_user(address) ⇒ Object

Sends an email if a gitlab.com user check fails

Parameters:

  • address (String)

    The email addresses used

Author:

  • Jason Colyer

Since:

  • 1.0.42



60
61
62
63
64
65
66
67
68
69
# File 'lib/support_readiness/support_super_form_processor/shared.rb', line 60

def self.no_such_gitlab_user(address)
  email = Readiness::Mailgun::Emails.new
  email.from = 'GitLab Support <techsupport@gitlab.com>'
  email.to = address
  email.subject = 'Invalid Support Super Form submission'
  email.text = no_such_gitlab_user_message(email)
  Readiness::Mailgun::Emails.send!(mailgun_client, email)
  puts "No such gitlab.com account tied to #{address}"
  exit 0
end

.no_such_gitlab_user_message(email) ⇒ String

Returns the email body message for a failed gitlab.com user check

Returns:

  • (String)

Author:

  • Jason Colyer

Since:

  • 1.0.42



267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
# File 'lib/support_readiness/support_super_form_processor/shared.rb', line 267

def self.no_such_gitlab_user_message(email)
  <<~STRING
    Greetings,

    Recently a Support Super Form submission was made stating the requester email was #{email}.

    We were unable to find a gitlab.com account using that email address as the primary email. As such, the request could not be completed.

    If you have a gitlab.com account using that as a secondary email, please modify your gitlab.com account to make your official GitLab email the primary.

    Once that has been rectified, please re-submit your request.

    Thank you,

    GitLab Support
  STRING
end

.no_such_zendesk_user(address) ⇒ Object

Sends an email if a Zendesk user check fails

Parameters:

  • address (String)

    The email addresses used

Author:

  • Jason Colyer

Since:

  • 1.0.42



77
78
79
80
81
82
83
84
85
86
# File 'lib/support_readiness/support_super_form_processor/shared.rb', line 77

def self.no_such_zendesk_user(address)
  email = Readiness::Mailgun::Emails.new
  email.from = 'GitLab Support <techsupport@gitlab.com>'
  email.to = address
  email.subject = 'Invalid Support Super Form submission'
  email.text = no_such_zendesk_user_message(address)
  Readiness::Mailgun::Emails.send!(mailgun_client, email)
  puts "No such Zendesk account tied to #{address}"
  exit 0
end

.no_such_zendesk_user_message(email) ⇒ String

Returns the email body message for a failed Zendesk user check

Returns:

  • (String)

Author:

  • Jason Colyer

Since:

  • 1.0.42



291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
# File 'lib/support_readiness/support_super_form_processor/shared.rb', line 291

def self.no_such_zendesk_user_message(email)
  <<~STRING
    Greetings,

    The Internal Request Form submission you recently filed was not able to be filed due to the following issues:

    - Invalid Zendesk user: #{email}

    Please rectify the above issues and re-submit your Internal Request via the form.
    
    Thank you,
    
    GitLab Support
    
    Please note this is sent from an unmonitored inbox and replies to it will not be followed up on.
  STRING
end

.not_oem_member(address) ⇒ Object

Sends an email if not an OEM member

Parameters:

  • address (String)

    The email addresses used

Author:

  • Jason Colyer

Since:

  • 1.0.42



94
95
96
97
98
99
100
101
102
103
# File 'lib/support_readiness/support_super_form_processor/shared.rb', line 94

def self.not_oem_member(address)
  email = Readiness::Mailgun::Emails.new
  email.from = 'GitLab Support <techsupport@gitlab.com>'
  email.to = address
  email.subject = 'Invalid Support Super Form submission'
  email.text = not_oem_member_message
  Readiness::Mailgun::Emails.send!(mailgun_client, email)
  puts "Not an OEM member - #{address}"
  exit 0
end

.not_oem_member_messageString

Returns the email body message for a failed OEM check

Returns:

  • (String)

Author:

  • Jason Colyer

Since:

  • 1.0.42



315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
# File 'lib/support_readiness/support_super_form_processor/shared.rb', line 315

def self.not_oem_member_message
  <<~STRING
    Greetings,

    The Internal Request Form submission you recently filed was not able to be filed due to the following issues:

    - You are not a member of the OEM management team.

    Please rectify the above issues and re-submit your Internal Request via the form.
    
    Thank you,
    
    GitLab Support
    
    Please note this is sent from an unmonitored inbox and replies to it will not be followed up on.
  STRING
end

.not_order_management_member(address) ⇒ Object

Sends an email if not an Order Management member

Parameters:

  • address (String)

    The email addresses used

Author:

  • Jason Colyer

Since:

  • 1.0.42



111
112
113
114
115
116
117
118
119
120
# File 'lib/support_readiness/support_super_form_processor/shared.rb', line 111

def self.not_order_management_member(address)
  email = Readiness::Mailgun::Emails.new
  email.from = 'GitLab Support <techsupport@gitlab.com>'
  email.to = address
  email.subject = 'Invalid Support Super Form submission'
  email.text = not_order_management_member_message
  Readiness::Mailgun::Emails.send!(mailgun_client, email)
  puts "Not an Order Management member - #{address}"
  exit 0
end

.not_order_management_member_messageString

Returns the email body message for a failed Order Management check

Returns:

  • (String)

Author:

  • Jason Colyer

Since:

  • 1.0.42



339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
# File 'lib/support_readiness/support_super_form_processor/shared.rb', line 339

def self.not_order_management_member_message
  <<~STRING
    Greetings,

    The Internal Request Form submission you recently filed was not able to be filed due to the following issues:

    - You are not a member of the order management team.

    Please rectify the above issues and re-submit your Internal Request via the form.

    Thank you,

    GitLab Support

    Please note this is sent from an unmonitored inbox and replies to it will not be followed up on.
  STRING
end

.not_partner_support_member(address) ⇒ Object

Sends an email if not an Partner Support member

Parameters:

  • address (String)

    The email addresses used

Author:

  • Jason Colyer

Since:

  • 1.0.42



145
146
147
148
149
150
151
152
153
154
# File 'lib/support_readiness/support_super_form_processor/shared.rb', line 145

def self.not_partner_support_member(address)
  email = Readiness::Mailgun::Emails.new
  email.from = 'GitLab Support <techsupport@gitlab.com>'
  email.to = address
  email.subject = 'Invalid Support Super Form submission'
  email.text = not_partner_support_member_message
  Readiness::Mailgun::Emails.send!(mailgun_client, email)
  puts "Not an Order Management member - #{address}"
  exit 0
end

.not_partner_support_member_messageString

Returns the email body message when not a Partner Supprot member

Returns:

  • (String)

Author:

  • Jason Colyer

Since:

  • 1.0.42



387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
# File 'lib/support_readiness/support_super_form_processor/shared.rb', line 387

def self.not_partner_support_member_message
  <<~STRING
    Greetings,

    The Internal Request Form submission you recently filed was not able to be filed due to the following issues:

    - You are not a member of the partner support team.

    Please rectify the above issues and re-submit your Internal Request via the form.

    Thank you,

    GitLab Support

    Please note this is sent from an unmonitored inbox and replies to it will not be followed up on.
  STRING
end

.sfdc_account_string(link) ⇒ Object

Since:

  • 1.0.42



526
527
528
529
530
531
532
533
534
# File 'lib/support_readiness/support_super_form_processor/shared.rb', line 526

def self.(link)
  id = if link =~ /lightning/
    link.split('/')[-2]
  else
    link.split('/').last
  end
  lightning = "<a href='https://gitlab.lightning.force.com/lightning/r/Account/#{id}/view' target='_blank'>#{id}</a>"
  "SFDC Account: #{lightning}"
end

.sfdc_chattr_string(link) ⇒ Object

Since:

  • 1.0.42



556
557
558
559
560
561
562
563
564
# File 'lib/support_readiness/support_super_form_processor/shared.rb', line 556

def self.sfdc_chattr_string(link)
  id = if link =~ /lightning/
    link.split('/')[-2]
  else
    link.split('/').last
  end
  lightning = "<a href='https://gitlab.lightning.force.com/lightning/r/#{id}/view' target='_blank'>#{id}</a>"
  "Chattr link containing approval: #{lightning}"
end

.sfdc_opportunity_string(link) ⇒ Object

Since:

  • 1.0.42



536
537
538
539
540
541
542
543
544
# File 'lib/support_readiness/support_super_form_processor/shared.rb', line 536

def self.sfdc_opportunity_string(link)
  id = if link =~ /lightning/
    link.split('/')[-2]
  else
    link.split('/').last
  end
  lightning = "<a href='https://gitlab.lightning.force.com/lightning/r/Opportunity/#{id}/view' target='_blank'>#{id}</a>"
  "SFDC Opportunity: #{lightning}"
end

.sfdc_upload_string(link) ⇒ Object

Since:

  • 1.0.42



546
547
548
549
550
551
552
553
554
# File 'lib/support_readiness/support_super_form_processor/shared.rb', line 546

def self.sfdc_upload_string(link)
  id = if link =~ /lightning/
    link.split('/')[-2]
  else
    link.split('/').last
  end
  lightning = "<a href='https://gitlab.lightning.force.com/lightning/r/ContentDocument/#{id}/view' target='_blank'>#{id}</a>"
  "Customer verification proof: #{lightning}"
end

.zendesk_user_check(client, email) ⇒ Object

Performs a Zendesk user check

Parameters:

  • client (Object)

    An instance of GitLab::Client

  • email (String)

    The email to search for

Author:

  • Jason Colyer

Since:

  • 1.0.42



47
48
49
50
51
52
# File 'lib/support_readiness/support_super_form_processor/shared.rb', line 47

def self.zendesk_user_check(client, email)
  user_search = Readiness::Zendesk::Search.users(client, "email:#{email} -role:end-user")
  user = user_search.detect { |u| u.email.downcase == email.downcase }
  no_such_zendesk_user(email) if user.nil?
  user
end