Commit 16f6bf36 authored by Ruben Davila's avatar Ruben Davila

Return the attrs that have been updated by slash command in JSON payload.

parent 658fc330
...@@ -147,10 +147,9 @@ class Projects::NotesController < Projects::ApplicationController ...@@ -147,10 +147,9 @@ class Projects::NotesController < Projects::ApplicationController
def note_json(note) def note_json(note)
if note.is_a?(AwardEmoji) if note.is_a?(AwardEmoji)
{ attrs = {
valid: note.valid?, valid: note.valid?,
award: true, award: true,
id: note.id,
name: note.name name: note.name
} }
elsif note.persisted? elsif note.persisted?
...@@ -158,12 +157,9 @@ class Projects::NotesController < Projects::ApplicationController ...@@ -158,12 +157,9 @@ class Projects::NotesController < Projects::ApplicationController
attrs = { attrs = {
valid: true, valid: true,
id: note.id,
discussion_id: note.discussion_id, discussion_id: note.discussion_id,
html: note_html(note), html: note_html(note),
award: false, note: note.note
note: note.note,
commands_executed: note.commands_executed
} }
if note.diff_note? if note.diff_note?
...@@ -189,16 +185,18 @@ class Projects::NotesController < Projects::ApplicationController ...@@ -189,16 +185,18 @@ class Projects::NotesController < Projects::ApplicationController
attrs[:original_discussion_id] = note.original_discussion_id attrs[:original_discussion_id] = note.original_discussion_id
end end
end end
attrs
else else
{ attrs = {
valid: false, valid: false,
award: false,
commands_executed: note.commands_executed,
errors: note.errors errors: note.errors
} }
end end
attrs[:award] ||= false
attrs[:id] = note.id
attrs[:commands_changes] = note.commands_changes
attrs
end end
def authorize_admin_note! def authorize_admin_note!
......
...@@ -19,8 +19,8 @@ class Note < ActiveRecord::Base ...@@ -19,8 +19,8 @@ class Note < ActiveRecord::Base
# Banzai::ObjectRenderer # Banzai::ObjectRenderer
attr_accessor :user_visible_reference_count attr_accessor :user_visible_reference_count
# Flag used to indicate that a Note contains slash commands and they have been executed. # Attributes used to store the attributes that have ben changed by slash commands.
attr_accessor :commands_executed attr_accessor :commands_changes
default_value_for :system, false default_value_for :system, false
......
...@@ -41,7 +41,7 @@ module Notes ...@@ -41,7 +41,7 @@ module Notes
note.errors.add(:commands_only, 'Your commands have been executed!') note.errors.add(:commands_only, 'Your commands have been executed!')
end end
note.commands_executed = true note.commands_changes = command_params.keys
end end
note note
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment