File tree Expand file tree Collapse file tree 4 files changed +29
-17
lines changed Expand file tree Collapse file tree 4 files changed +29
-17
lines changed Original file line number Diff line number Diff line change @@ -3,4 +3,4 @@ export default interface Attachment {
33}
44export * from './attachments/XMAAttachment'
55export * from './attachments/FileAttachment'
6- export { default as parseAttachment } from './attachments/parseAttachment '
6+ export { default as parseAttachments } from './attachments/parseAttachments '
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ import parseFileAttachment from './parseFileAttachment'
2+ import parseBlobAttachment from './parseBlobAttachment'
3+ import parseXMAAttachment from './parseXMAAttachment'
4+ import { FileAttachment , XMAAttachment } from '../Attachment'
5+
6+ interface Attachments {
7+ fileAttachments : FileAttachment [ ] ,
8+ mediaAttachments : XMAAttachment [ ]
9+ }
10+
11+ export default function parseAttachments ( attachments : any [ ] ) : Attachments {
12+ const result : Attachments = {
13+ fileAttachments : [ ] ,
14+ mediaAttachments : [ ]
15+ }
16+ for ( let attachment of attachments ) {
17+ if ( attachment . mimeType ) result . fileAttachments . push ( parseFileAttachment ( attachment ) )
18+ if ( attachment . mimetype ) result . fileAttachments . push ( parseBlobAttachment ( attachment ) )
19+ if ( attachment . xmaGraphQL ) result . mediaAttachments . push ( parseXMAAttachment ( JSON . parse ( attachment . xmaGraphQL ) ) )
20+ result . mediaAttachments . push ( {
21+ type : 'Unknown' ,
22+ ...attachment
23+ } )
24+ }
25+ return result
26+ }
Original file line number Diff line number Diff line change 1- import { parseAttachment } from '../Attachment'
1+ import { parseAttachments } from '../Attachment'
22import Message , { Mention } from '../Message'
33
44export default function parseDeltaMessage ( delta : any ) {
55 return {
66 threadId : getThreadId ( delta ) ,
7- attachments : delta . attachments ? delta . attachments . map ( parseAttachment ) : [ ] ,
7+ attachments : delta . attachments ? parseAttachments ( delta . attachments ) : [ ] ,
88 authorId : delta . messageMetadata . actorFbId ,
99 id : delta . messageMetadata . messageId ,
1010 timestamp : delta . messageMetadata . timestamp ,
You can’t perform that action at this time.
0 commit comments