From 8be4bb74093c7e54fafa48df2ce7561b06dba45b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Sat, 9 Jul 2022 00:15:26 +0200 Subject: [PATCH] Ensure attachment meta is not null MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- app/soapbox/normalizers/attachment.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/soapbox/normalizers/attachment.ts b/app/soapbox/normalizers/attachment.ts index 06fba73ad8..23cce3686c 100644 --- a/app/soapbox/normalizers/attachment.ts +++ b/app/soapbox/normalizers/attachment.ts @@ -46,8 +46,18 @@ const normalizeUrls = (attachment: ImmutableMap) => { return attachment.mergeWith(mergeDefined, base); }; +// Ensure meta is not null +const normalizeMeta = (attachment: ImmutableMap) => { + const meta = ImmutableMap().merge(attachment.get('meta')); + + return attachment.set('meta', meta); +}; + export const normalizeAttachment = (attachment: Record) => { return AttachmentRecord( - normalizeUrls(ImmutableMap(fromJS(attachment))), + ImmutableMap(fromJS(attachment)).withMutations((attachment: ImmutableMap) => { + normalizeUrls(attachment); + normalizeMeta(attachment); + }), ); };