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:
parent
902aea8bc4
commit
60bed46014
8 changed files with 66 additions and 7 deletions
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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 };
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue