Sha256: 9c23d03c492df4ccbb4257994a777be1d93cc25fffd1c27656371c1bd0962566

Contents?: true

Size: 595 Bytes

Versions: 25

Compression:

Stored size: 595 Bytes

Contents

# frozen_string_literal: true

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

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

      update_settings
      @user.save!

      broadcast(:ok, @user)
    end

    private

    def update_settings
      @user.newsletter_notifications_at = nil
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
decidim-core-0.29.1 app/commands/decidim/unsubscribe_settings.rb
decidim-core-0.28.4 app/commands/decidim/unsubscribe_settings.rb
decidim-core-0.27.9 app/commands/decidim/unsubscribe_settings.rb
decidim-core-0.29.0 app/commands/decidim/unsubscribe_settings.rb
decidim-core-0.28.3 app/commands/decidim/unsubscribe_settings.rb
decidim-core-0.27.8 app/commands/decidim/unsubscribe_settings.rb
decidim-core-0.29.0.rc4 app/commands/decidim/unsubscribe_settings.rb
decidim-core-0.29.0.rc3 app/commands/decidim/unsubscribe_settings.rb
decidim-core-0.29.0.rc2 app/commands/decidim/unsubscribe_settings.rb
decidim-core-0.29.0.rc1 app/commands/decidim/unsubscribe_settings.rb
decidim-core-0.28.2 app/commands/decidim/unsubscribe_settings.rb
decidim-core-0.27.7 app/commands/decidim/unsubscribe_settings.rb
decidim-core-0.28.1 app/commands/decidim/unsubscribe_settings.rb
decidim-core-0.27.6 app/commands/decidim/unsubscribe_settings.rb
decidim-core-0.28.0 app/commands/decidim/unsubscribe_settings.rb
decidim-core-0.27.5 app/commands/decidim/unsubscribe_settings.rb
decidim-core-0.28.0.rc5 app/commands/decidim/unsubscribe_settings.rb
decidim-core-0.28.0.rc4 app/commands/decidim/unsubscribe_settings.rb
decidim-core-0.27.4 app/commands/decidim/unsubscribe_settings.rb
decidim-core-0.27.3 app/commands/decidim/unsubscribe_settings.rb