Stores the comments on dumps, threaded by parent_id. The comment routes
call it and broadcast what it returns. It leaves checking that the caller
may see the dump to them.
Posts a comment on dump dumpId, replying to parentId if given, for
POST /api/dumps/:dumpId/comments. It notifies the dump's poster and the
users it mentions, unless the dump is private, and links the comment's
attachments and backlinks. The route has checked that the caller may see
the dump.
Deletes a comment, for DELETE /api/comments/:commentId. canModerate lets
someone other than the author do it. The body is emptied and the backlinks
dropped, but the row stays so its replies keep their place. The route
broadcasts the deletion to those who may see the returned dump.
Returns the id of the dump comment commentId is posted under. The likers
route uses it to check that the caller may see that dump.
Returns every comment on dump dumpId, oldest first, for
GET /api/dumps/:dumpId/comments. Deleted comments are included, emptied,
so the client can keep their replies in place.
Replaces a comment's body, for PATCH /api/comments/:commentId.
canModerate lets someone other than the author do it. It notifies, in the
author's name, the users it mentions for the first time, unless the dump is
private, and relinks the attachments and backlinks. The route broadcasts the
comment to those who may see its dump.
The dump a comment is on, as updateComment and deleteComment return it: what the route needs to choose the broadcast's audience.
- id: string
- isPrivate: boolean
-
userId: string
The dump's poster, the only one who sees a private dump's comments.
Usage
import * as mod from "api/services/comment-service.ts";