mirror of https://github.com/vector-im/riot-web
Inject stickers
parent
7660176079
commit
e96d199b28
|
@ -275,6 +275,12 @@ class ContentMessages {
|
||||||
this.nextId = 0;
|
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) {
|
sendContentToRoom(file, roomId, matrixClient) {
|
||||||
const content = {
|
const content = {
|
||||||
body: file.name || 'Attachment',
|
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:
|
Listens for incoming postMessage requests from embedded widgets. The following API is exposed:
|
||||||
{
|
{
|
||||||
api: "widget",
|
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.
|
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.
|
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.
|
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 must include an "api" field with value of "widget".**
|
||||||
All actions can return an error response instead of the response outlined below.
|
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
|
This API can be used to initiate actions in remote widget instances.
|
||||||
actions in the widget iframe, and request data from the widget instance.
|
|
||||||
|
ACTIONS
|
||||||
|
=======
|
||||||
|
|
||||||
Outbound actions use the "widget_client" API key / name, which must be included
|
Outbound actions use the "widget_client" API key / name, which must be included
|
||||||
on all requests.
|
on all requests.
|
||||||
|
@ -133,7 +138,7 @@ screenshot
|
||||||
|
|
||||||
Request a screenshot from the widget (if supported).
|
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.
|
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.
|
The screenshot is returned as a Blob object.
|
||||||
|
|
||||||
|
|
|
@ -459,6 +459,9 @@ module.exports = React.createClass({
|
||||||
case 'message_sent':
|
case 'message_sent':
|
||||||
this._checkIfAlone(this.state.room);
|
this._checkIfAlone(this.state.room);
|
||||||
break;
|
break;
|
||||||
|
case 'inject_sticker':
|
||||||
|
this.injectSticker(payload.url, payload.info, payload.text);
|
||||||
|
break;
|
||||||
case 'picture_snapshot':
|
case 'picture_snapshot':
|
||||||
this.uploadFile(payload.file);
|
this.uploadFile(payload.file);
|
||||||
break;
|
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) {
|
onSearch: function(term, scope) {
|
||||||
this.setState({
|
this.setState({
|
||||||
searchTerm: term,
|
searchTerm: term,
|
||||||
|
|
Loading…
Reference in New Issue