Sha256: 9c1b7db090ee6f02c65da1f490b32954608612da574f14bcacda9eaa8a1588bf

Contents?: true

Size: 727 Bytes

Versions: 41

Compression:

Stored size: 727 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 = @form.newsletter_notifications
    end
  end
end

Version data entries

41 entries across 41 versions & 2 rubygems

Version Path
decidim-core-0.12.2 app/commands/decidim/update_notifications_settings.rb
decidim-core-0.12.1 app/commands/decidim/update_notifications_settings.rb
decidim-core-0.12.0 app/commands/decidim/update_notifications_settings.rb
decidim-core-0.11.2 app/commands/decidim/update_notifications_settings.rb
decidim-core-0.12.0.pre app/commands/decidim/update_notifications_settings.rb
decidim-core-0.11.1 app/commands/decidim/update_notifications_settings.rb
decidim-core-0.11.0.pre1 app/commands/decidim/update_notifications_settings.rb
decidim-core-0.10.1 app/commands/decidim/update_notifications_settings.rb
decidim-core-0.10.0 app/commands/decidim/update_notifications_settings.rb
decidim-core-0.9.3 app/commands/decidim/update_notifications_settings.rb
decidim-core-0.9.2 app/commands/decidim/update_notifications_settings.rb
decidim-core-0.9.1 app/commands/decidim/update_notifications_settings.rb
decidim-core-0.9.0 app/commands/decidim/update_notifications_settings.rb
decidim-core-0.8.4 app/commands/decidim/update_notifications_settings.rb
decidim-core-0.8.3 app/commands/decidim/update_notifications_settings.rb
decidim-core-0.8.2 app/commands/decidim/update_notifications_settings.rb
decidim-core-0.8.1 app/commands/decidim/update_notifications_settings.rb
decidim-core-0.8.0 app/commands/decidim/update_notifications_settings.rb
decidim-core-0.7.4 app/commands/decidim/update_notifications_settings.rb
decidim-core-0.7.3 app/commands/decidim/update_notifications_settings.rb