@@ -65,7 +65,7 @@ async function deleteMilestone(authUser, timelineId, id, transaction, item) {
6565 * @param {Object } data The updated data
6666 * @param {Object } transaction The transaction to use
6767 * @param {Object } [item] The item to update
68- * @returns {Object } The updated milestone
68+ * @returns {{updated: Object, original: Object} } The updated and original milestones
6969 * @throws {Error } If something went wrong
7070 */
7171async function updateMilestone ( authUser , timelineId , data , transaction , item ) {
@@ -87,6 +87,9 @@ async function updateMilestone(authUser, timelineId, data, transaction, item) {
8787 apiErr . status = 404 ;
8888 throw apiErr ;
8989 }
90+
91+ const original = milestone . toJSON ( ) ;
92+
9093 if ( entityToUpdate . status === MILESTONE_STATUS . PAUSED && ! validStatuses . includes ( milestone . status ) ) {
9194 const validStatutesStr = validStatuses . join ( ', ' ) ;
9295 const apiErr = new Error ( `Milestone can only be paused from the next statuses: ${ validStatutesStr } ` ) ;
@@ -196,7 +199,10 @@ async function updateMilestone(authUser, timelineId, data, transaction, item) {
196199 */
197200
198201 const result = await milestone . update ( entityToUpdate , { comment : entityToUpdate . statusComment , transaction } ) ;
199- return _ . omit ( result . toJSON ( ) , [ 'deletedBy' , 'deletedAt' ] ) ;
202+ return {
203+ original : _ . omit ( original , [ 'deletedBy' , 'deletedAt' ] ) ,
204+ updated : _ . omit ( result . toJSON ( ) , [ 'deletedBy' , 'deletedAt' ] ) ,
205+ } ;
200206}
201207
202208
0 commit comments