Handle sticker message payloads
This commit is contained in:
parent
b85efa08ce
commit
eb4053bc99
3 changed files with 26 additions and 4 deletions
|
@ -253,8 +253,10 @@ export default class WidgetMessaging extends MatrixPostMessageApi {
|
||||||
// Message endpoint already registered
|
// Message endpoint already registered
|
||||||
console.warn("Endpoint already registered");
|
console.warn("Endpoint already registered");
|
||||||
return;
|
return;
|
||||||
|
} else {
|
||||||
|
console.warn(`Adding widget messaging endpoint for ${widgetId}`);
|
||||||
|
global.mxWidgetMessagingMessageEndpoints.push(endpoint);
|
||||||
}
|
}
|
||||||
global.mxWidgetMessagingMessageEndpoints.push(endpoint);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -322,6 +324,9 @@ export default class WidgetMessaging extends MatrixPostMessageApi {
|
||||||
api: "widget",
|
api: "widget",
|
||||||
version: WIDGET_API_VERSION,
|
version: WIDGET_API_VERSION,
|
||||||
});
|
});
|
||||||
|
} else if (action === 'sticker_message') {
|
||||||
|
console.warn('got widget sticker message', widgetId);
|
||||||
|
dis.dispatch({action: 'sticker_message', data: event.data.data});
|
||||||
} else {
|
} else {
|
||||||
console.warn("Widget postMessage event unhandled");
|
console.warn("Widget postMessage event unhandled");
|
||||||
this.sendError(event, {message: "The postMessage was unhandled"});
|
this.sendError(event, {message: "The postMessage was unhandled"});
|
||||||
|
|
|
@ -459,8 +459,11 @@ 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':
|
case 'post_sticker_message':
|
||||||
this.injectSticker(payload.url, payload.info, payload.text);
|
this.injectSticker(
|
||||||
|
payload.data.content.url,
|
||||||
|
payload.data.content.info,
|
||||||
|
payload.data.description || payload.data.name);
|
||||||
break;
|
break;
|
||||||
case 'picture_snapshot':
|
case 'picture_snapshot':
|
||||||
this.uploadFile(payload.file);
|
this.uploadFile(payload.file);
|
||||||
|
|
|
@ -333,7 +333,7 @@ export default React.createClass({
|
||||||
* Called when widget iframe has finished loading
|
* Called when widget iframe has finished loading
|
||||||
*/
|
*/
|
||||||
_onLoaded() {
|
_onLoaded() {
|
||||||
// console.warn("App frame", this.refs.appFrame.contentWindow);
|
console.warn("App frame loaded", this.props.id);
|
||||||
this.widgetMessaging = new WidgetMessaging(this.props.id, this.refs.appFrame.contentWindow);
|
this.widgetMessaging = new WidgetMessaging(this.props.id, this.refs.appFrame.contentWindow);
|
||||||
this.widgetMessaging.startListening();
|
this.widgetMessaging.startListening();
|
||||||
this.widgetMessaging.addEndpoint(this.props.id, this.props.url);
|
this.widgetMessaging.addEndpoint(this.props.id, this.props.url);
|
||||||
|
@ -345,8 +345,22 @@ export default React.createClass({
|
||||||
console.log("Failed to get widget capabilities", this.widgetId, err);
|
console.log("Failed to get widget capabilities", this.widgetId, err);
|
||||||
});
|
});
|
||||||
this.setState({loading: false});
|
this.setState({loading: false});
|
||||||
|
|
||||||
|
dis.register(this._onAction);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_onAction(payload) {
|
||||||
|
switch (payload) {
|
||||||
|
case payload.action === 'sticker_message':
|
||||||
|
if (this._hasCapability('sticker_message')) {
|
||||||
|
dis.dispatch({action: 'post_sticker_message', data: payload.data});
|
||||||
|
} else {
|
||||||
|
console.warn('Ignoring sticker message. Invalid capability');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set remote content title on AppTile
|
* Set remote content title on AppTile
|
||||||
* @param {string} url Url to check for title
|
* @param {string} url Url to check for title
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue