Include a file-safe room name and ISO date in chat exports (#9440)
* conversation export named after room * sanitization added for exported file name * sanitization added for exported file name * sanitization added for exported file name * sanitization added for exported file name=>lint error fixed * sanitization added for exported file name=>lint error fixed * sanitization added for exported file name=>redundancy removed * sanitization added for exported file name=>redundancy removed * reverted to previous commit * sanitization added for exported file name=>redundancy removed * exported chat date iso formatted * conversation export named after room * conversation export named after room Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> * code refacto filename date format * Add docs to fn * Bring in a util library for sanitizing * Extract file naming function and make consistent for all 3 types Also use the library we dragged in * Write tests & associated fixes * Apply linters locally * Include new date util in index Co-authored-by: Sinharitik589 <sinharitik18112835@gmail.com> Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> Co-authored-by: yaya-usman <yayaazeez222@gmail.com> Co-authored-by: Sinharitik589 <67551927+Sinharitik589@users.noreply.github.com>
This commit is contained in:
parent
ca8b1b04ef
commit
10a429c68d
16 changed files with 233 additions and 90 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright 2021 The Matrix.org Foundation C.I.C.
|
||||
Copyright 2021 - 2022 The Matrix.org Foundation C.I.C.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
@ -20,7 +20,6 @@ import { logger } from "matrix-js-sdk/src/logger";
|
|||
import React from "react";
|
||||
|
||||
import Exporter from "./Exporter";
|
||||
import { formatFullDateNoDay } from "../../DateUtils";
|
||||
import { _t } from "../../languageHandler";
|
||||
import { ExportType, IExportOptions } from "./exportUtils";
|
||||
import { textForEvent } from "../../TextForEvent";
|
||||
|
@ -43,6 +42,10 @@ export default class PlainTextExporter extends Exporter {
|
|||
: _t("Media omitted - file size limit exceeded");
|
||||
}
|
||||
|
||||
public get destinationFileName(): string {
|
||||
return this.makeFileNameNoExtension() + ".txt";
|
||||
}
|
||||
|
||||
public textForReplyEvent = (content: IContent) => {
|
||||
const REPLY_REGEX = /> <(.*?)>(.*?)\n\n(.*)/s;
|
||||
const REPLY_SOURCE_MAX_LENGTH = 32;
|
||||
|
@ -137,7 +140,7 @@ export default class PlainTextExporter extends Exporter {
|
|||
this.addFile("export.txt", new Blob([text]));
|
||||
await this.downloadZIP();
|
||||
} else {
|
||||
const fileName = `matrix-export-${formatFullDateNoDay(new Date())}.txt`;
|
||||
const fileName = this.destinationFileName;
|
||||
this.downloadPlainText(fileName, text);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue