Sha256: bb5765006ced9b996b5dc804b7d264607e8b459c75562f3786a89d8c46f5bea8

Contents?: true

Size: 1.27 KB

Versions: 20

Compression:

Stored size: 1.27 KB

Contents

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
        opts = {
          synced_at: params[:synced_at],
          permissions: permissions,
          recipient_token: params[:token]
        }
        fetcher = Notification::Fetcher.new opts
        render json: [fetcher.formatted_notifications, fetcher.next_sync_time.iso8601(6)]
      end

      def permissions
        return [] if not defined? loco_permissions
        return loco_permissions if params[:uuid].blank?
        resources_to_del = []
        resources_to_add = []
        loco_permissions.each do |resource|
          next if resource.nil?
          next if not WsConnectionManager.new(resource).connected?(params[:uuid])
          resources_to_del << resource
          resources_to_add << resource.class
        end
        loco_permissions - resources_to_del + resources_to_add.uniq
      end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
loco-rails-2.5.3 app/controllers/loco/notification_center_controller.rb
loco-rails-2.5.2 app/controllers/loco/notification_center_controller.rb
loco-rails-2.5.1 app/controllers/loco/notification_center_controller.rb
loco-rails-2.5.0 app/controllers/loco/notification_center_controller.rb
loco-rails-2.4.0 app/controllers/loco/notification_center_controller.rb
loco-rails-2.3.0 app/controllers/loco/notification_center_controller.rb
loco-rails-3.0.0 app/controllers/loco/notification_center_controller.rb
loco-rails-2.2.2 app/controllers/loco/notification_center_controller.rb
loco-rails-2.2.1 app/controllers/loco/notification_center_controller.rb
loco-rails-2.2.0 app/controllers/loco/notification_center_controller.rb
loco-rails-2.1.0 app/controllers/loco/notification_center_controller.rb
loco-rails-2.0.0 app/controllers/loco/notification_center_controller.rb
loco-rails-1.5.2 app/controllers/loco/notification_center_controller.rb
loco-rails-1.5.1 app/controllers/loco/notification_center_controller.rb
loco-rails-1.5.0 app/controllers/loco/notification_center_controller.rb
loco-rails-1.4.0 app/controllers/loco/notification_center_controller.rb
loco-rails-1.3.3 app/controllers/loco/notification_center_controller.rb
loco-rails-1.3.2 app/controllers/loco/notification_center_controller.rb
loco-rails-1.3.1 app/controllers/loco/notification_center_controller.rb
loco-rails-1.3.0 app/controllers/loco/notification_center_controller.rb