1
0
mirror of https://github.com/matrix-org/matrix-react-sdk.git synced 2025-11-07 10:46:24 +03:00

Ensure widgets always have a sender associated with them

Fixes https://github.com/vector-im/riot-web/issues/11419
This commit is contained in:
Travis Ralston
2019-11-18 13:16:36 -07:00
parent f543a113cf
commit f5ec9eb8f4
3 changed files with 8 additions and 4 deletions

View File

@@ -400,7 +400,7 @@ export default class WidgetUtils {
return client.setAccountData('m.widgets', userWidgets);
}
static makeAppConfig(appId, app, sender, roomId) {
static makeAppConfig(appId, app, senderUserId, roomId) {
const myUserId = MatrixClientPeg.get().credentials.userId;
const user = MatrixClientPeg.get().getUser(myUserId);
const params = {
@@ -413,6 +413,11 @@ export default class WidgetUtils {
'$theme': SettingsStore.getValue("theme"),
};
if (!senderUserId) {
throw new Error("Widgets must be created by someone - provide a senderUserId");
}
app.creatorUserId = senderUserId;
app.id = appId;
app.name = app.name || app.type;
@@ -425,7 +430,6 @@ export default class WidgetUtils {
}
app.url = encodeUri(app.url, params);
app.creatorUserId = (sender && sender.userId) ? sender.userId : null;
return app;
}