Follow+Notes: Expose grant notes creation in Finder API
TylerHendrickson opened this issue · 0 comments
TylerHendrickson commented
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()
frompackages/server/src/lib/grantsCollaboration
to persist a new note and/or note revision to the database. - Subsequently calls
followGrant()
frompackages/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 tosaveNoteRevision()
was successful (did not throw any error). - Begins a new database transaction on the
knex
object that is passed tosaveNoteRevision()
andfollowGrant()
(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.