Class: Decidim::Messaging::ReplyToConversation
- Inherits:
-
Rectify::Command
- Object
- Rectify::Command
- Decidim::Messaging::ReplyToConversation
- Defined in:
- app/commands/decidim/messaging/reply_to_conversation.rb
Overview
A command with all the business logic for replying to a conversation
Instance Method Summary collapse
-
#call ⇒ Object
Executes the command.
-
#initialize(conversation, form) ⇒ ReplyToConversation
constructor
Public: Initializes the command.
Constructor Details
#initialize(conversation, form) ⇒ ReplyToConversation
Public: Initializes the command.
conversation - The conversation to be updated. form - A form object with the params.
11 12 13 14 |
# File 'app/commands/decidim/messaging/reply_to_conversation.rb', line 11 def initialize(conversation, form) @conversation = conversation @form = form end |
Instance Method Details
#call ⇒ Object
Executes the command. Broadcasts these events:
-
:ok when everything is valid, together with the message.
-
:invalid if the form wasn’t valid and we couldn’t proceed.
Returns nothing.
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/commands/decidim/messaging/reply_to_conversation.rb', line 22 def call return broadcast(:invalid) if form.invalid? if .save notify_interlocutors notify_comanagers if sender.is_a?(UserGroup) broadcast(:ok, ) else broadcast(:invalid, .errors.) end end |