diff --git a/package.json b/package.json
index a07e9225c0..9819d7c4dd 100644
--- a/package.json
+++ b/package.json
@@ -13,7 +13,7 @@
"clean": "rm -rf built",
"minify": "webpack --optimize-minimize --optimize-dedupe",
"start": "http-server -p 8000",
- "test": "echo \"Error: no test specified\" && exit 1"
+ "test": "mocha"
},
"repository": {
"type": "git",
@@ -42,8 +42,5 @@
"ts-loader": "^0.8.2",
"typescript": "^2.0.8",
"webpack": "^1.13.1"
- },
- "scripts": {
- "test": "mocha"
}
}
diff --git a/src/Attachment.tsx b/src/Attachment.tsx
index 16501fe3e8..596722f5dc 100644
--- a/src/Attachment.tsx
+++ b/src/Attachment.tsx
@@ -42,8 +42,8 @@ export const AttachmentView = (props: {
{ buttons.map(button =>
) }
;
- const imageWithOnLoad = (url: string) =>
-
props.onImageLoad() } />;
+ const imageWithOnLoad = (url: string, thumbnailUrl?: string, autoPlay?:boolean, loop?: boolean) =>
+
props.onImageLoad() } />;
const audio = (audioUrl: string, autoPlay?:boolean, loop?: boolean) =>
;
@@ -54,6 +54,15 @@ export const AttachmentView = (props: {
const attachedImage = (images?: { url: string }[]) =>
images && images.length > 0 && imageWithOnLoad(images[0].url);
+ const isGifMedia = (url: string): boolean => {
+ return url.slice((url.lastIndexOf(".") - 1 >>> 0) + 2).toLowerCase() == 'gif';
+ }
+
+ const isUnsupportedCardContentType = (contentType: string): boolean => {
+ let searchPattern = new RegExp('^application/vnd\.microsoft\.card\.', 'i');
+ return searchPattern.test(contentType);
+ }
+
switch (attachment.contentType) {
case "application/vnd.microsoft.card.hero":
if (!attachment.content)
@@ -96,6 +105,22 @@ export const AttachmentView = (props: {
);
+ case "application/vnd.microsoft.card.animation":
+ if (!attachment.content || !attachment.content.media || attachment.content.media.length === 0)
+ return null;
+
+ let contentFunction = isGifMedia(attachment.content.media[0].url) ? imageWithOnLoad : videoWithOnLoad;
+
+ return (
+
+ { contentFunction(attachment.content.media[0].url, attachment.content.image ? attachment.content.image.url : null, attachment.content.autostart, attachment.content.autoloop) }
+
{ attachment.content.title }
+
{ attachment.content.subtitle }
+
{ attachment.content.text }
+ { buttons(attachment.content.buttons) }
+
+ );
+
case "application/vnd.microsoft.card.audio":
if (!attachment.content || !attachment.content.media || attachment.content.media.length === 0)
return null;
@@ -165,7 +190,11 @@ export const AttachmentView = (props: {
return videoWithOnLoad(attachment.contentUrl);
default:
- return [File of type '{ (attachment as any).contentType }'];
-
+ if(isUnsupportedCardContentType(attachment['contentType'])) {
+ return [Unknown Card '{ (attachment as any).contentType }'];
+ }
+ else {
+ return [File of type '{ (attachment as any).contentType }'];
+ }
}
}
\ No newline at end of file
diff --git a/src/BotConnection.ts b/src/BotConnection.ts
index e63da540a6..e5092ebd3a 100644
--- a/src/BotConnection.ts
+++ b/src/BotConnection.ts
@@ -104,7 +104,21 @@ export interface VideoCard {
}
}
-export type Attachment = Media | HeroCard | Thumbnail | Signin | Receipt | AudioCard | VideoCard;
+export interface AnimationCard {
+ contentType: "application/vnd.microsoft.card.animation",
+ content: {
+ title?: string,
+ subtitle?: string,
+ text?: string,
+ media?: { url: string, profile?: string }[],
+ buttons?: Button[],
+ image?: { url: string, alt?: string },
+ autoloop?: boolean,
+ autostart?: boolean
+ }
+}
+
+export type Attachment = Media | HeroCard | Thumbnail | Signin | Receipt | AudioCard | VideoCard | AnimationCard;
export interface User {
id: string,