2017-08-08 21:44:28 +08:00
|
|
|
module ClientApi
|
|
|
|
class NotificationsController < ApplicationController
|
|
|
|
def recent_notifications
|
|
|
|
respond_to do |format|
|
|
|
|
format.json do
|
|
|
|
render template: '/client_api/notifications/index',
|
|
|
|
status: :ok,
|
2017-10-02 20:51:54 +08:00
|
|
|
locals: {
|
|
|
|
notifications:
|
|
|
|
UserNotification.recent_notifications(current_user)
|
|
|
|
}
|
2017-08-08 21:44:28 +08:00
|
|
|
end
|
|
|
|
end
|
2017-10-02 20:51:54 +08:00
|
|
|
# clean the unseen notifications
|
|
|
|
UserNotification.seen_by_user(current_user)
|
2017-08-08 21:44:28 +08:00
|
|
|
end
|
|
|
|
|
2017-10-06 16:45:22 +08:00
|
|
|
def unread_notifications_count
|
2017-10-02 20:51:54 +08:00
|
|
|
respond_to do |format|
|
|
|
|
format.json do
|
|
|
|
render json: {
|
|
|
|
count: UserNotification.unseen_notification_count(current_user)
|
|
|
|
}, status: :ok
|
|
|
|
end
|
|
|
|
end
|
2017-08-08 21:44:28 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|