From 9afd43a42d2c4205eea2284e30e95503ffd428c2 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Thu, 10 Mar 2022 17:15:09 -0600 Subject: [PATCH] Normalize Attachment entities as Immutable.Record --- .../normalizers/__tests__/status-test.js | Bin 5994 -> 5860 bytes app/soapbox/normalizers/status.ts | 16 ++++++++++++++-- .../reducers/__tests__/statuses-test.js | Bin 7136 -> 6964 bytes 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/app/soapbox/normalizers/__tests__/status-test.js b/app/soapbox/normalizers/__tests__/status-test.js index f3c836f2313d396904b3dd3ccbd210584f2fbc5f..578e71dc44d86f52cdb57e5f699a118dbea9a61a 100644 GIT binary patch delta 289 zcmaE*_e6I?E<0oNWI0ZW&AsgEj4XMjIXRQ#d6YJrb1ES5u5oEVc$?#SoEZ5)s&u#% zfS@+knrq@k%gMIl?2|qD1ScO8RheAKcThwxH#H?QF+Q=RBr!Q7H#M)M*qUpyp|~(l zab{Jjrd~uo^IFHeK&eD^ATu{JH#NSbvLIDG yRugKndSXFAPG)jqNoIbYeuZvcYOyX*wff`)Q9X8$J;s`vlO@H}HqYTd#|{AE5nfgR delta 150 zcmaE&`$}&^F8kyx7SYMPT-=-6*wq;)hjGbFzQ^vpc{_&B#EX`b_w%z)zRDvwc_FjXWKrI2lMnFlX%v?vmXsFjrKgr? vsOP4pWG2QZmXstWXXK{ll@zOMYU-8byB3xv=1e}zBRTmXoAhQe{&VaAu$wa2 diff --git a/app/soapbox/normalizers/status.ts b/app/soapbox/normalizers/status.ts index 7272062652..ad447f8d25 100644 --- a/app/soapbox/normalizers/status.ts +++ b/app/soapbox/normalizers/status.ts @@ -66,6 +66,19 @@ const PollRecord = ImmutableRecord({ voted: false, }); +// https://docs.joinmastodon.org/entities/attachment/ +const AttachmentRecord = ImmutableRecord({ + blurhash: undefined, + description: '', + id: '', + meta: ImmutableMap(), + pleroma: ImmutableMap(), + preview_url: '', + remote_url: null, + type: 'unknown', + url: '', +}); + // Ensure attachments have required fields // https://docs.joinmastodon.org/entities/attachment/ const normalizeAttachment = (attachment: ImmutableMap) => { @@ -78,10 +91,9 @@ const normalizeAttachment = (attachment: ImmutableMap) => { const base = ImmutableMap({ url, preview_url: url, - remote_url: url, }); - return attachment.mergeWith(mergeDefined, base); + return AttachmentRecord(attachment.mergeWith(mergeDefined, base)); }; const normalizeAttachments = (status: ImmutableMap) => { diff --git a/app/soapbox/reducers/__tests__/statuses-test.js b/app/soapbox/reducers/__tests__/statuses-test.js index 3ea21ab649533eb04d2dfacba229dd9b2a7a47d2..130aa4ec6275315dda6d5473f59c8c859cbecccf 100644 GIT binary patch delta 429 zcmaE0zQxQvGq)hWs6?TfOF_Xmu|OfQSiv(lx3nZNDJK=k*8vI#r6%VWrJ%?_gg}yM zMftg2!8%+Ub!RYf!gX#w%Jhk4^FDSjMwYzNoSez0dDJ%db7~;*thfyzyv?V1{22K_ zszAnpKyB>gM!qO9y^?&dU=2-8Anlu2lAPh6l$DxXGI^(%tYlhdMQX7^Ku#*q@?>ZPZaXiRn#5E0eX%S}zmOpHfTYRxsdQ9^`Q zuQ;QFur33jP-;aXuEo1K|xMt da$-qlex81XZeD7!F3@|E53q@Do+RMM4FClbki`H1 delta 242 zcmdmD_P|^>Gq)hWs6?S!!8fr$A+cD&GdH)iBrz!`70B072ue-PFG|r-NGr2xrs||vmd7hh$A~$fy-la6PF)|BQyCg zmoHfM7dKc|X7XtsPv+WK&B+G5QIjvSsIlavCYDV;z$?b4keHL7mpb`9zujaJzFCv+ zFmpp~*C;MYEGaG4%S}zmOpH$~DM?Ju$W6^FDFzuLH~A2su(*zbI)