issue: https://linear.app/comm/issue/ENG-3708/add-a-migration-to-populate-target-message-for-sidebar-source
We need the new sidebar_source messages to have their target_message column filled with the id of the original message.
Details
Created new sidebar, checked that the target_message was correctly filled.
Run flow in keyserver/ and lib/
Diff Detail
- Repository
- rCOMM Comm
- Lint
No Lint Coverage - Unit
No Test Coverage
Event Timeline
lib/types/message-types.js | ||
---|---|---|
245 ↗ | (On Diff #25330) |
|
lib/types/message-types.js | ||
---|---|---|
245 ↗ | (On Diff #25330) | I think we don't need to include targetMessageID in *MessageInfo for sidebar source, because we are still keeping it in the content column, and sending it to the client via sourceMessage field. Reactions and edits don't do that, so they need to have targetMessageID in *MessageInfo. An assumption I am working under: We don't want to rewrite the way we handle sidebar source messages (how we obtain the ID of their source message). We just want to have the target_message column filled. |
245 ↗ | (On Diff #25330) | Alternatively, if having both sourceMessage and targetMessageID in SidebarSourceMessageData is redundant and not a good pattern, I could just extract targetMessageID` from message.sourceMessage inside of messageCreator (here) like so let targetMessageID = null; if (messageData.targetMessageID) { targetMessageID = messageData.targetMessageID; } else if (messageData.sourceMessage) { targetMessageID = messageData.sourceMessage.id; } This would require no other changes in the code. |
Address review - change the approach to extracting the source message id in the message creator, from messageData.sourceMessage.id.
Only messageData for sidebar source message has a sourceMessage field, so this shouldn't break anything. If a messageData has targetMessageID, then it will be set correctly as it used to. If a messageData has a sourceMessage then the message must have been a sidebar source message that doesn't have a targetMessageID, and so targetMessageID will be set to messageData.sourceMessage.id. For all other messages targetMessageID will be null, as it used to.