Sha256: c978da12d301b81c9b78a22e64aa85e0b5f71d82cd96995699a6131bb1f3d557

Contents?: true

Size: 1.49 KB

Versions: 25

Compression:

Stored size: 1.49 KB

Contents

class NotificationsController < ApplicationController

  before_filter :authenticate_user!
  before_filter :get_mailbox, :get_actor
  before_filter :check_current_subject_is_owner, :only => [:show, :update, :destroy]
  
  def index
    @notifications = @mailbox.notifications.not_trashed.page(params[:page]).per(10)
  end

  def show
    
  end

  def new

  end

  def edit

  end

  def create

  end

  def update
    if params[:read].present?
      if params[:read].eql?("Read")
        @actor.mark_as_read @notification
      elsif params[:read].eql?("Unread")
        @actor.mark_as_unread @notification
      end
    end
    @notifications = @mailbox.notifications.not_trashed.page(params[:page]).per(10)
    render :action => :index
  end
  
  def update_all
    @notifications= @mailbox.notifications.all
    @actor.mark_as_read @notifications

    if request.xhr?
      render text: ''
    else
      redirect_to notifications_path
    end
  end

  def destroy
    @notification.receipt_for(@actor).move_to_trash
    @notifications = @mailbox.notifications.not_trashed.page(params[:page]).per(10)
    render :action => :index
  end

  private

  def get_mailbox
    @mailbox = current_actor.mailbox
  end

  def get_actor
    @actor = Actor.normalize(current_subject)
  end


  def check_current_subject_is_owner
    
    @notification = Notification.find_by_id(params[:id])

    if @notification.nil? #TODO or !@notification.is_receiver?(@actor)
      redirect_to notifications_path
    return
    end
  end

end

Version data entries

25 entries across 25 versions & 2 rubygems

Version Path
social_stream-2.2.2 base/app/controllers/notifications_controller.rb
social_stream-base-2.2.2 app/controllers/notifications_controller.rb
social_stream-2.2.1 base/app/controllers/notifications_controller.rb
social_stream-base-2.2.1 app/controllers/notifications_controller.rb
social_stream-2.2.0 base/app/controllers/notifications_controller.rb
social_stream-base-2.2.0 app/controllers/notifications_controller.rb
social_stream-2.1.1 base/app/controllers/notifications_controller.rb
social_stream-2.1.0 base/app/controllers/notifications_controller.rb
social_stream-base-2.1.0 app/controllers/notifications_controller.rb
social_stream-2.0.4 base/app/controllers/notifications_controller.rb
social_stream-base-2.0.4 app/controllers/notifications_controller.rb
social_stream-2.0.3 base/app/controllers/notifications_controller.rb
social_stream-base-2.0.3 app/controllers/notifications_controller.rb
social_stream-2.0.2 base/app/controllers/notifications_controller.rb
social_stream-base-2.0.2 app/controllers/notifications_controller.rb
social_stream-2.0.1 base/app/controllers/notifications_controller.rb
social_stream-base-2.0.1 app/controllers/notifications_controller.rb
social_stream-2.0.0 base/app/controllers/notifications_controller.rb
social_stream-base-2.0.0 app/controllers/notifications_controller.rb
social_stream-2.0.0.beta3 base/app/controllers/notifications_controller.rb