Class: NotificationServiceWorkers::Sms
- Inherits:
-
ApplicationWorker
- Object
- ApplicationWorker
- NotificationServiceWorkers::Sms
- Defined in:
- app/workers/notification_service_workers/sms.rb
Overview
Sms Worker to shorten URL in a message
Instance Method Summary collapse
-
#perform(msg, phones, opt) ⇒ Object
Example: “` msg = “hello %<url>s” url = “hungryhub.com” output = perform(msg, phones, url: url) # output => “hello https//:hungryhub.com “`.
Methods inherited from ApplicationWorker
Instance Method Details
#perform(msg, phones, opt) ⇒ Object
Example: “` msg = “hello %<url>s” url = “hungryhub.com” output = perform(msg, phones, url: url) # output => “hello https//:hungryhub.com “`
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'app/workers/notification_service_workers/sms.rb', line 19 def perform(msg, phones, opt) = opt.with_indifferent_access reservation_id = .delete(:reservation_id) BUSINESS_LOGGER.set_business_context({ reservation_id: reservation_id }) if reservation_id.present? if Rails.env.development? || IS_STAGING_ENV BUSINESS_LOGGER.info('SMS skipped in development/staging environment. SMS details are logged below:', reservation_id: reservation_id, message: msg, phone_numbers: phones, options: opt) return end url = .delete(:url) if url.present? url = MyUrlShortener.by_url(url) msg = format(CGI.unescapeHTML(msg), url: url) else msg.gsub!('%<url>s', '') end SmsWorker.perform_async(msg.strip, phones, reservation_id) end |