Skip to content

Commit

Permalink
Fixed error when XMA has no type
Browse files Browse the repository at this point in the history
  • Loading branch information
Bjornskjald committed Jun 22, 2019
1 parent 24db6cf commit d62e253
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/types/attachments/XMAAttachment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export interface XMAAttachment extends Attachment {
export interface UnavailableXMA extends XMAAttachment {
type: 'UnavailableXMA'
message: string
attach: any
}
export interface StoryXMA extends XMAAttachment {
type: 'StoryXMA'
Expand Down
5 changes: 3 additions & 2 deletions src/types/attachments/parseXMAAttachment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ import vm from 'vm'

export default function parseXMAAttachment (attach: any) {
attach = attach[Object.keys(attach)[0]].story_attachment
if (!attach.target) {
if (!attach.target || !attach.target.__type__) {
return {
type: 'UnavailableXMA',
message: attach.description.text
message: attach.description.text,
attach
} as UnavailableXMA
}
const type = attach.target.__type__.name
Expand Down

0 comments on commit d62e253

Please sign in to comment.