class Decidim::Meetings::Admin::PublishMeeting

existing meeting.
A command with all the business logic that publishes an

def call

Returns nothing.

- :invalid if the form wasn't valid and we couldn't proceed.
- :ok when everything is valid.

Executes the command. Broadcasts these events:
def call
  return broadcast(:invalid) if meeting.published?
  transaction do
    publish_meeting
    send_notification
    schedule_upcoming_meeting_notification
  end
  broadcast(:ok, meeting)
end

def initialize(meeting, current_user)

current_user - the user performing the action
meeting - Decidim::Meetings::Meeting

Public: Initializes the command.
def initialize(meeting, current_user)
  @meeting = meeting
  @current_user = current_user
end

def publish_meeting

def publish_meeting
  @meeting = Decidim.traceability.perform_action!(
    :publish,
    meeting,
    current_user,
    visibility: "all"
  ) do
    meeting.publish!
    meeting
  end
end

def schedule_upcoming_meeting_notification

def schedule_upcoming_meeting_notification
  return if meeting.start_time < Time.zone.now
  checksum = Decidim::Meetings::UpcomingMeetingNotificationJob.generate_checksum(meeting)
  Decidim::Meetings::UpcomingMeetingNotificationJob
    .set(wait_until: meeting.start_time - Decidim::Meetings.upcoming_meeting_notification)
    .perform_later(meeting.id, checksum)
end

def send_notification

def send_notification
  Decidim::EventsManager.publish(
    event: "decidim.events.meetings.meeting_created",
    event_class: Decidim::Meetings::CreateMeetingEvent,
    resource: meeting,
    followers: meeting.participatory_space.followers,
    force_send: true
  )
end