Sha256: 10569362ac6d7e6002a220edddcb26adf391137633877850b37e0dd8db21d3e7

Contents?: true

Size: 930 Bytes

Versions: 4

Compression:

Stored size: 930 Bytes

Contents

# frozen_string_literal: true

module Loco
  class NotificationCenterController < ApplicationController
    def index
      if Loco::Config.silence_logger
        logger.silence { fetch_notifications }
      else
        fetch_notifications
      end
    end

    def sync_time
      render json: { sync_time: Time.current.iso8601(6) }
    end

    private

    def fetch_notifications
      if params[:synced_at].blank?
        render json: [[], Time.current.iso8601(6)]
        return
      end
      fetcher = Notification::Fetcher.new({ synced_at: params[:synced_at],
                                            permissions: permissions,
                                            recipient_token: params[:token] })
      render json: [fetcher.formatted_notifications, fetcher.next_sync_time.iso8601(6)]
    end

    def permissions
      return [] unless defined?(loco_permissions)

      loco_permissions
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
loco-rails-6.2.0 app/controllers/loco/notification_center_controller.rb
loco-rails-6.1.0 app/controllers/loco/notification_center_controller.rb
loco-rails-6.0.0 app/controllers/loco/notification_center_controller.rb
loco-rails-5.0.0 app/controllers/loco/notification_center_controller.rb