mirror of
https://github.com/vector-im/element-web.git
synced 2024-11-18 14:44:58 +08:00
Handle encrypted stickers and store stickers in a separate folder
This commit is contained in:
parent
c63c59b408
commit
692e499cf2
@ -137,7 +137,6 @@ export function wantsDateSeparator(prevEventDate: Date, nextEventDate: Date): bo
|
|||||||
return prevEventDate.getDay() !== nextEventDate.getDay();
|
return prevEventDate.getDay() !== nextEventDate.getDay();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export function formatFullDateNoDay(date: Date) {
|
export function formatFullDateNoDay(date: Date) {
|
||||||
return (
|
return (
|
||||||
date.getFullYear() +
|
date.getFullYear() +
|
||||||
|
@ -176,7 +176,9 @@ export default class MFileBody extends React.Component {
|
|||||||
placeholder = (
|
placeholder = (
|
||||||
<div className="mx_MFileBody_info">
|
<div className="mx_MFileBody_info">
|
||||||
<span className="mx_MFileBody_info_icon" >
|
<span className="mx_MFileBody_info_icon" >
|
||||||
{this.props.isExporting ? <img class="mx_export_attach_icon" src="icons/attach.svg" /> : null}
|
{this.props.isExporting ?
|
||||||
|
<img className="mx_export_attach_icon" src="icons/attach.svg" />
|
||||||
|
: null}
|
||||||
</span>
|
</span>
|
||||||
<span className="mx_MFileBody_info_filename">{this.presentableTextForFile(content, false)}</span>
|
<span className="mx_MFileBody_info_filename">{this.presentableTextForFile(content, false)}</span>
|
||||||
</div>
|
</div>
|
||||||
|
@ -156,7 +156,9 @@ export default class HTMLExporter extends Exporter {
|
|||||||
try {
|
try {
|
||||||
const isEncrypted = event.isEncrypted();
|
const isEncrypted = event.isEncrypted();
|
||||||
const content = event.getContent();
|
const content = event.getContent();
|
||||||
if (isEncrypted && !content.hasOwnProperty("org.matrix.msc1767.file")) {
|
const shouldDecrypt = isEncrypted && !content.hasOwnProperty("org.matrix.msc1767.file")
|
||||||
|
&& event.getType() !== "m.sticker";
|
||||||
|
if (shouldDecrypt) {
|
||||||
blob = await decryptFile(content.file);
|
blob = await decryptFile(content.file);
|
||||||
} else {
|
} else {
|
||||||
const media = mediaFromContent(event.getContent());
|
const media = mediaFromContent(event.getContent());
|
||||||
@ -185,7 +187,7 @@ export default class HTMLExporter extends Exporter {
|
|||||||
if (lastDot === -1) return [file, ""];
|
if (lastDot === -1) return [file, ""];
|
||||||
const fileName = file.slice(0, lastDot);
|
const fileName = file.slice(0, lastDot);
|
||||||
const ext = file.slice(lastDot + 1);
|
const ext = file.slice(lastDot + 1);
|
||||||
return [fileName, ext];
|
return [fileName, '.' + ext];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected getFilePath(event: MatrixEvent) {
|
protected getFilePath(event: MatrixEvent) {
|
||||||
@ -202,12 +204,11 @@ export default class HTMLExporter extends Exporter {
|
|||||||
fileDirectory = "audio";
|
fileDirectory = "audio";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fileDirectory = "files";
|
fileDirectory = event.getType() === "m.sticker" ? "stickers" : "files";
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
const fileDate = formatFullDateNoDay(new Date(event.getTs()));
|
const fileDate = formatFullDateNoDay(new Date(event.getTs()));
|
||||||
const [fileName, fileExt] = this.splitFileName(event.getContent().body);
|
const [fileName, fileExt] = this.splitFileName(event.getContent().body);
|
||||||
const filePath = fileDirectory + "/" + fileName + '-' + fileDate + '.' + fileExt;
|
const filePath = fileDirectory + "/" + fileName + '-' + fileDate + fileExt;
|
||||||
return filePath;
|
return filePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user