Sha256: 58b3092c01bff754f71eca78373dcc2d3af529d5b8408a2fc869096886c3dcc6

Contents?: true

Size: 635 Bytes

Versions: 7

Compression:

Stored size: 635 Bytes

Contents

# frozen_string_literal: true

module Decidim
  # The controller to handle the user's notifications deletion.
  class NotificationsController < Decidim::ApplicationController
    def destroy
      notification = notifications.find(params[:id])
      enforce_permission_to :destroy, :notification, notification: notification
      notification.destroy
    end

    def read_all
      enforce_permission_to :destroy, :notification, notification: notifications.first
      notifications.destroy_all
    end

    private

    def notifications
      @notifications ||= current_user.notifications.order(created_at: :desc)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
decidim-core-0.13.1 app/controllers/decidim/notifications_controller.rb
decidim-core-0.12.2 app/controllers/decidim/notifications_controller.rb
decidim-core-0.13.0 app/controllers/decidim/notifications_controller.rb
decidim-core-0.12.1 app/controllers/decidim/notifications_controller.rb
decidim-core-0.13.0.pre1 app/controllers/decidim/notifications_controller.rb
decidim-core-0.12.0 app/controllers/decidim/notifications_controller.rb
decidim-core-0.12.0.pre app/controllers/decidim/notifications_controller.rb