Inject stickers
This commit is contained in:
parent
7660176079
commit
e96d199b28
3 changed files with 37 additions and 8 deletions
|
@ -275,6 +275,12 @@ class ContentMessages {
|
|||
this.nextId = 0;
|
||||
}
|
||||
|
||||
sendURLContentToRoom(url, roomId, info, text, matrixClient) {
|
||||
return MatrixClientPeg.get().sendImageMessage(roomId, url, info, text).catch((e) => {
|
||||
console.warn(`Failed to send content with URL ${url} to room ${roomId}`, e);
|
||||
});
|
||||
}
|
||||
|
||||
sendContentToRoom(file, roomId, matrixClient) {
|
||||
const content = {
|
||||
body: file.name || 'Attachment',
|
||||
|
|
|
@ -15,6 +15,9 @@ limitations under the License.
|
|||
*/
|
||||
|
||||
/*
|
||||
POSTMESSAGE API
|
||||
===============
|
||||
|
||||
Listens for incoming postMessage requests from embedded widgets. The following API is exposed:
|
||||
{
|
||||
api: "widget",
|
||||
|
@ -38,7 +41,7 @@ The "api" field is required to use this API, and must be set to "widget" in all
|
|||
|
||||
The "action" determines the format of the request and response. All actions can return an error response.
|
||||
|
||||
Additional data can be sent as additional, abritrary fields. However, typically the data object should be used.
|
||||
Additional data can be sent as abritrary fields. However, typically the data object should be used.
|
||||
|
||||
A success response is an object with zero or more keys.
|
||||
|
||||
|
@ -52,8 +55,8 @@ They look like:
|
|||
}
|
||||
The "message" key should be a human-friendly string.
|
||||
|
||||
INBOUND ACTIONS
|
||||
===============
|
||||
ACTIONS
|
||||
=======
|
||||
** All actions must include an "api" field with value of "widget".**
|
||||
All actions can return an error response instead of the response outlined below.
|
||||
|
||||
|
@ -110,11 +113,13 @@ Example:
|
|||
}
|
||||
|
||||
|
||||
OUTBOUND ACTIONS
|
||||
================
|
||||
OUTBOUND POSTMESSAGE API
|
||||
========================
|
||||
|
||||
In addition to listening for inbound requests, the API can be used to initiate
|
||||
actions in the widget iframe, and request data from the widget instance.
|
||||
This API can be used to initiate actions in remote widget instances.
|
||||
|
||||
ACTIONS
|
||||
=======
|
||||
|
||||
Outbound actions use the "widget_client" API key / name, which must be included
|
||||
on all requests.
|
||||
|
@ -133,7 +138,7 @@ screenshot
|
|||
|
||||
Request a screenshot from the widget (if supported).
|
||||
This can currently only be supported by widgets that have access to all of their DOM tree.
|
||||
For example, widgets that nest further levels of iframes can not support this.
|
||||
For example, widgets that nest further levels of iframes can not support this capability.
|
||||
|
||||
The screenshot is returned as a Blob object.
|
||||
|
||||
|
|
|
@ -459,6 +459,9 @@ module.exports = React.createClass({
|
|||
case 'message_sent':
|
||||
this._checkIfAlone(this.state.room);
|
||||
break;
|
||||
case 'inject_sticker':
|
||||
this.injectSticker(payload.url, payload.info, payload.text);
|
||||
break;
|
||||
case 'picture_snapshot':
|
||||
this.uploadFile(payload.file);
|
||||
break;
|
||||
|
@ -904,6 +907,21 @@ module.exports = React.createClass({
|
|||
});
|
||||
},
|
||||
|
||||
injectSticker: function(url, info, text) {
|
||||
if (MatrixClientPeg.get().isGuest()) {
|
||||
dis.dispatch({action: 'view_set_mxid'});
|
||||
return;
|
||||
}
|
||||
|
||||
ContentMessages.sendURLContentToRoom(url, this.state.room.roomId, info, text, MatrixClientPeg.get())
|
||||
.done(undefined, (error) => {
|
||||
if (error.name === "UnknownDeviceError") {
|
||||
// Let the staus bar handle this
|
||||
return;
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
onSearch: function(term, scope) {
|
||||
this.setState({
|
||||
searchTerm: term,
|
||||
|
|
Loading…
Reference in a new issue