From dff6adc6c1a0f5973bcd3dea6231e6440712b374 Mon Sep 17 00:00:00 2001 From: Hagen Schink Date: Tue, 4 Nov 2014 10:52:53 +0100 Subject: [PATCH] Implement notify parameter for WP PATCH endpoint --- lib/api/v3/work_packages/work_packages_api.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/api/v3/work_packages/work_packages_api.rb b/lib/api/v3/work_packages/work_packages_api.rb index 5dae0ff331..abafc96a0d 100644 --- a/lib/api/v3/work_packages/work_packages_api.rb +++ b/lib/api/v3/work_packages/work_packages_api.rb @@ -40,6 +40,14 @@ module API helpers do attr_reader :work_package + def save_work_package + send_notifications = !(params.has_key?(:notify) && params[:notify] == 'false') + + UserMailer.with_deliveries(send_notifications) do + @representer.represented.save + end + end + def decorate_work_package(work_package) @representer = ::API::V3::WorkPackages::WorkPackageRepresenter.new(work_package, { current_user: current_user }, :activities, :users) end @@ -81,7 +89,7 @@ module API @representer.from_json(patch_request_body) - if patch_request_valid? && @representer.represented.save + if patch_request_valid? && save_work_package decorate_work_package(@work_package.reload) @representer else