Class: Decidim::Posts::CreatePost

Inherits:
Command
  • Object
show all
Includes:
MultipleAttachmentsMethods
Defined in:
app/commands/decidim/posts/create_post.rb

Overview

This command is executed when a participant or user group creates a Meeting from the public views.

Instance Method Summary collapse

Constructor Details

#initialize(form) ⇒ CreatePost

Returns a new instance of CreatePost.



11
12
13
# File 'app/commands/decidim/posts/create_post.rb', line 11

def initialize(form)
  @form = form
end

Instance Method Details

#callObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/commands/decidim/posts/create_post.rb', line 15

def call
  return broadcast(:invalid) if form.invalid?

  if process_attachments?
    build_attachments
    return broadcast(:invalid) if attachments_invalid?
  end

  with_events(with_transaction: true) do
    Decidim.traceability.perform_action!("create_feeds_post", Post, form.current_user) do
      create_post
    end
    
    # create_attachments(weight: first_attachment_weight) if process_attachments?
    create_attachments if process_attachments?
  end

  # create_follow_form_resource(form.current_user)
  #send_notification

  broadcast(:ok, post)
end