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
def note_json(note)
if note.is_a?(AwardEmoji)
{
attrs = {
valid: note.valid?,
award: true,
id: note.id,
name: note.name
}
elsif note.persisted?
......@@ -158,12 +157,9 @@ class Projects::NotesController < Projects::ApplicationController
attrs = {
valid: true,
id: note.id,
discussion_id: note.discussion_id,
html: note_html(note),
award: false,
note: note.note,
commands_executed: note.commands_executed
note: note.note
}
if note.diff_note?
......@@ -189,16 +185,18 @@ class Projects::NotesController < Projects::ApplicationController
attrs[:original_discussion_id] = note.original_discussion_id
end
end
attrs
else
{
attrs = {
valid: false,
award: false,
commands_executed: note.commands_executed,
errors: note.errors
}
end
attrs[:award] ||= false
attrs[:id] = note.id
attrs[:commands_changes] = note.commands_changes
attrs
end
def authorize_admin_note!
......
......@@ -19,8 +19,8 @@ class Note < ActiveRecord::Base
# Banzai::ObjectRenderer
attr_accessor :user_visible_reference_count
# Flag used to indicate that a Note contains slash commands and they have been executed.
attr_accessor :commands_executed
# Attributes used to store the attributes that have ben changed by slash commands.
attr_accessor :commands_changes
default_value_for :system, false
......
......@@ -41,7 +41,7 @@ module Notes
note.errors.add(:commands_only, 'Your commands have been executed!')
end
note.commands_executed = true
note.commands_changes = command_params.keys
end
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