Support avatar_url in the scalar client API (#8550)
* Support avatar_url in the scalar client API Signed-off-by: Oliver Sand <oliver.sand@nordeck.net> * Fix return type * Remove automatic upload * Remove return type * Fix indentionpull/28788/head^2
parent
efc36acf93
commit
f7ba3f07cd
|
@ -148,6 +148,7 @@ Request:
|
||||||
can configure/lay out the widget in different ways. All widgets must have a type.
|
can configure/lay out the widget in different ways. All widgets must have a type.
|
||||||
- `name` (String) is an optional human-readable string about the widget.
|
- `name` (String) is an optional human-readable string about the widget.
|
||||||
- `data` (Object) is some optional data about the widget, and can contain arbitrary key/value pairs.
|
- `data` (Object) is some optional data about the widget, and can contain arbitrary key/value pairs.
|
||||||
|
- `avatar_url` (String) is some optional mxc: URI pointing to the avatar of the widget.
|
||||||
Response:
|
Response:
|
||||||
{
|
{
|
||||||
success: true
|
success: true
|
||||||
|
@ -319,6 +320,7 @@ function setWidget(event: MessageEvent<any>, roomId: string): void {
|
||||||
const widgetUrl = event.data.url;
|
const widgetUrl = event.data.url;
|
||||||
const widgetName = event.data.name; // optional
|
const widgetName = event.data.name; // optional
|
||||||
const widgetData = event.data.data; // optional
|
const widgetData = event.data.data; // optional
|
||||||
|
const widgetAvatarUrl = event.data.avatar_url; // optional
|
||||||
const userWidget = event.data.userWidget;
|
const userWidget = event.data.userWidget;
|
||||||
|
|
||||||
// both adding/removing widgets need these checks
|
// both adding/removing widgets need these checks
|
||||||
|
@ -337,6 +339,14 @@ function setWidget(event: MessageEvent<any>, roomId: string): void {
|
||||||
sendError(event, _t("Unable to create widget."), new Error("Optional field 'data' must be an Object."));
|
sendError(event, _t("Unable to create widget."), new Error("Optional field 'data' must be an Object."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (widgetAvatarUrl !== undefined && typeof widgetAvatarUrl !== 'string') {
|
||||||
|
sendError(
|
||||||
|
event,
|
||||||
|
_t("Unable to create widget."),
|
||||||
|
new Error("Optional field 'avatar_url' must be a string."),
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (typeof widgetType !== 'string') {
|
if (typeof widgetType !== 'string') {
|
||||||
sendError(event, _t("Unable to create widget."), new Error("Field 'type' must be a string."));
|
sendError(event, _t("Unable to create widget."), new Error("Field 'type' must be a string."));
|
||||||
return;
|
return;
|
||||||
|
@ -364,7 +374,8 @@ function setWidget(event: MessageEvent<any>, roomId: string): void {
|
||||||
if (!roomId) {
|
if (!roomId) {
|
||||||
sendError(event, _t('Missing roomId.'), null);
|
sendError(event, _t('Missing roomId.'), null);
|
||||||
}
|
}
|
||||||
WidgetUtils.setRoomWidget(roomId, widgetId, widgetType, widgetUrl, widgetName, widgetData).then(() => {
|
WidgetUtils.setRoomWidget(roomId, widgetId, widgetType, widgetUrl, widgetName, widgetData, widgetAvatarUrl)
|
||||||
|
.then(() => {
|
||||||
sendResponse(event, {
|
sendResponse(event, {
|
||||||
success: true,
|
success: true,
|
||||||
});
|
});
|
||||||
|
|
|
@ -286,6 +286,7 @@ export default class WidgetUtils {
|
||||||
widgetUrl?: string,
|
widgetUrl?: string,
|
||||||
widgetName?: string,
|
widgetName?: string,
|
||||||
widgetData?: object,
|
widgetData?: object,
|
||||||
|
widgetAvatarUrl?: string,
|
||||||
) {
|
) {
|
||||||
let content;
|
let content;
|
||||||
|
|
||||||
|
@ -299,6 +300,7 @@ export default class WidgetUtils {
|
||||||
url: widgetUrl,
|
url: widgetUrl,
|
||||||
name: widgetName,
|
name: widgetName,
|
||||||
data: widgetData,
|
data: widgetData,
|
||||||
|
avatar_url: widgetAvatarUrl,
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
content = {};
|
content = {};
|
||||||
|
|
Loading…
Reference in New Issue