usdigitalresponse/usdr-gost

Follow+Notes: Expose grant notes creation in Finder API

TylerHendrickson opened this issue · 0 comments

Subtask of [STORY]: Update 'Status' to 'Follow + Note' feature #2960

Blocked by

Blocks

Definition of Done

A new API route exists that allows users to publish (and revise) notes pertaining to a specific grant.

Implementation Details

In packages/server/src/routes/grants.js, define a new PUT /:grantId/notes/revision API route handler as follows:

  • Requires authentication.
  • Requires that the organization (tenant) of the authenticated user matches the :organizationId request path parameter.
  • Calls saveNoteRevision() from packages/server/src/lib/grantsCollaboration to persist a new note and/or note revision to the database.
  • Subsequently calls followGrant() from packages/server/src/lib/grantsCollaboration so that the user who posted the comment is automatically marked as following the grant. This should only happen if the call to saveNoteRevision() was successful (did not throw any error).
  • Begins a new database transaction on the knex object that is passed to saveNoteRevision() and followGrant() (so that both function calls are encapsulated in the same database transaction) and commits the transaction after both function calls have returned without throwing any error. If either function throws an error, the transaction should be rolled back and an error response issued.