2016-09-24 11:00:46 +08:00
|
|
|
# frozen_string_literal: true
|
2017-11-25 11:23:47 -08:00
|
|
|
|
2016-04-24 11:50:35 -04:00
|
|
|
class ApplicationMailer < ActionMailer::Base
|
2016-07-26 08:14:23 +08:00
|
|
|
default from: 'team@metamaps.cc'
|
2016-04-24 11:50:35 -04:00
|
|
|
layout 'mailer'
|
2016-11-01 11:18:27 +08:00
|
|
|
|
2016-12-08 14:39:41 -05:00
|
|
|
class << self
|
|
|
|
def mail_for_notification(notification)
|
2017-02-09 16:53:19 -05:00
|
|
|
case notification.notification_code
|
2017-11-25 11:23:47 -08:00
|
|
|
when MAP_ACCESS_REQUEST
|
|
|
|
request = notification.notified_object
|
|
|
|
MapMailer.access_request(request)
|
|
|
|
when MAP_ACCESS_APPROVED
|
|
|
|
request = notification.notified_object
|
|
|
|
MapMailer.access_approved(request)
|
|
|
|
when MAP_INVITE_TO_EDIT
|
|
|
|
user_map = notification.notified_object
|
|
|
|
MapMailer.invite_to_edit(user_map)
|
|
|
|
when TOPIC_ADDED_TO_MAP
|
|
|
|
event = notification.notified_object
|
|
|
|
TopicMailer.added_to_map(event, notification.recipients[0])
|
|
|
|
when TOPIC_CONNECTED_1
|
|
|
|
synapse = notification.notified_object
|
|
|
|
TopicMailer.connected(synapse, synapse.topic1, notification.recipients[0])
|
|
|
|
when TOPIC_CONNECTED_2
|
|
|
|
synapse = notification.notified_object
|
|
|
|
TopicMailer.connected(synapse, synapse.topic2, notification.recipients[0])
|
2016-12-08 14:39:41 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2016-04-24 11:50:35 -04:00
|
|
|
end
|