6
7
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/communify/controllers/push_notification_controller.rb', line 6
def self.send_push_notification(title, content, recipient, notification_type, other_details, priority = 0)
resource = CommunifyLog.new(title: title, content: content, recipient: recipient.to_s, content_type: 1, priority: priority)
if resource.save
resource.update_column(:status, "Notification Queued at #{DateTime.now}")
time = resource.read_attribute_before_type_cast(:priority)
attempt = 1
result = Communify::Workers::PushNotificationWorker.perform_in(time.minutes.from_now, resource.id, notification_type, other_details, time, attempt)
return resource.id
else
raise "Error => Resource has not been saved!!"
end
end
|