Sha256: a2713d5124ca615b1db2cf162638aeb4f2e3eec378e3622142fcae875a506221

Contents?: true

Size: 589 Bytes

Versions: 13

Compression:

Stored size: 589 Bytes

Contents

# frozen_string_literal: true

module Decidim
  # This command unsubscribes user from newsletter.
  class UnsubscribeSettings < Rectify::Command
    # unsubscribe user from newsletter.
    #
    # user - The user to be updated.
    # newsletter_notifications - to be false
    def initialize(user)
      @user = user
    end

    def call
      return broadcast(:invalid) unless @user.newsletter_notifications

      update_settings
      @user.save!

      broadcast(:ok, @user)
    end

    private

    def update_settings
      @user.newsletter_notifications = false
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
decidim-core-0.12.2 app/commands/decidim/unsubscribe_settings.rb
decidim-core-0.12.1 app/commands/decidim/unsubscribe_settings.rb
decidim-core-0.12.0 app/commands/decidim/unsubscribe_settings.rb
decidim-core-0.11.2 app/commands/decidim/unsubscribe_settings.rb
decidim-core-0.12.0.pre app/commands/decidim/unsubscribe_settings.rb
decidim-core-0.11.1 app/commands/decidim/unsubscribe_settings.rb
decidim-core-0.11.0.pre1 app/commands/decidim/unsubscribe_settings.rb
decidim-core-0.10.1 app/commands/decidim/unsubscribe_settings.rb
decidim-core-0.10.0 app/commands/decidim/unsubscribe_settings.rb
decidim-core-0.9.3 app/commands/decidim/unsubscribe_settings.rb
decidim-core-0.9.2 app/commands/decidim/unsubscribe_settings.rb
decidim-core-0.9.1 app/commands/decidim/unsubscribe_settings.rb
decidim-core-0.9.0 app/commands/decidim/unsubscribe_settings.rb