Sha256: c095fe947a024a49c7ca65546f7cc3bcf262c6eb949425c05177f5a352b7b649
Contents?: true
Size: 916 Bytes
Versions: 25
Compression:
Stored size: 916 Bytes
Contents
# frozen_string_literal: true module Decidim # This command updates the user's notifications settings. class UpdateNotificationsSettings < Rectify::Command # Updates a user's notifications settings. # # user - The user to be updated. # form - The form with the data. def initialize(user, form) @user = user @form = form end def call return broadcast(:invalid) unless @form.valid? update_notifications_settings @user.save! broadcast(:ok, @user) end private def update_notifications_settings @user.email_on_notification = @form.email_on_notification @user.newsletter_notifications_at = @form.newsletter_notifications_at @user.notification_types = @form.notification_types @user.direct_message_types = @form.direct_message_types @user.email_on_moderations = @form.email_on_moderations end end end
Version data entries
25 entries across 25 versions & 1 rubygems