2016-09-24 03:00:46 +00:00
|
|
|
# frozen_string_literal: true
|
2016-09-21 17:22:40 +00:00
|
|
|
class UserMap < ApplicationRecord
|
2016-04-24 15:50:35 +00:00
|
|
|
belongs_to :map
|
|
|
|
belongs_to :user
|
2017-02-09 21:53:19 +00:00
|
|
|
belongs_to :access_request
|
|
|
|
|
|
|
|
after_create :after_created_async
|
2016-12-09 16:59:24 +00:00
|
|
|
|
|
|
|
def mark_invite_notifications_as_read
|
2016-12-11 22:29:48 +00:00
|
|
|
Mailboxer::Notification.where(notified_object: self).find_each do |notification|
|
2016-12-09 16:59:24 +00:00
|
|
|
Mailboxer::Receipt.where(notification: notification).update_all(is_read: true)
|
|
|
|
end
|
|
|
|
end
|
2017-02-09 21:53:19 +00:00
|
|
|
|
|
|
|
protected
|
|
|
|
|
|
|
|
def after_created_async
|
|
|
|
if access_request
|
|
|
|
NotificationService.access_approved(self.access_request)
|
|
|
|
else
|
|
|
|
NotificationService.invite_to_edit(self)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
handle_asynchronously :after_created_async
|
2016-04-24 15:50:35 +00:00
|
|
|
end
|