File tree Expand file tree Collapse file tree 8 files changed +83
-67
lines changed Expand file tree Collapse file tree 8 files changed +83
-67
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " libfb" ,
3- "version" : " 2.2 .0" ,
3+ "version" : " 2.3 .0" ,
44 "description" : " Facebook MQTT library for Node.js" ,
55 "repository" : " https://github.com/ChatPlug/libfb-js" ,
66 "main" : " dist/index.js" ,
2525 "node-fetch" : " ^2.6.0" ,
2626 "strict-event-emitter-types" : " ^2.0.0" ,
2727 "thrift" : " ^0.12.0" ,
28- "tslib" : " ^1.9.3 "
28+ "tslib" : " ^1.10.0 "
2929 },
3030 "devDependencies" : {
3131 "@types/chai" : " ^4.1.7" ,
3232 "@types/debug" : " ^4.1.4" ,
3333 "@types/long" : " ^4.0.0" ,
3434 "@types/mocha" : " ^5.2.7" ,
35- "@types/node" : " ^12.0.4 " ,
36- "@types/node-fetch" : " ^2.3.4 " ,
35+ "@types/node" : " ^12.0.10 " ,
36+ "@types/node-fetch" : " ^2.3.7 " ,
3737 "@types/node-int64" : " ^0.4.29" ,
3838 "@types/thrift" : " ^0.10.8" ,
3939 "chai" : " ^4.2.0" ,
40- "console-stamp" : " ^0.2.7 " ,
40+ "console-stamp" : " ^0.2.9 " ,
4141 "mocha" : " ^6.1.4" ,
4242 "shx" : " ^0.3.2" ,
43- "ts-node" : " ^8.2 .0" ,
44- "tslint" : " ^5.17 .0" ,
43+ "ts-node" : " ^8.3 .0" ,
44+ "tslint" : " ^5.18 .0" ,
4545 "tslint-config-standard" : " ^8.0.1" ,
4646 "typedoc" : " ^0.14.2" ,
4747 "typedoc-plugin-as-member-of" : " ^1.0.2" ,
4848 "typedoc-plugin-sourcefile-url" : " ^1.0.4" ,
49- "typescript" : " ^3.5.1 "
49+ "typescript" : " ^3.5.2 "
5050 },
5151 "license" : " MIT"
5252}
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 '
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ export interface XMAAttachment extends Attachment {
2626export interface UnavailableXMA extends XMAAttachment {
2727 type : 'UnavailableXMA'
2828 message : string
29+ attach : any
2930}
3031export interface StoryXMA extends XMAAttachment {
3132 type : 'StoryXMA'
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 @@ -11,10 +11,11 @@ import vm from 'vm'
1111
1212export default function parseXMAAttachment ( attach : any ) {
1313 attach = attach [ Object . keys ( attach ) [ 0 ] ] . story_attachment
14- if ( ! attach . target ) {
14+ if ( ! attach . target || ! attach . target . __type__ ) {
1515 return {
1616 type : 'UnavailableXMA' ,
17- message : attach . description . text
17+ message : attach . description . text ,
18+ attach
1819 } as UnavailableXMA
1920 }
2021 const type = attach . target . __type__ . name
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