Sha256: da2d9a603ac9e8ead99c393fdec503845b822caec880656cd8dcbf0ab1dbff46

Contents?: true

Size: 793 Bytes

Versions: 13

Compression:

Stored size: 793 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.comments_notifications = @form.comments_notifications
      @user.replies_notifications = @form.replies_notifications
      @user.newsletter_notifications = @form.newsletter_notifications
    end
  end
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
decidim-core-0.5.1 app/commands/decidim/update_notifications_settings.rb
decidim-0.5.1 decidim-core/app/commands/decidim/update_notifications_settings.rb
decidim-core-0.5.0 app/commands/decidim/update_notifications_settings.rb
decidim-0.5.0 decidim-core/app/commands/decidim/update_notifications_settings.rb
decidim-core-0.4.4 app/commands/decidim/update_notifications_settings.rb
decidim-core-0.4.2 app/commands/decidim/update_notifications_settings.rb
decidim-core-0.4.1 app/commands/decidim/update_notifications_settings.rb
decidim-core-0.4.3 app/commands/decidim/update_notifications_settings.rb
decidim-core-0.4.0 app/commands/decidim/update_notifications_settings.rb
decidim-core-0.3.2 app/commands/decidim/update_notifications_settings.rb
decidim-core-0.3.1 app/commands/decidim/update_notifications_settings.rb
decidim-core-0.3.0 app/commands/decidim/update_notifications_settings.rb
decidim-core-0.2.0 app/commands/decidim/update_notifications_settings.rb