-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(studio): add support for audio and video content-types (#4816)
* feat(studio): add support for audio and video content-types * add support for file preview * add warning for audio content-type * minor ui change * migration and change default setting * adjust default in code * feat(studio): add support for video content-type (#4820) Co-authored-by: Samuel Massé <samuelmasse4@gmail.com> * migration for bots * pr comments * fix migration * _merge * us extension instead of mime-type for filters * small fix * pr comments * remove channel-vonage config schema file * pr comments Co-authored-by: Samuel Massé <59894025+samuelmasse@users.noreply.github.com> Co-authored-by: Samuel Massé <samuelmasse4@gmail.com>
- Loading branch information
1 parent
aaf8873
commit 95ba80d
Showing
45 changed files
with
612 additions
and
231 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
const base = require('./_base') | ||
const path = require('path') | ||
const utils = require('./_utils') | ||
|
||
function render(data) { | ||
const events = [] | ||
|
||
if (data.typing) { | ||
events.push({ | ||
type: 'typing', | ||
value: data.typing | ||
}) | ||
} | ||
|
||
return [ | ||
...events, | ||
{ | ||
type: 'audio', | ||
title: data.title, | ||
url: utils.formatURL(data.BOT_URL, data.audio), | ||
collectFeedback: data.collectFeedback | ||
} | ||
] | ||
} | ||
|
||
function renderElement(data, channel) { | ||
// rendering is handled by channel-vonage | ||
if (channel === 'vonage') { | ||
return data | ||
} else { | ||
return render(data) | ||
} | ||
} | ||
|
||
module.exports = { | ||
id: 'builtin_audio', | ||
group: 'Built-in Audio', | ||
title: 'Audio', | ||
|
||
jsonSchema: { | ||
description: 'module.builtin.types.audio.description', | ||
type: 'object', | ||
$subtype: 'audio', | ||
required: ['audio'], | ||
properties: { | ||
audio: { | ||
type: 'string', | ||
$subtype: 'audio', | ||
$filter: '.mp3', | ||
title: 'module.builtin.types.audio.title' | ||
}, | ||
title: { | ||
type: 'string', | ||
title: 'module.builtin.types.audio.audioLabel' | ||
}, | ||
...base.typingIndicators | ||
} | ||
}, | ||
|
||
uiSchema: { | ||
title: { | ||
'ui:field': 'i18n_field' | ||
} | ||
}, | ||
|
||
computePreviewText: formData => { | ||
if (!formData.audio) { | ||
return | ||
} | ||
|
||
const link = utils.formatURL(formData.BOT_URL, formData.audio) | ||
const title = formData.title ? ' | ' + formData.title : '' | ||
let fileName = '' | ||
|
||
if (utils.isUrl(link)) { | ||
fileName = path.basename(formData.audio) | ||
if (fileName.includes('-')) { | ||
fileName = fileName | ||
.split('-') | ||
.slice(1) | ||
.join('-') | ||
} | ||
return `Audio: (${fileName}) ${title}` | ||
} else { | ||
return `Expression: ${link}${title}` | ||
} | ||
}, | ||
|
||
renderElement: renderElement | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
const base = require('./_base') | ||
const path = require('path') | ||
const utils = require('./_utils') | ||
|
||
function render(data) { | ||
const events = [] | ||
|
||
if (data.typing) { | ||
events.push({ | ||
type: 'typing', | ||
value: data.typing | ||
}) | ||
} | ||
|
||
return [ | ||
...events, | ||
{ | ||
type: 'video', | ||
title: data.title, | ||
url: utils.formatURL(data.BOT_URL, data.video), | ||
collectFeedback: data.collectFeedback | ||
} | ||
] | ||
} | ||
|
||
function renderElement(data, channel) { | ||
// rendering is handled by channel-vonage | ||
if (channel === 'vonage') { | ||
return data | ||
} else { | ||
return render(data) | ||
} | ||
} | ||
|
||
module.exports = { | ||
id: 'builtin_video', | ||
group: 'Built-in Video', | ||
title: 'Video', | ||
|
||
jsonSchema: { | ||
description: 'module.builtin.types.video.description', | ||
type: 'object', | ||
$subtype: 'video', | ||
required: ['video'], | ||
properties: { | ||
video: { | ||
type: 'string', | ||
$subtype: 'video', | ||
$filter: '.mp4', | ||
title: 'module.builtin.types.video.title' | ||
}, | ||
title: { | ||
type: 'string', | ||
title: 'module.builtin.types.video.videoLabel' | ||
}, | ||
...base.typingIndicators | ||
} | ||
}, | ||
|
||
uiSchema: { | ||
title: { | ||
'ui:field': 'i18n_field' | ||
} | ||
}, | ||
|
||
computePreviewText: formData => { | ||
if (!formData.video) { | ||
return | ||
} | ||
|
||
const link = utils.formatURL(formData.BOT_URL, formData.video) | ||
const title = formData.title ? ' | ' + formData.title : '' | ||
let fileName = '' | ||
|
||
if (utils.isUrl(link)) { | ||
fileName = path.basename(formData.video) | ||
if (fileName.includes('-')) { | ||
fileName = fileName | ||
.split('-') | ||
.slice(1) | ||
.join('-') | ||
} | ||
return `Video: (${fileName}) ${title}` | ||
} else { | ||
return `Expression: ${link}${title}` | ||
} | ||
}, | ||
|
||
renderElement: renderElement | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.