Handle mxc urls for non-encrypted rooms

This commit is contained in:
Jaiwanth 2021-06-29 12:54:44 +05:30
parent 747273cc9c
commit 497d8102e2
5 changed files with 14 additions and 9 deletions

View File

@ -42,8 +42,9 @@ export default class MAudioBody extends React.Component {
}
_getContentUrl() {
if (this.props.forExport) return this.props.mxEvent.getContent().url;
const media = mediaFromContent(this.props.mxEvent.getContent());
const content = this.props.mxEvent.getContent();
if (this.props.forExport) return content.file?.url || content.url;
const media = mediaFromContent(content);
if (media.isEncrypted) {
return this.state.decryptedUrl;
} else {

View File

@ -186,8 +186,9 @@ export default class MFileBody extends React.Component {
}
if (this.props.forExport) {
const content = this.props.mxEvent.getContent();
return <span className="mx_MFileBody">
<a href={this.props.mxEvent.getContent().url}>
<a href={content.file?.url || content.url}>
{ placeholder }
</a>
</span>;

View File

@ -172,8 +172,9 @@ export default class MImageBody extends React.Component {
}
_getContentUrl() {
if (this.props.forExport) return this.props.mxEvent.getContent().url;
const media = mediaFromContent(this.props.mxEvent.getContent());
const content = this.props.mxEvent.getContent();
if (this.props.forExport) return content.url || content.file.url;
const media = mediaFromContent(content);
if (media.isEncrypted) {
return this.state.decryptedUrl;
} else {

View File

@ -78,8 +78,9 @@ export default class MVideoBody extends React.PureComponent<IProps, IState> {
}
private getContentUrl(): string|null {
if (this.props.forExport) return this.props.mxEvent.getContent().url;
const media = mediaFromContent(this.props.mxEvent.getContent());
const content = this.props.mxEvent.getContent();
if (this.props.forExport) return content.file?.url || content.url;
const media = mediaFromContent(content);
if (media.isEncrypted) {
return this.state.decryptedUrl;
} else {

View File

@ -264,7 +264,8 @@ export default class HTMLExporter extends Exporter {
</div>
let eventTileMarkup = renderToStaticMarkup(eventTile);
if (filePath) {
eventTileMarkup = eventTileMarkup.split(mxEv.getContent().url).join(filePath);
const mxc = mxEv.getContent().url || mxEv.getContent().file?.url;
eventTileMarkup = eventTileMarkup.split(mxc).join(filePath);
}
if (hasAvatar) {
eventTileMarkup = eventTileMarkup.replace(
@ -305,7 +306,7 @@ export default class HTMLExporter extends Exporter {
}
this.addFile(filePath, blob);
} catch (e) {
console.log("Error while fetching file");
console.log("Error while fetching file" + e);
eventTile = await this.getEventTile(
this.createModifiedEvent(_t("Error fetching file"), mxEv),
joined,