Skip to content

Commit

Permalink
[keyserver] Replace undefined subthread_permissions with null
Browse files Browse the repository at this point in the history
Summary:
When fetching a message for entry action, we weren't selecting `subthread_permissions`. Then the result was passed to `rawMessageInfoFromRows` which uses `JSON.parse` on `subthread_permissions`. When a value is `null`, parsing returns null. But when a value is `undefined`, parsing throws an error.

Modified the code so that we're fetching `NULL` - all the entry messages are different from `messageTypes.CREATE_SUB_THREAD` so they don't have `subthread_permissions`.

https://linear.app/comm/issue/ENG-5684/editing-entries-doesnt-work

Test Plan: Create and edit an entry in the community root - it should work.

Reviewers: ashoat, atul, kamil, inka

Reviewed By: inka

Subscribers: wyilio

Differential Revision: https://phab.comm.dev/D9765
  • Loading branch information
palys-swm committed Nov 9, 2023
1 parent 16501e4 commit 6949cb2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions keyserver/src/fetchers/message-fetchers.js
Original file line number Diff line number Diff line change
Expand Up @@ -661,9 +661,9 @@ async function fetchMessageInfoForEntryAction(
const viewerID = viewer.id;
const query = SQL`
SELECT m.id, m.thread AS threadID, m.content, m.time, m.type, m.creation,
m.user AS creatorID, m.target_message as targetMessageID,
up.id AS uploadID, up.type AS uploadType, up.secret AS uploadSecret,
up.extra AS uploadExtra
m.user AS creatorID, m.target_message AS targetMessageID,
NULL AS subthread_permissions, up.id AS uploadID, up.type AS uploadType,
up.secret AS uploadSecret, up.extra AS uploadExtra
FROM messages m
LEFT JOIN uploads up ON up.container = m.id
LEFT JOIN memberships mm ON mm.thread = m.thread AND mm.user = ${viewerID}
Expand Down

0 comments on commit 6949cb2

Please sign in to comment.