-
Notifications
You must be signed in to change notification settings - Fork 110
Open
Description
Ticket: Conversation Atomic Edits and Hiding by Index
Description,
We need to introduce the ability to atomically edit or hide individual conversation comments.
Unlike the previous "append-only" strictness, users (authors) need to be able to correct mistakes or hide inappropriate comments.
Crucially, these operations must target a comment by its index relative to the organization's conversation history (e.g., "edit the 3rd comment").
Acceptance Criteria / TODOs,
Database / Schema Changes (src/model/conversation.js)
- Add Fields:
-
is_active: Boolean, defaulttrue. (Used for hiding/soft-deletion). -
edited_at: Date. (Timestamp of last edit). -
editor_uuid: String. (UUID of the user who performed the edit/hide).
-
Backend Logic (src/repositories/conversationRepository.js)
- Implement
findByTargetUUIDAndIndex:- Logic: Find all conversations for
target_uuid, sort bycreated_at(ascending) + UUID (ascending) for stability. - Use
.skip(index).limit(1)to retrieve the specific document. - Important: The index must apply to all records (active and inactive) to ensure indices remain stable even when items are hidden.
- Logic: Find all conversations for
- Implement
editConversationByIndex:- Update the
body,edited_at, andeditor_uuid.
- Update the
- Implement
hideConversationByIndex:- Set
is_activetofalse, updateeditor_uuid.
- Set
API Changes (src/controller/registry-org.controller or conversation.controller)
- New Endpoint:
PUT /api/registryOrg/:shortname/conversation/:index(or similar path structure linked to Org).- Permissions:
- Users can edit/hide their own comments.
- Secretariat can edit/hide any comment? (Clarify if needed, assume yes for moderation).
- Payload:
-
body: String (optional, for editing). -
is_active: Boolean (optional, for hiding).
-
- Logic:
- Resolve Org UUID from
shortname. - Call
repo.findByTargetUUIDAndIndex. - Verify ownership/permissions.
- Perform update.
- Resolve Org UUID from
- Permissions:
Testing,
- Unit Tests:
- Verify index 0 returns the first comment, index 1 the second, even if index 0 is hidden.
- Verify access controls (User A cannot edit User B's comment).
- Verify atomic updates (body changes, timestamp updates).
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
Needs Triage
Status
In Progress