fix: handle the attachment when the value is null (#5130)

* fix: handle the attachment when the value is null

* filter properly before pass to map
This commit is contained in:
Reinaldo Neto 2023-07-14 14:17:48 -03:00 committed by GitHub
parent 48acd0669e
commit b420b51272
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 8 deletions

View File

@ -9,14 +9,17 @@ function normalizeAttachments(msg: TMsg) {
if (typeof msg.attachments !== typeof [] || !msg.attachments || !msg.attachments.length) { if (typeof msg.attachments !== typeof [] || !msg.attachments || !msg.attachments.length) {
msg.attachments = []; msg.attachments = [];
} }
msg.attachments = msg.attachments.map(att => {
att.fields = att.fields || []; msg.attachments = msg.attachments
if (att.ts) { .filter(att => !!att)
att.ts = moment(att.ts).toDate(); .map(att => {
} att.fields = att.fields || [];
att = normalizeAttachments(att as TMsg); if (att.ts) {
return att; att.ts = moment(att.ts).toDate();
}); }
att = normalizeAttachments(att as TMsg);
return att;
});
return msg; return msg;
} }