docbrown/app/services/read_notifications_service.rb
Andy Zhao 5ace9a5fc9 Organization Notifications (#1762)
* Add spec for org reaction notification

* Add organization_id to notifications

* Add validations for user and org IDs

* Move comment json_data out of loop

* Use actual column names instead

* Add organization filters

* Remove extra text-align

* Add organization filtering

* Refactor to reduce complexity

* Add receiver argument to handle orgs

* Add has_many notifications for orgs

* Add follow notifications for orgs

* Add comment notifications for orgs

* Rename some tests for specificity

* Add mark org notifications as read functionality

* Add radix to parseInt

* Define json_data outside of loop

* Notify org followers of a new post as well

* Move test to proper location

* Add test for aggregated method

* Make send org reaction notification more readable

* Test the rest of the notification model

* Refactor tag adjustment spec

* Fix extra html
2019-02-25 14:25:37 -08:00

30 lines
820 B
Ruby

class ReadNotificationsService
def initialize(receiver)
@receiver = receiver
end
def mark_as_read
NotificationCounter.new(@receiver).set_to_zero
# remove_notifications(@recipient.id)
"read"
end
# This was not working as expected. Go back to drawing board.
# def remove_notifications(user_id)
# return unless ApplicationConfig["PUSHER_BEAMS_KEY"] && ApplicationConfig["PUSHER_BEAMS_KEY"].size == 64
# payload = {
# apns: {
# aps: {
# alert: {
# title: "DEV Notifications",
# body: "Marking as read 🙂"
# }
# },
# data: {
# url: "REMOVE_NOTIFICATIONS"
# }
# }
# }
# Pusher::PushNotifications.publish(interests: ["user-notifications-#{user_id}"], payload: payload)
# end
end