Add an action to upload media files according to MSC4039 (#11311)

Signed-off-by: Dominik Henneke <dominik.henneke@nordeck.net>
This commit is contained in:
Dominik Henneke 2023-09-21 21:03:22 +02:00 committed by GitHub
parent 902aea8bc4
commit 60bed46014
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 66 additions and 7 deletions

View file

@ -136,6 +136,7 @@ export default class ModalWidgetDialog extends React.PureComponent<IProps, IStat
clientId: ELEMENT_CLIENT_ID,
clientTheme: SettingsStore.getValue("theme"),
clientLanguage: getUserLanguage(),
baseUrl: MatrixClientPeg.safeGet().baseUrl,
});
const parsed = new URL(templated);

View file

@ -218,6 +218,7 @@ export class StopGapWidget extends EventEmitter {
clientTheme: SettingsStore.getValue("theme"),
clientLanguage: getUserLanguage(),
deviceId: this.client.getDeviceId() ?? undefined,
baseUrl: this.client.baseUrl,
};
const templated = this.mockWidget.getCompleteUrl(Object.assign(defaults, fromCustomisation), opts?.asPopout);

View file

@ -32,6 +32,7 @@ import {
WidgetEventCapability,
WidgetKind,
ISearchUserDirectoryResult,
IGetMediaConfigResult,
} from "matrix-widget-api";
import {
ClientEvent,
@ -523,4 +524,18 @@ export class StopGapWidgetDriver extends WidgetDriver {
})),
};
}
public async getMediaConfig(): Promise<IGetMediaConfigResult> {
const client = MatrixClientPeg.safeGet();
return await client.getMediaConfig();
}
public async uploadFile(file: XMLHttpRequestBodyInit): Promise<{ contentUri: string }> {
const client = MatrixClientPeg.safeGet();
const uploadResult = await client.uploadContent(file);
return { contentUri: uploadResult.content_uri };
}
}