Sha256: 05b818daf90e2f2f661cb3ca6fa3c507b7ba90fd8470f9a219cb6e46cf5055a6

Contents?: true

Size: 1.36 KB

Versions: 12

Compression:

Stored size: 1.36 KB

Contents

# frozen_string_literal: true

module Decidim
  module Conferences
    module Admin
      # A command with all the business logic when destroying a media link
      # in the system.
      class DestroyMediaLink < Decidim::Command
        # Public: Initializes the command.
        #
        # media_link - the MediaLink to destroy
        # current_user - the user performing this action
        def initialize(media_link, current_user)
          @media_link = media_link
          @current_user = current_user
        end

        # Executes the command. Broadcasts these events:
        #
        # - :ok when everything is valid.
        # - :invalid if the form wasn't valid and we couldn't proceed.
        #
        # Returns nothing.
        def call
          destroy_speaker!
          broadcast(:ok)
        end

        private

        attr_reader :media_link, :current_user

        def destroy_speaker!
          log_info = {
            resource: {
              title: media_link.title
            },
            participatory_space: {
              title: media_link.conference.title
            }
          }

          Decidim.traceability.perform_action!(
            "delete",
            media_link,
            current_user,
            log_info
          ) do
            media_link.destroy!
            media_link
          end
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
decidim-conferences-0.27.9 app/commands/decidim/conferences/admin/destroy_media_link.rb
decidim-conferences-0.27.8 app/commands/decidim/conferences/admin/destroy_media_link.rb
decidim-conferences-0.27.7 app/commands/decidim/conferences/admin/destroy_media_link.rb
decidim-conferences-0.27.6 app/commands/decidim/conferences/admin/destroy_media_link.rb
decidim-conferences-0.27.5 app/commands/decidim/conferences/admin/destroy_media_link.rb
decidim-conferences-0.27.4 app/commands/decidim/conferences/admin/destroy_media_link.rb
decidim-conferences-0.27.3 app/commands/decidim/conferences/admin/destroy_media_link.rb
decidim-conferences-0.27.2 app/commands/decidim/conferences/admin/destroy_media_link.rb
decidim-conferences-0.27.1 app/commands/decidim/conferences/admin/destroy_media_link.rb
decidim-conferences-0.27.0 app/commands/decidim/conferences/admin/destroy_media_link.rb
decidim-conferences-0.27.0.rc2 app/commands/decidim/conferences/admin/destroy_media_link.rb
decidim-conferences-0.27.0.rc1 app/commands/decidim/conferences/admin/destroy_media_link.rb