Sha256: 3ee031865b39e8877436e0b7697192445ca98124903fae45153eaef20a1411d9
Contents?: true
Size: 1.47 KB
Versions: 104
Compression:
Stored size: 1.47 KB
Contents
module Comee module Core class NotificationsController < ApplicationController before_action :set_notification, only: %i[mark_as_read mark_as_unread] def index data = Notification.messages(current_user.notifications.newest_first) render_content(data) end def read data = Notification.messages(current_user.notifications.read.newest_first) render_content(data) end def unread data = Notification.messages(current_user.notifications.unread.newest_first) render_content(data) end def mark_as_read @notification.mark_as_read! render json: {success: true, data: @notification.message} end def mark_as_unread @notification.mark_as_unread! render json: {success: true, data: @notification.message} end def notify NotificationMailer.with( user: current_user, recipients: notify_params[:recipients], subject: notify_params[:subject], email_body: notify_params[:body], files: notify_params[:files] ).notify.deliver_now render json: {success: true} rescue StandardError => e render_error(e) end private def set_notification @notification = Notification.find(params[:id]) end def notify_params params.require(:payload).permit(:subject, :body, recipients: [], files: {filename: :file}) end end end end
Version data entries
104 entries across 104 versions & 1 rubygems