Sha256: c0dc8ba23e87dd179b3b7ba02dd968e4d6407765f19c2e4c18f4618bb378c6a7
Contents?: true
Size: 1.13 KB
Versions: 6
Compression:
Stored size: 1.13 KB
Contents
class MailboxController < ApplicationController before_filter :authenticate_user! def index if user_signed_in? @messages = current_user.mailbox.inbox @messages.each{|m| m.mark_as_read(current_user)} else @messages =[] end end def delete_all current_user.mailbox.inbox.each do |msg| delete_message(msg) end empty_trash(current_user) redirect_to sufia.notifications_path end def destroy if current_user msg = Conversation.find(params[:id]) if (msg.participants[0] == current_user) || (msg.participants[1] == current_user) delete_message(msg) empty_trash(msg.participants[0]) end else flash[:alert] = "You do not have privileges to delete the notification..." end redirect_to sufia.notifications_path end private def delete_message (msg) msg.move_to_trash(msg.participants[0]) msg.move_to_trash(msg.participants[1]) end def empty_trash (user) user.mailbox.trash.each { |conv| conv.messages.each {|notify| notify.receipts.each { |receipt| receipt.delete}; notify.delete}; conv.delete} end end
Version data entries
6 entries across 6 versions & 1 rubygems