Sha256: 206ae69f538645092ffd71fd11c9e257b63a17c3dac257ade6d0bc3753e4aae9

Contents?: true

Size: 733 Bytes

Versions: 10

Compression:

Stored size: 733 Bytes

Contents

# frozen_string_literal: true

module Decidim
  # This command updates the user's notifictions 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
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
decidim-core-0.15.2 app/commands/decidim/update_notifications_settings.rb
decidim-core-0.15.1 app/commands/decidim/update_notifications_settings.rb
decidim-core-0.15.0 app/commands/decidim/update_notifications_settings.rb
decidim-core-0.14.4 app/commands/decidim/update_notifications_settings.rb
decidim-core-0.14.3 app/commands/decidim/update_notifications_settings.rb
decidim-core-0.14.2 app/commands/decidim/update_notifications_settings.rb
decidim-core-0.14.1 app/commands/decidim/update_notifications_settings.rb
decidim-core-0.13.1 app/commands/decidim/update_notifications_settings.rb
decidim-core-0.13.0 app/commands/decidim/update_notifications_settings.rb
decidim-core-0.13.0.pre1 app/commands/decidim/update_notifications_settings.rb