2016-12-16 21:51:52 +00:00
|
|
|
# frozen_string_literal: true
|
2017-11-25 19:23:47 +00:00
|
|
|
|
2017-01-24 00:30:13 +00:00
|
|
|
module Events
|
|
|
|
class TopicAddedToMap < Event
|
2017-02-11 05:20:42 +00:00
|
|
|
after_create :notify_users!
|
2016-12-16 21:51:52 +00:00
|
|
|
|
2017-01-24 00:30:13 +00:00
|
|
|
def self.publish!(topic, map, user, meta)
|
|
|
|
create!(kind: 'topic_added_to_map',
|
|
|
|
eventable: topic,
|
|
|
|
map: map,
|
|
|
|
user: user,
|
|
|
|
meta: meta)
|
|
|
|
end
|
2017-11-25 19:23:47 +00:00
|
|
|
|
2017-02-11 05:20:42 +00:00
|
|
|
def notify_users!
|
|
|
|
# in the future, notify followers of both the topic, and the map
|
|
|
|
NotificationService.notify_followers(eventable, TOPIC_ADDED_TO_MAP, self)
|
|
|
|
# NotificationService.notify_followers(map, MAP_RECEIVED_TOPIC, self)
|
|
|
|
end
|
|
|
|
handle_asynchronously :notify_users!
|
2016-12-16 21:51:52 +00:00
|
|
|
end
|
|
|
|
end
|