feat(audit): expose commentId on rolled-up activity feed projection
Adds getCommentId() to ActivityFeedRow and selects (ag.payload->>'commentId')::uuid from findRolledUpActivityFeed so chronik consumers can build deep-link URLs for COMMENT_ADDED and MENTION_CREATED events. Null for other kinds. Refs #300. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -15,4 +15,6 @@ public interface ActivityFeedRow {
|
|||||||
boolean isYouParticipated();
|
boolean isYouParticipated();
|
||||||
int getCount();
|
int getCount();
|
||||||
Instant getHappenedAtUntil();
|
Instant getHappenedAtUntil();
|
||||||
|
/** Present only for COMMENT_ADDED and MENTION_CREATED — null otherwise. */
|
||||||
|
UUID getCommentId();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -99,7 +99,8 @@ public interface AuditLogQueryRepository extends JpaRepository<AuditLog, UUID> {
|
|||||||
AND n.reference_id = (ag.payload->>'commentId')::uuid
|
AND n.reference_id = (ag.payload->>'commentId')::uuid
|
||||||
) AS youParticipated,
|
) AS youParticipated,
|
||||||
ag.count AS count,
|
ag.count AS count,
|
||||||
ag.happened_at_until AS happenedAtUntil
|
ag.happened_at_until AS happenedAtUntil,
|
||||||
|
(ag.payload->>'commentId')::uuid AS commentId
|
||||||
FROM aggregated ag
|
FROM aggregated ag
|
||||||
LEFT JOIN users u ON u.id = ag.actor_id
|
LEFT JOIN users u ON u.id = ag.actor_id
|
||||||
ORDER BY ag.happened_at DESC
|
ORDER BY ag.happened_at DESC
|
||||||
|
|||||||
@@ -271,6 +271,45 @@ class AuditLogQueryRepositoryRolledUpTest {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void rolledUpFeed_exposes_commentId_for_COMMENT_ADDED_events() {
|
||||||
|
insertUserAndDocs();
|
||||||
|
UUID commentId = UUID.randomUUID();
|
||||||
|
insertAuditEvent(USER_ID, DOC_ID, "COMMENT_ADDED",
|
||||||
|
Instant.parse("2026-04-20T10:00:00Z"), Map.of("commentId", commentId.toString()));
|
||||||
|
|
||||||
|
List<ActivityFeedRow> rows = auditLogQueryRepository.findRolledUpActivityFeed(USER_ID.toString(), 40);
|
||||||
|
|
||||||
|
assertThat(rows).hasSize(1);
|
||||||
|
assertThat(rows.get(0).getCommentId()).isEqualTo(commentId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void rolledUpFeed_exposes_commentId_for_MENTION_CREATED_events() {
|
||||||
|
insertUserAndDocs();
|
||||||
|
UUID commentId = UUID.randomUUID();
|
||||||
|
insertAuditEvent(OTHER_USER_ID, DOC_ID, "MENTION_CREATED",
|
||||||
|
Instant.parse("2026-04-20T10:00:00Z"),
|
||||||
|
Map.of("commentId", commentId.toString(), "mentionedUserId", USER_ID.toString()));
|
||||||
|
|
||||||
|
List<ActivityFeedRow> rows = auditLogQueryRepository.findRolledUpActivityFeed(USER_ID.toString(), 40);
|
||||||
|
|
||||||
|
assertThat(rows).hasSize(1);
|
||||||
|
assertThat(rows.get(0).getCommentId()).isEqualTo(commentId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void rolledUpFeed_commentId_is_null_for_non_comment_kinds() {
|
||||||
|
insertUserAndDocs();
|
||||||
|
insertAuditEvent(USER_ID, DOC_ID, "TEXT_SAVED",
|
||||||
|
Instant.parse("2026-04-20T10:00:00Z"), Map.of("blockId", "ccc", "pageNumber", "1"));
|
||||||
|
|
||||||
|
List<ActivityFeedRow> rows = auditLogQueryRepository.findRolledUpActivityFeed(USER_ID.toString(), 40);
|
||||||
|
|
||||||
|
assertThat(rows).hasSize(1);
|
||||||
|
assertThat(rows.get(0).getCommentId()).isNull();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void youMentioned_is_false_when_mention_created_payload_targets_different_user() {
|
void youMentioned_is_false_when_mention_created_payload_targets_different_user() {
|
||||||
insertUserAndDocs();
|
insertUserAndDocs();
|
||||||
|
|||||||
@@ -107,6 +107,7 @@ class DashboardServiceTest {
|
|||||||
public boolean isYouParticipated() { return false; }
|
public boolean isYouParticipated() { return false; }
|
||||||
public int getCount() { return 1; }
|
public int getCount() { return 1; }
|
||||||
public Instant getHappenedAtUntil() { return null; }
|
public Instant getHappenedAtUntil() { return null; }
|
||||||
|
public UUID getCommentId() { return null; }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user