Sha256: 00cc5dd6ca7997cc93400c369efe139163c1c56c12b8b56bd66dc1b5ff7a2fcd
Contents?: true
Size: 1.22 KB
Versions: 3
Compression:
Stored size: 1.22 KB
Contents
require_dependency "renalware/messaging" # A Receipt is cross reference between Message and Recipient. # We can for instance mark on a receipt if/when it was read or viewed. module Renalware module Messaging class ReceiptsController < BaseController include Renalware::Concerns::Pageable include PresenterHelper # GET aka inbox def unread render_receipts(receipts.unread) end # GET def read render_receipts(receipts) end # PATCH def mark_as_read authorize receipt receipt.update(read_at: Time.zone.now) render locals: { receipt: Messaging::ReceiptPresenter.new(receipt) } end private def render_receipts(receipts) authorize receipts render locals: { receipts: present(receipts, Messaging::ReceiptPresenter) } end def receipts @receipts ||= recipient.receipts.page(page).per(per_page) end def receipt @receipt ||= recipient.receipts.find_by!( message_id: params[:message_id], id: params[:id] ) end def recipient Messaging.cast_recipient(current_user) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems