Class CommentService

java.lang.Object
su.onno.ui.comments.CommentService

public class CommentService extends Object
Persistence for onno_comments: the framework-owned thread store behind the /api/comments endpoint. It is infrastructure (like onno_schema_history), not a modelled catalog — so it is created with a plain CREATE TABLE IF NOT EXISTS at startup rather than through the metadata diff engine, and never appears in the navigation or REST model.

A thread is keyed by (entity_type, entity_name, entity_id). Deletes are soft (the row stays for audit with _deleted = true); reads filter them out.

Timestamps are Instants. They go to and from the plain TIMESTAMP column through Timestamp (Timestamp.from(instant) on write, getTimestamp().toInstant() on read), so the instant round-trips symmetrically regardless of the server's zone and no column migration is needed (#177).

  • Constructor Details

    • CommentService

      public CommentService(org.jdbi.v3.core.Jdbi jdbi)
  • Method Details

    • list

      public List<Comment> list(String entityType, String entityName, UUID entityId)
      The live thread for one entity, oldest comment first.
    • add

      public Comment add(String entityType, String entityName, UUID entityId, String authorId, String authorName, String body)
      Append a comment and return it as stored.
    • add

      public Comment add(String entityType, String entityName, UUID entityId, String authorId, String authorName, String body, UUID parentId)
      Append a top-level comment or a reply and return it as stored.
    • find

      public Optional<Comment> find(UUID id)
      A single comment by id (including soft-deleted ones), for authorization checks.
    • softDelete

      public boolean softDelete(UUID id)
      Soft-delete a comment; returns false when it doesn't exist or was already deleted.
    • toggleReaction

      public boolean toggleReaction(UUID commentId, String userKey, String emoji)
      Toggle one viewer's reaction on a comment and return whether it is now present.
    • reactionsFor

      public Map<UUID,List<CommentService.CommentReaction>> reactionsFor(Collection<UUID> commentIds, String userKey)
      Grouped reactions for a batch of comments, preserving first-seen emoji order per comment.