From 7437a2fb452a3cf191780a9f7db70e6875c64f1f Mon Sep 17 00:00:00 2001 From: MartinBraquet Date: Fri, 13 Feb 2026 17:36:12 +0100 Subject: [PATCH] Fix DM not parsed in data export --- backend/api/src/get-private-messages.ts | 4 ++-- backend/api/src/get-user-data-export.ts | 2 ++ backend/shared/src/supabase/messages.ts | 9 +++++---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/backend/api/src/get-private-messages.ts b/backend/api/src/get-private-messages.ts index 873af9c..b6de994 100644 --- a/backend/api/src/get-private-messages.ts +++ b/backend/api/src/get-private-messages.ts @@ -101,7 +101,7 @@ export const getChannelMessagesEndpoint: APIHandler<'get-channel-messages'> = as export async function getChannelMessages(props: { channelId: number; - limit: number; + limit?: number; id?: number | undefined; userId: string; }) { @@ -119,7 +119,7 @@ export async function getChannelMessages(props: { and ($4 is null or id > $4) and not visibility = 'system_status' order by created_time desc - limit $3 + ${limit ? 'limit $3' : ''} `, [channelId, userId, limit, id], convertPrivateChatMessage diff --git a/backend/api/src/get-user-data-export.ts b/backend/api/src/get-user-data-export.ts index c04445c..8df3df3 100644 --- a/backend/api/src/get-user-data-export.ts +++ b/backend/api/src/get-user-data-export.ts @@ -3,6 +3,7 @@ import {createSupabaseDirectClient} from 'shared/supabase/init' import {Row} from 'common/supabase/utils' import {getLikesAndShipsMain} from './get-likes-and-ships' import {parseJsonContentToText} from 'common/util/parse' +import {parseMessageObject} from "shared/supabase/messages"; export const getUserDataExport: APIHandler<'me/data'> = async (_, auth) => { const userId = auth.uid @@ -116,6 +117,7 @@ export const getUserDataExport: APIHandler<'me/data'> = async (_, auth) => { [channelIds] ) : [] + for (const message of messages) parseMessageObject(message) const membershipsWithUsernames = channelIds.length ? await pg.manyOrNone( diff --git a/backend/shared/src/supabase/messages.ts b/backend/shared/src/supabase/messages.ts index 04448a4..881bcf2 100644 --- a/backend/shared/src/supabase/messages.ts +++ b/backend/shared/src/supabase/messages.ts @@ -22,10 +22,11 @@ export const convertPrivateChatMessage = (row: Row<'private_user_messages'>) => return message } -type MessageObject = Omit & { id: number; createdTimeTs: string } & { - ciphertext: string; - iv: string; - tag: string +type MessageObject = { + ciphertext: string | null; + iv: string | null; + tag: string | null + content?: any } export function parseMessageObject(message: MessageObject) {