From 55c48a5bd48c21bc8ca9f26b2e8497a343227842 Mon Sep 17 00:00:00 2001 From: Sinharitik589 Date: Sat, 5 Mar 2022 02:10:10 +0530 Subject: [PATCH 01/20] conversation export named after room --- src/utils/exportUtils/Exporter.ts | 2 +- src/utils/exportUtils/JSONExport.ts | 2 +- src/utils/exportUtils/PlainTextExport.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/utils/exportUtils/Exporter.ts b/src/utils/exportUtils/Exporter.ts index 7b4a7bf342f..cbcf8d197a4 100644 --- a/src/utils/exportUtils/Exporter.ts +++ b/src/utils/exportUtils/Exporter.ts @@ -77,7 +77,7 @@ export default abstract class Exporter { protected async downloadZIP(): Promise { const brand = SdkConfig.get().brand; - const filenameWithoutExt = `${brand} - Chat Export - ${formatFullDateNoDay(new Date())}`; + const filenameWithoutExt = `${brand} - ${this.room.name} - Chat Export - ${formatFullDateNoDay(new Date())}`; const filename = `${filenameWithoutExt}.zip`; const { default: JSZip } = await import('jszip'); diff --git a/src/utils/exportUtils/JSONExport.ts b/src/utils/exportUtils/JSONExport.ts index 27fdb5a8478..61da728091c 100644 --- a/src/utils/exportUtils/JSONExport.ts +++ b/src/utils/exportUtils/JSONExport.ts @@ -108,7 +108,7 @@ export default class JSONExporter extends Exporter { this.addFile("export.json", new Blob([text])); await this.downloadZIP(); } else { - const fileName = `matrix-export-${formatFullDateNoDay(new Date())}.json`; + const fileName = `matrix-${this.room.name}-export-${formatFullDateNoDay(new Date())}.json`; this.downloadPlainText(fileName, text); } diff --git a/src/utils/exportUtils/PlainTextExport.ts b/src/utils/exportUtils/PlainTextExport.ts index edabb80fe02..aa7a65f2c83 100644 --- a/src/utils/exportUtils/PlainTextExport.ts +++ b/src/utils/exportUtils/PlainTextExport.ts @@ -136,7 +136,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 = `matrix-${this.room.name}-export-${formatFullDateNoDay(new Date())}.txt`; this.downloadPlainText(fileName, text); } From 04d7e625db1986f9c8d472291bba627b5833080e Mon Sep 17 00:00:00 2001 From: Sinharitik589 Date: Wed, 9 Mar 2022 01:46:06 +0530 Subject: [PATCH 02/20] sanitization added for exported file name --- src/utils/exportUtils/Exporter.ts | 8 +++++++- src/utils/exportUtils/JSONExport.ts | 8 +++++++- src/utils/exportUtils/PlainTextExport.ts | 9 ++++++++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/utils/exportUtils/Exporter.ts b/src/utils/exportUtils/Exporter.ts index cbcf8d197a4..44f21f2af41 100644 --- a/src/utils/exportUtils/Exporter.ts +++ b/src/utils/exportUtils/Exporter.ts @@ -75,9 +75,15 @@ export default abstract class Exporter { this.files.push(file); } + public santizeFileName(filename:string): string { + filename = filename.replace(/[^a-z0-9áéíóúñü \.,_-]/gim,""); + filename = filename.replace(/[ ]/gim,"-"); + return filename.trim(); + } + protected async downloadZIP(): Promise { const brand = SdkConfig.get().brand; - const filenameWithoutExt = `${brand} - ${this.room.name} - Chat Export - ${formatFullDateNoDay(new Date())}`; + const filenameWithoutExt = this.santizeFileName(`${brand} - ${this.room.name} - Chat Export - ${formatFullDateNoDay(new Date())}`); const filename = `${filenameWithoutExt}.zip`; const { default: JSZip } = await import('jszip'); diff --git a/src/utils/exportUtils/JSONExport.ts b/src/utils/exportUtils/JSONExport.ts index 61da728091c..22e13a3fa9a 100644 --- a/src/utils/exportUtils/JSONExport.ts +++ b/src/utils/exportUtils/JSONExport.ts @@ -91,6 +91,12 @@ export default class JSONExporter extends Exporter { return this.createJSONString(); } + public santizeFileName(filename:string): string { + filename = filename.replace(/[^a-z0-9áéíóúñü \.,_-]/gim,""); + filename = filename.replace(/[ ]/gim,"-"); + return filename.trim(); + } + public async export() { logger.info("Starting export process..."); logger.info("Fetching events..."); @@ -108,7 +114,7 @@ export default class JSONExporter extends Exporter { this.addFile("export.json", new Blob([text])); await this.downloadZIP(); } else { - const fileName = `matrix-${this.room.name}-export-${formatFullDateNoDay(new Date())}.json`; + const fileName = this.santizeFileName(`matrix-${this.room.name}-export-${formatFullDateNoDay(new Date())}.json`); this.downloadPlainText(fileName, text); } diff --git a/src/utils/exportUtils/PlainTextExport.ts b/src/utils/exportUtils/PlainTextExport.ts index aa7a65f2c83..f3382eb0133 100644 --- a/src/utils/exportUtils/PlainTextExport.ts +++ b/src/utils/exportUtils/PlainTextExport.ts @@ -24,6 +24,7 @@ import { _t } from "../../languageHandler"; import { haveTileForEvent } from "../../components/views/rooms/EventTile"; import { ExportType, IExportOptions } from "./exportUtils"; import { textForEvent } from "../../TextForEvent"; +import { string } from "prop-types"; export default class PlainTextExporter extends Exporter { protected totalSize: number; @@ -119,6 +120,12 @@ export default class PlainTextExporter extends Exporter { return content; } + public santizeFileName(filename:string): string { + filename = filename.replace(/[^a-z0-9áéíóúñü \.,_-]/gim,""); + filename = filename.replace(/[ ]/gim,"-"); + return filename.trim(); + } + public async export() { this.updateProgress(_t("Starting export process...")); this.updateProgress(_t("Fetching events...")); @@ -136,7 +143,7 @@ export default class PlainTextExporter extends Exporter { this.addFile("export.txt", new Blob([text])); await this.downloadZIP(); } else { - const fileName = `matrix-${this.room.name}-export-${formatFullDateNoDay(new Date())}.txt`; + const fileName = this.santizeFileName(`matrix-${this.room.name}-export-${formatFullDateNoDay(new Date())}.txt`); this.downloadPlainText(fileName, text); } From 65bdb674439c4f9e2b487d5c1bc0613238d9bdc3 Mon Sep 17 00:00:00 2001 From: Sinharitik589 Date: Wed, 9 Mar 2022 02:07:53 +0530 Subject: [PATCH 03/20] sanitization added for exported file name --- src/utils/exportUtils/Exporter.ts | 6 +++--- src/utils/exportUtils/JSONExport.ts | 6 +++--- src/utils/exportUtils/PlainTextExport.ts | 7 +++---- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/utils/exportUtils/Exporter.ts b/src/utils/exportUtils/Exporter.ts index 44f21f2af41..d00aa7bf737 100644 --- a/src/utils/exportUtils/Exporter.ts +++ b/src/utils/exportUtils/Exporter.ts @@ -75,9 +75,9 @@ export default abstract class Exporter { this.files.push(file); } - public santizeFileName(filename:string): string { - filename = filename.replace(/[^a-z0-9áéíóúñü \.,_-]/gim,""); - filename = filename.replace(/[ ]/gim,"-"); + public santizeFileName(filename: string): string { + filename = filename.replace(/[^a-z0-9áéíóúñü \.,_-]/gim, ""); + filename = filename.replace(/[ ]/gim, "-"); return filename.trim(); } diff --git a/src/utils/exportUtils/JSONExport.ts b/src/utils/exportUtils/JSONExport.ts index 22e13a3fa9a..6adcda4b760 100644 --- a/src/utils/exportUtils/JSONExport.ts +++ b/src/utils/exportUtils/JSONExport.ts @@ -91,9 +91,9 @@ export default class JSONExporter extends Exporter { return this.createJSONString(); } - public santizeFileName(filename:string): string { - filename = filename.replace(/[^a-z0-9áéíóúñü \.,_-]/gim,""); - filename = filename.replace(/[ ]/gim,"-"); + public santizeFileName(filename: string): string { + filename = filename.replace(/[^a-z0-9áéíóúñü \.,_-]/gim, ""); + filename = filename.replace(/[ ]/gim, "-"); return filename.trim(); } diff --git a/src/utils/exportUtils/PlainTextExport.ts b/src/utils/exportUtils/PlainTextExport.ts index f3382eb0133..1f85124fc95 100644 --- a/src/utils/exportUtils/PlainTextExport.ts +++ b/src/utils/exportUtils/PlainTextExport.ts @@ -24,7 +24,6 @@ import { _t } from "../../languageHandler"; import { haveTileForEvent } from "../../components/views/rooms/EventTile"; import { ExportType, IExportOptions } from "./exportUtils"; import { textForEvent } from "../../TextForEvent"; -import { string } from "prop-types"; export default class PlainTextExporter extends Exporter { protected totalSize: number; @@ -120,9 +119,9 @@ export default class PlainTextExporter extends Exporter { return content; } - public santizeFileName(filename:string): string { - filename = filename.replace(/[^a-z0-9áéíóúñü \.,_-]/gim,""); - filename = filename.replace(/[ ]/gim,"-"); + public santizeFileName(filename: string): string { + filename = filename.replace(/[^a-z0-9áéíóúñü \.,_-]/gim, ""); + filename = filename.replace(/[ ]/gim, "-"); return filename.trim(); } From cb4a957379895c6a05f32b97e4cabe9062be85fe Mon Sep 17 00:00:00 2001 From: Sinharitik589 Date: Wed, 9 Mar 2022 02:15:14 +0530 Subject: [PATCH 04/20] sanitization added for exported file name --- src/utils/exportUtils/Exporter.ts | 2 +- src/utils/exportUtils/JSONExport.ts | 2 +- src/utils/exportUtils/PlainTextExport.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/utils/exportUtils/Exporter.ts b/src/utils/exportUtils/Exporter.ts index d00aa7bf737..a00adec7beb 100644 --- a/src/utils/exportUtils/Exporter.ts +++ b/src/utils/exportUtils/Exporter.ts @@ -76,7 +76,7 @@ export default abstract class Exporter { } public santizeFileName(filename: string): string { - filename = filename.replace(/[^a-z0-9áéíóúñü \.,_-]/gim, ""); + filename = filename.replace(/[^a-z0-9áéíóúñü.,_-]/gim, ""); filename = filename.replace(/[ ]/gim, "-"); return filename.trim(); } diff --git a/src/utils/exportUtils/JSONExport.ts b/src/utils/exportUtils/JSONExport.ts index 6adcda4b760..b2da67a546b 100644 --- a/src/utils/exportUtils/JSONExport.ts +++ b/src/utils/exportUtils/JSONExport.ts @@ -92,7 +92,7 @@ export default class JSONExporter extends Exporter { } public santizeFileName(filename: string): string { - filename = filename.replace(/[^a-z0-9áéíóúñü \.,_-]/gim, ""); + filename = filename.replace(/[^a-z0-9áéíóúñü.,_-]/gim,""); filename = filename.replace(/[ ]/gim, "-"); return filename.trim(); } diff --git a/src/utils/exportUtils/PlainTextExport.ts b/src/utils/exportUtils/PlainTextExport.ts index 1f85124fc95..a82330b1817 100644 --- a/src/utils/exportUtils/PlainTextExport.ts +++ b/src/utils/exportUtils/PlainTextExport.ts @@ -120,7 +120,7 @@ export default class PlainTextExporter extends Exporter { } public santizeFileName(filename: string): string { - filename = filename.replace(/[^a-z0-9áéíóúñü \.,_-]/gim, ""); + filename = filename.replace(/[^a-z0-9áéíóúñü.,_-]/gim, ""); filename = filename.replace(/[ ]/gim, "-"); return filename.trim(); } From 439c4cac364c4c6fe2b660dacb55afaaed97971d Mon Sep 17 00:00:00 2001 From: Sinharitik589 Date: Wed, 9 Mar 2022 02:20:31 +0530 Subject: [PATCH 05/20] sanitization added for exported file name=>lint error fixed --- src/utils/exportUtils/JSONExport.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/exportUtils/JSONExport.ts b/src/utils/exportUtils/JSONExport.ts index b2da67a546b..01df4fe5b9c 100644 --- a/src/utils/exportUtils/JSONExport.ts +++ b/src/utils/exportUtils/JSONExport.ts @@ -92,7 +92,7 @@ export default class JSONExporter extends Exporter { } public santizeFileName(filename: string): string { - filename = filename.replace(/[^a-z0-9áéíóúñü.,_-]/gim,""); + filename = filename.replace(/[^a-z0-9áéíóúñü.,_-]/gim, ""); filename = filename.replace(/[ ]/gim, "-"); return filename.trim(); } From 9958015f82291b80cd6a15118df37310c81cc554 Mon Sep 17 00:00:00 2001 From: Sinharitik589 Date: Wed, 9 Mar 2022 18:29:01 +0530 Subject: [PATCH 06/20] sanitization added for exported file name=>lint error fixed --- src/utils/exportUtils/Exporter.ts | 4 +++- src/utils/exportUtils/JSONExport.ts | 4 +++- src/utils/exportUtils/PlainTextExport.ts | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/utils/exportUtils/Exporter.ts b/src/utils/exportUtils/Exporter.ts index a00adec7beb..d8439f37641 100644 --- a/src/utils/exportUtils/Exporter.ts +++ b/src/utils/exportUtils/Exporter.ts @@ -83,7 +83,9 @@ export default abstract class Exporter { protected async downloadZIP(): Promise { const brand = SdkConfig.get().brand; - const filenameWithoutExt = this.santizeFileName(`${brand} - ${this.room.name} - Chat Export - ${formatFullDateNoDay(new Date())}`); + const filenameWithoutExt = this.santizeFileName( + `${brand} - ${this.room.name} - Chat Export - ${formatFullDateNoDay(new Date())}`, + ); const filename = `${filenameWithoutExt}.zip`; const { default: JSZip } = await import('jszip'); diff --git a/src/utils/exportUtils/JSONExport.ts b/src/utils/exportUtils/JSONExport.ts index 01df4fe5b9c..c7e82655408 100644 --- a/src/utils/exportUtils/JSONExport.ts +++ b/src/utils/exportUtils/JSONExport.ts @@ -114,7 +114,9 @@ export default class JSONExporter extends Exporter { this.addFile("export.json", new Blob([text])); await this.downloadZIP(); } else { - const fileName = this.santizeFileName(`matrix-${this.room.name}-export-${formatFullDateNoDay(new Date())}.json`); + const fileName = this.santizeFileName( + `matrix-${this.room.name}-export-${formatFullDateNoDay(new Date())}.json`, + ); this.downloadPlainText(fileName, text); } diff --git a/src/utils/exportUtils/PlainTextExport.ts b/src/utils/exportUtils/PlainTextExport.ts index a82330b1817..9c7b1145bac 100644 --- a/src/utils/exportUtils/PlainTextExport.ts +++ b/src/utils/exportUtils/PlainTextExport.ts @@ -142,7 +142,9 @@ export default class PlainTextExporter extends Exporter { this.addFile("export.txt", new Blob([text])); await this.downloadZIP(); } else { - const fileName = this.santizeFileName(`matrix-${this.room.name}-export-${formatFullDateNoDay(new Date())}.txt`); + const fileName = this.santizeFileName( + `matrix-${this.room.name}-export-${formatFullDateNoDay(new Date())}.txt`, + ); this.downloadPlainText(fileName, text); } From f2ceb5d827f04221253e75c72d40a4f9b4749479 Mon Sep 17 00:00:00 2001 From: Sinharitik589 Date: Wed, 9 Mar 2022 19:22:53 +0530 Subject: [PATCH 07/20] sanitization added for exported file name=>redundancy removed --- src/utils/exportUtils/Exporter.ts | 2 +- src/utils/exportUtils/JSONExport.ts | 6 ------ src/utils/exportUtils/PlainTextExport.ts | 6 ------ 3 files changed, 1 insertion(+), 13 deletions(-) diff --git a/src/utils/exportUtils/Exporter.ts b/src/utils/exportUtils/Exporter.ts index d8439f37641..0ee59480dfb 100644 --- a/src/utils/exportUtils/Exporter.ts +++ b/src/utils/exportUtils/Exporter.ts @@ -75,7 +75,7 @@ export default abstract class Exporter { this.files.push(file); } - public santizeFileName(filename: string): string { + protected santizeFileName(filename: string): string { filename = filename.replace(/[^a-z0-9áéíóúñü.,_-]/gim, ""); filename = filename.replace(/[ ]/gim, "-"); return filename.trim(); diff --git a/src/utils/exportUtils/JSONExport.ts b/src/utils/exportUtils/JSONExport.ts index c7e82655408..7ba72f26e2a 100644 --- a/src/utils/exportUtils/JSONExport.ts +++ b/src/utils/exportUtils/JSONExport.ts @@ -91,12 +91,6 @@ export default class JSONExporter extends Exporter { return this.createJSONString(); } - public santizeFileName(filename: string): string { - filename = filename.replace(/[^a-z0-9áéíóúñü.,_-]/gim, ""); - filename = filename.replace(/[ ]/gim, "-"); - return filename.trim(); - } - public async export() { logger.info("Starting export process..."); logger.info("Fetching events..."); diff --git a/src/utils/exportUtils/PlainTextExport.ts b/src/utils/exportUtils/PlainTextExport.ts index 9c7b1145bac..4c841d9f8fc 100644 --- a/src/utils/exportUtils/PlainTextExport.ts +++ b/src/utils/exportUtils/PlainTextExport.ts @@ -119,12 +119,6 @@ export default class PlainTextExporter extends Exporter { return content; } - public santizeFileName(filename: string): string { - filename = filename.replace(/[^a-z0-9áéíóúñü.,_-]/gim, ""); - filename = filename.replace(/[ ]/gim, "-"); - return filename.trim(); - } - public async export() { this.updateProgress(_t("Starting export process...")); this.updateProgress(_t("Fetching events...")); From e75b3065c3434ae8b7170dc976f518aee1292932 Mon Sep 17 00:00:00 2001 From: Sinharitik589 Date: Sat, 12 Mar 2022 15:06:29 +0530 Subject: [PATCH 08/20] sanitization added for exported file name=>redundancy removed --- src/utils/exportUtils/Exporter.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/utils/exportUtils/Exporter.ts b/src/utils/exportUtils/Exporter.ts index 0ee59480dfb..ff03e2addd2 100644 --- a/src/utils/exportUtils/Exporter.ts +++ b/src/utils/exportUtils/Exporter.ts @@ -76,6 +76,7 @@ export default abstract class Exporter { } protected santizeFileName(filename: string): string { + filename = filename.normalize('NFD').replace(/[\u0300-\u036f]/g, ""); filename = filename.replace(/[^a-z0-9áéíóúñü.,_-]/gim, ""); filename = filename.replace(/[ ]/gim, "-"); return filename.trim(); From 572cf47b898ca88cbbfe6ec6ca26cda0ae4d233f Mon Sep 17 00:00:00 2001 From: Sinharitik589 Date: Sat, 12 Mar 2022 15:21:56 +0530 Subject: [PATCH 09/20] reverted to previous commit --- src/utils/exportUtils/Exporter.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/utils/exportUtils/Exporter.ts b/src/utils/exportUtils/Exporter.ts index ff03e2addd2..0ee59480dfb 100644 --- a/src/utils/exportUtils/Exporter.ts +++ b/src/utils/exportUtils/Exporter.ts @@ -76,7 +76,6 @@ export default abstract class Exporter { } protected santizeFileName(filename: string): string { - filename = filename.normalize('NFD').replace(/[\u0300-\u036f]/g, ""); filename = filename.replace(/[^a-z0-9áéíóúñü.,_-]/gim, ""); filename = filename.replace(/[ ]/gim, "-"); return filename.trim(); From b0dac2f18a5c150ec358a610cbcb053b3daa9476 Mon Sep 17 00:00:00 2001 From: Sinharitik589 Date: Tue, 15 Mar 2022 09:58:51 +0530 Subject: [PATCH 10/20] sanitization added for exported file name=>redundancy removed --- src/utils/exportUtils/Exporter.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/utils/exportUtils/Exporter.ts b/src/utils/exportUtils/Exporter.ts index 0ee59480dfb..ff03e2addd2 100644 --- a/src/utils/exportUtils/Exporter.ts +++ b/src/utils/exportUtils/Exporter.ts @@ -76,6 +76,7 @@ export default abstract class Exporter { } protected santizeFileName(filename: string): string { + filename = filename.normalize('NFD').replace(/[\u0300-\u036f]/g, ""); filename = filename.replace(/[^a-z0-9áéíóúñü.,_-]/gim, ""); filename = filename.replace(/[ ]/gim, "-"); return filename.trim(); From 245c3bdfab97d7b7103354f4ef824dacf19c8bf3 Mon Sep 17 00:00:00 2001 From: yaya-usman Date: Tue, 10 May 2022 23:03:42 +0300 Subject: [PATCH 11/20] exported chat date iso formatted --- src/DateUtils.ts | 4 ++++ src/utils/exportUtils/Exporter.ts | 6 ++---- src/utils/exportUtils/JSONExport.ts | 4 ++-- src/utils/exportUtils/PlainTextExport.ts | 4 ++-- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/DateUtils.ts b/src/DateUtils.ts index 20227354f02..bac7481a4f2 100644 --- a/src/DateUtils.ts +++ b/src/DateUtils.ts @@ -177,6 +177,10 @@ export function formatFullDateNoDay(date: Date) { }); } +export function formatFullDateNoDayISO(date: Date) { + return date.toISOString(); +} + export function formatFullDateNoDayNoTime(date: Date) { return ( date.getFullYear() + diff --git a/src/utils/exportUtils/Exporter.ts b/src/utils/exportUtils/Exporter.ts index 7b4a7bf342f..ea88125e7e5 100644 --- a/src/utils/exportUtils/Exporter.ts +++ b/src/utils/exportUtils/Exporter.ts @@ -25,11 +25,10 @@ import { MatrixClientPeg } from "../../MatrixClientPeg"; import { ExportType, IExportOptions } from "./exportUtils"; import { decryptFile } from "../DecryptFile"; import { mediaFromContent } from "../../customisations/Media"; -import { formatFullDateNoDay } from "../../DateUtils"; +import { formatFullDateNoDay, formatFullDateNoDayISO } from "../../DateUtils"; import { isVoiceMessage } from "../EventUtils"; import { IMediaEventContent } from "../../customisations/models/IMediaEventContent"; import { _t } from "../../languageHandler"; -import SdkConfig from "../../SdkConfig"; type BlobFile = { name: string; @@ -76,8 +75,7 @@ export default abstract class Exporter { } protected async downloadZIP(): Promise { - const brand = SdkConfig.get().brand; - const filenameWithoutExt = `${brand} - Chat Export - ${formatFullDateNoDay(new Date())}`; + const filenameWithoutExt = `${this.room.name}-${formatFullDateNoDayISO(new Date())}`; const filename = `${filenameWithoutExt}.zip`; const { default: JSZip } = await import('jszip'); diff --git a/src/utils/exportUtils/JSONExport.ts b/src/utils/exportUtils/JSONExport.ts index b0b4b330b06..57ee1ea447e 100644 --- a/src/utils/exportUtils/JSONExport.ts +++ b/src/utils/exportUtils/JSONExport.ts @@ -20,7 +20,7 @@ import { EventType } from "matrix-js-sdk/src/@types/event"; import { logger } from "matrix-js-sdk/src/logger"; import Exporter from "./Exporter"; -import { formatFullDateNoDay, formatFullDateNoDayNoTime } from "../../DateUtils"; +import { formatFullDateNoDayISO, formatFullDateNoDayNoTime } from "../../DateUtils"; import { ExportType, IExportOptions } from "./exportUtils"; import { _t } from "../../languageHandler"; import { haveRendererForEvent } from "../../events/EventTileFactory"; @@ -108,7 +108,7 @@ export default class JSONExporter extends Exporter { this.addFile("export.json", new Blob([text])); await this.downloadZIP(); } else { - const fileName = `matrix-export-${formatFullDateNoDay(new Date())}.json`; + const fileName = `${this.room.name}-${formatFullDateNoDayISO(new Date())}.json`; this.downloadPlainText(fileName, text); } diff --git a/src/utils/exportUtils/PlainTextExport.ts b/src/utils/exportUtils/PlainTextExport.ts index e86c56e9f4c..da5dbcaf007 100644 --- a/src/utils/exportUtils/PlainTextExport.ts +++ b/src/utils/exportUtils/PlainTextExport.ts @@ -19,7 +19,7 @@ import { IContent, MatrixEvent } from "matrix-js-sdk/src/models/event"; import { logger } from "matrix-js-sdk/src/logger"; import Exporter from "./Exporter"; -import { formatFullDateNoDay } from "../../DateUtils"; +import { formatFullDateNoDayISO } from "../../DateUtils"; import { _t } from "../../languageHandler"; import { ExportType, IExportOptions } from "./exportUtils"; import { textForEvent } from "../../TextForEvent"; @@ -136,7 +136,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.room.name}-${formatFullDateNoDayISO(new Date())}.txt`; this.downloadPlainText(fileName, text); } From f086670d9d415104ca2c1051a30d9aec65a53789 Mon Sep 17 00:00:00 2001 From: Sinharitik589 Date: Mon, 16 May 2022 13:35:58 +0530 Subject: [PATCH 12/20] conversation export named after room --- src/utils/exportUtils/Exporter.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/exportUtils/Exporter.ts b/src/utils/exportUtils/Exporter.ts index ff03e2addd2..fd98940238e 100644 --- a/src/utils/exportUtils/Exporter.ts +++ b/src/utils/exportUtils/Exporter.ts @@ -77,8 +77,8 @@ export default abstract class Exporter { protected santizeFileName(filename: string): string { filename = filename.normalize('NFD').replace(/[\u0300-\u036f]/g, ""); - filename = filename.replace(/[^a-z0-9áéíóúñü.,_-]/gim, ""); filename = filename.replace(/[ ]/gim, "-"); + filename = filename.replace(/[^a-z0-9.,_-]/gim, ""); return filename.trim(); } From 677e9e7132540d7a571439f7264c08c5dc435c47 Mon Sep 17 00:00:00 2001 From: Sinharitik589 <67551927+Sinharitik589@users.noreply.github.com> Date: Wed, 18 May 2022 23:22:59 +0530 Subject: [PATCH 13/20] conversation export named after room Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> --- src/utils/exportUtils/Exporter.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/exportUtils/Exporter.ts b/src/utils/exportUtils/Exporter.ts index fd98940238e..25d685f9101 100644 --- a/src/utils/exportUtils/Exporter.ts +++ b/src/utils/exportUtils/Exporter.ts @@ -77,7 +77,7 @@ export default abstract class Exporter { protected santizeFileName(filename: string): string { filename = filename.normalize('NFD').replace(/[\u0300-\u036f]/g, ""); - filename = filename.replace(/[ ]/gim, "-"); + filename = filename.replace(/\s+/gim, "-"); filename = filename.replace(/[^a-z0-9.,_-]/gim, ""); return filename.trim(); } From eb9f262567558905c5af7a226e448f14c1a03f24 Mon Sep 17 00:00:00 2001 From: yaya-usman Date: Tue, 10 May 2022 23:03:42 +0300 Subject: [PATCH 14/20] code refacto filename date format --- src/utils/exportUtils/Exporter.ts | 4 +++- src/utils/exportUtils/JSONExport.ts | 2 +- src/utils/exportUtils/PlainTextExport.ts | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/utils/exportUtils/Exporter.ts b/src/utils/exportUtils/Exporter.ts index ea88125e7e5..74eeed1b8ea 100644 --- a/src/utils/exportUtils/Exporter.ts +++ b/src/utils/exportUtils/Exporter.ts @@ -29,6 +29,7 @@ import { formatFullDateNoDay, formatFullDateNoDayISO } from "../../DateUtils"; import { isVoiceMessage } from "../EventUtils"; import { IMediaEventContent } from "../../customisations/models/IMediaEventContent"; import { _t } from "../../languageHandler"; +import SdkConfig from "../../SdkConfig"; type BlobFile = { name: string; @@ -75,7 +76,8 @@ export default abstract class Exporter { } protected async downloadZIP(): Promise { - const filenameWithoutExt = `${this.room.name}-${formatFullDateNoDayISO(new Date())}`; + const brand = SdkConfig.get().brand; + const filenameWithoutExt = `${brand} - ${this.room.name} - Chat Export -${formatFullDateNoDayISO(new Date())}`; const filename = `${filenameWithoutExt}.zip`; const { default: JSZip } = await import('jszip'); diff --git a/src/utils/exportUtils/JSONExport.ts b/src/utils/exportUtils/JSONExport.ts index 57ee1ea447e..9e5987e4e4f 100644 --- a/src/utils/exportUtils/JSONExport.ts +++ b/src/utils/exportUtils/JSONExport.ts @@ -108,7 +108,7 @@ export default class JSONExporter extends Exporter { this.addFile("export.json", new Blob([text])); await this.downloadZIP(); } else { - const fileName = `${this.room.name}-${formatFullDateNoDayISO(new Date())}.json`; + const fileName = `matrix-${this.room.name}-export-${formatFullDateNoDayISO(new Date())}.json`; this.downloadPlainText(fileName, text); } diff --git a/src/utils/exportUtils/PlainTextExport.ts b/src/utils/exportUtils/PlainTextExport.ts index da5dbcaf007..ee1c3aeed48 100644 --- a/src/utils/exportUtils/PlainTextExport.ts +++ b/src/utils/exportUtils/PlainTextExport.ts @@ -136,7 +136,7 @@ export default class PlainTextExporter extends Exporter { this.addFile("export.txt", new Blob([text])); await this.downloadZIP(); } else { - const fileName = `${this.room.name}-${formatFullDateNoDayISO(new Date())}.txt`; + const fileName = `matrix-${this.room.name}-export-${formatFullDateNoDayISO(new Date())}.txt`; this.downloadPlainText(fileName, text); } From 278558f548894ac5ac6d659faa55be8b92327142 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Mon, 17 Oct 2022 16:40:33 -0600 Subject: [PATCH 15/20] Add docs to fn --- src/DateUtils.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/DateUtils.ts b/src/DateUtils.ts index bac7481a4f2..eafdf428e19 100644 --- a/src/DateUtils.ts +++ b/src/DateUtils.ts @@ -177,7 +177,13 @@ export function formatFullDateNoDay(date: Date) { }); } -export function formatFullDateNoDayISO(date: Date) { +/** + * Returns an ISO date string without textual description of the date (ie: no "Wednesday" or + * similar) + * @param date The date to format. + * @returns The date string in ISO format. + */ +export function formatFullDateNoDayISO(date: Date): string { return date.toISOString(); } From b1a6abee1b73b49f4779b2333002b5be47c1055d Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Mon, 17 Oct 2022 16:41:00 -0600 Subject: [PATCH 16/20] Bring in a util library for sanitizing --- package.json | 1 + yarn.lock | 98 +++++++++++----------------------------------------- 2 files changed, 22 insertions(+), 77 deletions(-) diff --git a/package.json b/package.json index 82ec05f81a5..b203cf51e91 100644 --- a/package.json +++ b/package.json @@ -111,6 +111,7 @@ "react-focus-lock": "^2.5.1", "react-transition-group": "^4.4.1", "rfc4648": "^1.4.0", + "sanitize-filename": "^1.6.3", "sanitize-html": "^2.3.2", "tar-js": "^0.3.0", "ua-parser-js": "^1.0.2", diff --git a/yarn.lock b/yarn.lock index ee6ceafdcf3..b54bc1ec815 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2674,7 +2674,7 @@ ajv-keywords@^3.5.2: resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-3.5.2.tgz#31f29da5ab6e00d1c2d329acf7b5929614d5014d" integrity sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ== -ajv@^6.10.0, ajv@^6.12.3, ajv@^6.12.4, ajv@^6.12.5: +ajv@^6.10.0, ajv@^6.12.4, ajv@^6.12.5: version "6.12.6" resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4" integrity sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g== @@ -3198,11 +3198,6 @@ browser-process-hrtime@^1.0.0: resolved "https://registry.yarnpkg.com/browser-process-hrtime/-/browser-process-hrtime-1.0.0.tgz#3c9b4b7d782c8121e56f10106d84c0d0ffc94626" integrity sha512-9o5UecI3GhkpM6DrXr69PblIuWxPKk9Y0jHBRhdocZ2y7YECBFCsHm79Pr3OyR2AvjhDkabFJaDJMYRazHgsow== -browser-request@^0.3.3: - version "0.3.3" - resolved "https://registry.yarnpkg.com/browser-request/-/browser-request-0.3.3.tgz#9ece5b5aca89a29932242e18bf933def9876cc17" - integrity sha512-YyNI4qJJ+piQG6MMEuo7J3Bzaqssufx04zpEKYfSrl/1Op59HWali9zMtBpXnkmqMcOuWJPZvudrm9wISmnCbg== - browserslist@^4.20.2, browserslist@^4.21.3: version "4.21.3" resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.21.3.tgz#5df277694eb3c48bc5c4b05af3e8b7e09c5a6d1a" @@ -5285,19 +5280,6 @@ grid-index@^1.1.0: resolved "https://registry.yarnpkg.com/grid-index/-/grid-index-1.1.0.tgz#97f8221edec1026c8377b86446a7c71e79522ea7" integrity sha512-HZRwumpOGUrHyxO5bqKZL0B0GlUpwtCAzZ42sgxUPniu33R1LSFH5yrIcBCHjkctCAh3mtWKcKd9J4vDDdeVHA== -har-schema@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/har-schema/-/har-schema-2.0.0.tgz#a94c2224ebcac04782a0d9035521f24735b7ec92" - integrity sha512-Oqluz6zhGX8cyRaTQlFMPw80bSJVG2x/cFb8ZPhUILGgHka9SsokCCOQgpveePerqidZOrT14ipqfJb7ILcW5Q== - -har-validator@~5.1.3: - version "5.1.5" - resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-5.1.5.tgz#1f0803b9f8cb20c0fa13822df1ecddb36bde1efd" - integrity sha512-nmT2T0lljbxdQZfspsno9hgrG3Uir6Ks5afism62poxqBM6sDnMEuPmzTq8XN0OEwqKLLdh1jQI3qyE66Nzb3w== - dependencies: - ajv "^6.12.3" - har-schema "^2.0.0" - hard-rejection@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/hard-rejection/-/hard-rejection-2.1.0.tgz#1c6eda5c1685c63942766d79bb40ae773cecd883" @@ -5458,15 +5440,6 @@ http-proxy-agent@^4.0.1: agent-base "6" debug "4" -http-signature@~1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-1.2.0.tgz#9aecd925114772f3d95b65a60abb8f7c18fbace1" - integrity sha512-CAbnr6Rz4CYQkLYUtSNXxQPUH2gK8f3iWexVlsnMeD+GjlsQ0Xsy1cOX+mN3dtxYomRy21CiOzU8Uhw6OwncEQ== - dependencies: - assert-plus "^1.0.0" - jsprim "^1.2.2" - sshpk "^1.7.0" - http-signature@~1.3.6: version "1.3.6" resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-1.3.6.tgz#cb6fbfdf86d1c974f343be94e87f7fc128662cf9" @@ -6695,16 +6668,6 @@ jsonfile@^6.0.1: optionalDependencies: graceful-fs "^4.1.6" -jsprim@^1.2.2: - version "1.4.2" - resolved "https://registry.yarnpkg.com/jsprim/-/jsprim-1.4.2.tgz#712c65533a15c878ba59e9ed5f0e26d5b77c5feb" - integrity sha512-P2bSOMAc/ciLz6DzgjVlGJP9+BrJWu5UDGK70C2iweC5QBIeFf0ZXRvGjEj2uYgrY2MkAAhsSWHDWlFtEroZWw== - dependencies: - assert-plus "1.0.0" - extsprintf "1.3.0" - json-schema "0.4.0" - verror "1.10.0" - jsprim@^2.0.2: version "2.0.2" resolved "https://registry.yarnpkg.com/jsprim/-/jsprim-2.0.2.tgz#77ca23dbcd4135cd364800d22ff82c2185803d4d" @@ -7070,14 +7033,12 @@ matrix-events-sdk@^0.0.1-beta.7: dependencies: "@babel/runtime" "^7.12.5" another-json "^0.2.0" - browser-request "^0.3.3" bs58 "^5.0.0" content-type "^1.0.4" loglevel "^1.7.1" matrix-events-sdk "^0.0.1-beta.7" p-retry "4" qs "^6.9.6" - request "^2.88.2" unhomoglyph "^1.0.6" matrix-mock-request@^2.5.0: @@ -7396,11 +7357,6 @@ nwsapi@^2.2.0: resolved "https://registry.yarnpkg.com/nwsapi/-/nwsapi-2.2.1.tgz#10a9f268fbf4c461249ebcfe38e359aa36e2577c" integrity sha512-JYOWTeFoS0Z93587vRJgASD5Ut11fYl5NyihP3KrYBvMe1FRRs6RN7m20SA/16GM4P6hTnZjT+UmDOt38UeXNg== -oauth-sign@~0.9.0: - version "0.9.0" - resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.9.0.tgz#47a7b016baa68b5fa0ecf3dee08a85c679ac6455" - integrity sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ== - object-assign@^4.1.0, object-assign@^4.1.1: version "4.1.1" resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" @@ -8303,32 +8259,6 @@ request-progress@^3.0.0: dependencies: throttleit "^1.0.0" -request@^2.88.2: - version "2.88.2" - resolved "https://registry.yarnpkg.com/request/-/request-2.88.2.tgz#d73c918731cb5a87da047e207234146f664d12b3" - integrity sha512-MsvtOrfG9ZcrOwAW+Qi+F6HbD0CWXEh9ou77uOb7FM2WPhwT7smM833PzanhJLsgXjN89Ir6V2PczXNnMpwKhw== - dependencies: - aws-sign2 "~0.7.0" - aws4 "^1.8.0" - caseless "~0.12.0" - combined-stream "~1.0.6" - extend "~3.0.2" - forever-agent "~0.6.1" - form-data "~2.3.2" - har-validator "~5.1.3" - http-signature "~1.2.0" - is-typedarray "~1.0.0" - isstream "~0.1.2" - json-stringify-safe "~5.0.1" - mime-types "~2.1.19" - oauth-sign "~0.9.0" - performance-now "^2.1.0" - qs "~6.5.2" - safe-buffer "^5.1.2" - tough-cookie "~2.5.0" - tunnel-agent "^0.6.0" - uuid "^3.3.2" - require-directory@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" @@ -8515,6 +8445,13 @@ sane@^4.0.3: minimist "^1.1.1" walker "~1.0.5" +sanitize-filename@^1.6.3: + version "1.6.3" + resolved "https://registry.yarnpkg.com/sanitize-filename/-/sanitize-filename-1.6.3.tgz#755ebd752045931977e30b2025d340d7c9090378" + integrity sha512-y/52Mcy7aw3gRm7IrcGDFx/bCk4AhRh2eI9luHOQM86nZsqwiRkkq2GekHXBBD+SmPidc8i2PqtYZl+pWJ8Oeg== + dependencies: + truncate-utf8-bytes "^1.0.0" + sanitize-html@^2.3.2: version "2.7.1" resolved "https://registry.yarnpkg.com/sanitize-html/-/sanitize-html-2.7.1.tgz#a6c2c1a88054a79eeacfac9b0a43f1b393476901" @@ -8788,7 +8725,7 @@ sprintf-js@~1.0.2: resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" integrity sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g== -sshpk@^1.14.1, sshpk@^1.7.0: +sshpk@^1.14.1: version "1.17.0" resolved "https://registry.yarnpkg.com/sshpk/-/sshpk-1.17.0.tgz#578082d92d4fe612b13007496e543fa0fbcbe4c5" integrity sha512-/9HIEs1ZXGhSPE8X6Ccm7Nam1z8KcoCqPdI7ecm1N33EzAetWahvQWVqLZtaZQ+IDKX4IyA2o0gBzqIMkAagHQ== @@ -9228,6 +9165,13 @@ trim-newlines@^3.0.0: resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-3.0.1.tgz#260a5d962d8b752425b32f3a7db0dcacd176c144" integrity sha512-c1PTsA3tYrIsLGkJkzHF+w9F2EyxfXGo4UyJc4pFL++FMjnq0HJS69T3M7d//gKrFKwy429bouPescbjecU+Zw== +truncate-utf8-bytes@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/truncate-utf8-bytes/-/truncate-utf8-bytes-1.0.2.tgz#405923909592d56f78a5818434b0b78489ca5f2b" + integrity sha512-95Pu1QXQvruGEhv62XCMO3Mm90GscOCClvrIUwCM0PYOXK3kaF3l3sIHxx71ThJfcbM2O5Au6SO3AWCSEfW4mQ== + dependencies: + utf8-byte-length "^1.0.1" + tsconfig-paths@^3.14.1: version "3.14.1" resolved "https://registry.yarnpkg.com/tsconfig-paths/-/tsconfig-paths-3.14.1.tgz#ba0734599e8ea36c862798e920bcf163277b137a" @@ -9485,16 +9429,16 @@ use@^3.1.0: resolved "https://registry.yarnpkg.com/use/-/use-3.1.1.tgz#d50c8cac79a19fbc20f2911f56eb973f4e10070f" integrity sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ== +utf8-byte-length@^1.0.1: + version "1.0.4" + resolved "https://registry.yarnpkg.com/utf8-byte-length/-/utf8-byte-length-1.0.4.tgz#f45f150c4c66eee968186505ab93fcbb8ad6bf61" + integrity sha512-4+wkEYLBbWxqTahEsWrhxepcoVOJ+1z5PGIjPZxRkytcdSUaNjIjBM7Xn8E+pdSuV7SzvWovBFA54FO0JSoqhA== + util-deprecate@^1.0.2, util-deprecate@~1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" integrity sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw== -uuid@^3.3.2: - version "3.4.0" - resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee" - integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A== - uuid@^8.3.2: version "8.3.2" resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2" From a4e492eb197e2c0fb9bc9858c74b1b678ff0ce3e Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Mon, 17 Oct 2022 16:41:39 -0600 Subject: [PATCH 17/20] Extract file naming function and make consistent for all 3 types Also use the library we dragged in --- src/utils/exportUtils/Exporter.ts | 18 +++++++----------- src/utils/exportUtils/JSONExport.ts | 9 ++------- src/utils/exportUtils/PlainTextExport.ts | 8 +------- 3 files changed, 10 insertions(+), 25 deletions(-) diff --git a/src/utils/exportUtils/Exporter.ts b/src/utils/exportUtils/Exporter.ts index 18d7c6af423..a6b501f219b 100644 --- a/src/utils/exportUtils/Exporter.ts +++ b/src/utils/exportUtils/Exporter.ts @@ -30,6 +30,7 @@ import { isVoiceMessage } from "../EventUtils"; import { IMediaEventContent } from "../../customisations/models/IMediaEventContent"; import { _t } from "../../languageHandler"; import SdkConfig from "../../SdkConfig"; +import sanitizeFilename from "sanitize-filename"; type BlobFile = { name: string; @@ -75,21 +76,16 @@ export default abstract class Exporter { this.files.push(file); } - protected santizeFileName(filename: string): string { - filename = filename.normalize('NFD').replace(/[\u0300-\u036f]/g, ""); - filename = filename.replace(/\s+/gim, "-"); - filename = filename.replace(/[^a-z0-9.,_-]/gim, ""); - return filename.trim(); + protected makeFileNameNoExtension(brand?: string = "matrix"): string { + const safeRoomName = sanitizeFilename(this.room.name ?? _t("Unnamed Room")); + const safeDate = formatFullDateNoDayISO(new Date()) + .replace(/:/g, '-'); // ISO format automatically removes a lot of stuff for us + return `${brand} - ${safeRoomName} - Chat Export - ${safeDate}`; } protected async downloadZIP(): Promise { const brand = SdkConfig.get().brand; - // TR - 9142 - const filenameWithoutExt = `${brand} - ${this.room.name} - Chat Export -${formatFullDateNoDayISO(new Date())}`; - // TR - 7992 - const filenameWithoutExt = this.santizeFileName( - `${brand} - ${this.room.name} - Chat Export - ${formatFullDateNoDay(new Date())}`, - ); + const filenameWithoutExt = this.makeFileNameNoExtension(brand); const filename = `${filenameWithoutExt}.zip`; const { default: JSZip } = await import('jszip'); diff --git a/src/utils/exportUtils/JSONExport.ts b/src/utils/exportUtils/JSONExport.ts index 9a85eed7f58..d17d08d7cb2 100644 --- a/src/utils/exportUtils/JSONExport.ts +++ b/src/utils/exportUtils/JSONExport.ts @@ -20,7 +20,7 @@ import { EventType } from "matrix-js-sdk/src/@types/event"; import { logger } from "matrix-js-sdk/src/logger"; import Exporter from "./Exporter"; -import { formatFullDateNoDayISO, formatFullDateNoDayNoTime } from "../../DateUtils"; +import { formatFullDateNoDayNoTime } from "../../DateUtils"; import { ExportType, IExportOptions } from "./exportUtils"; import { _t } from "../../languageHandler"; import { haveRendererForEvent } from "../../events/EventTileFactory"; @@ -108,12 +108,7 @@ export default class JSONExporter extends Exporter { this.addFile("export.json", new Blob([text])); await this.downloadZIP(); } else { - // TR - 9142 - const fileName = `matrix-${this.room.name}-export-${formatFullDateNoDayISO(new Date())}.json`; - // TR - 7992 - const fileName = this.santizeFileName( - `matrix-${this.room.name}-export-${formatFullDateNoDay(new Date())}.json`, - ); + const fileName = this.makeFileNameNoExtension() + ".json"; this.downloadPlainText(fileName, text); } diff --git a/src/utils/exportUtils/PlainTextExport.ts b/src/utils/exportUtils/PlainTextExport.ts index f566928eb9f..fe537fd5e7b 100644 --- a/src/utils/exportUtils/PlainTextExport.ts +++ b/src/utils/exportUtils/PlainTextExport.ts @@ -20,7 +20,6 @@ import { logger } from "matrix-js-sdk/src/logger"; import React from "react"; import Exporter from "./Exporter"; -import { formatFullDateNoDayISO } from "../../DateUtils"; import { _t } from "../../languageHandler"; import { ExportType, IExportOptions } from "./exportUtils"; import { textForEvent } from "../../TextForEvent"; @@ -137,12 +136,7 @@ export default class PlainTextExporter extends Exporter { this.addFile("export.txt", new Blob([text])); await this.downloadZIP(); } else { - // TR - 9142 - const fileName = `matrix-${this.room.name}-export-${formatFullDateNoDayISO(new Date())}.txt`; - // TR - 7992 - const fileName = this.santizeFileName( - `matrix-${this.room.name}-export-${formatFullDateNoDay(new Date())}.txt`, - ); + const fileName = this.makeFileNameNoExtension() + ".txt"; this.downloadPlainText(fileName, text); } From 1cdd931302f7169378e020155427e2f1a4209e78 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Mon, 17 Oct 2022 17:28:48 -0600 Subject: [PATCH 18/20] Write tests & associated fixes --- src/DateUtils.ts | 1 + src/utils/exportUtils/Exporter.ts | 20 ++++--- src/utils/exportUtils/JSONExport.ts | 8 ++- src/utils/exportUtils/PlainTextExport.ts | 8 ++- test/test-utils/date.ts | 17 ++++++ test/utils/DateUtils-test.ts | 9 +++- test/utils/exportUtils/HTMLExport-test.ts | 52 +++++++++++++++++++ test/utils/exportUtils/JSONExport-test.ts | 40 ++++++++++++++ .../utils/exportUtils/PlainTextExport-test.ts | 40 ++++++++++++++ .../__snapshots__/HTMLExport-test.ts.snap | 5 ++ .../__snapshots__/JSONExport-test.ts.snap | 3 ++ .../PlainTextExport-test.ts.snap | 3 ++ 12 files changed, 194 insertions(+), 12 deletions(-) create mode 100644 test/test-utils/date.ts create mode 100644 test/utils/exportUtils/HTMLExport-test.ts create mode 100644 test/utils/exportUtils/JSONExport-test.ts create mode 100644 test/utils/exportUtils/PlainTextExport-test.ts create mode 100644 test/utils/exportUtils/__snapshots__/HTMLExport-test.ts.snap create mode 100644 test/utils/exportUtils/__snapshots__/JSONExport-test.ts.snap create mode 100644 test/utils/exportUtils/__snapshots__/PlainTextExport-test.ts.snap diff --git a/src/DateUtils.ts b/src/DateUtils.ts index eafdf428e19..2b50bddb858 100644 --- a/src/DateUtils.ts +++ b/src/DateUtils.ts @@ -1,6 +1,7 @@ /* Copyright 2015, 2016 OpenMarket Ltd Copyright 2017 Vector Creations Ltd +Copyright 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. diff --git a/src/utils/exportUtils/Exporter.ts b/src/utils/exportUtils/Exporter.ts index a6b501f219b..fed5e0bbfe8 100644 --- a/src/utils/exportUtils/Exporter.ts +++ b/src/utils/exportUtils/Exporter.ts @@ -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. @@ -58,6 +58,10 @@ export default abstract class Exporter { window.addEventListener("beforeunload", this.onBeforeUnload); } + public get destinationFileName(): string { + return this.makeFileNameNoExtension(SdkConfig.get().brand) + ".zip"; + } + protected onBeforeUnload(e: BeforeUnloadEvent): string { e.preventDefault(); return e.returnValue = _t("Are you sure you want to exit during this export?"); @@ -76,17 +80,19 @@ export default abstract class Exporter { this.files.push(file); } - protected makeFileNameNoExtension(brand?: string = "matrix"): string { - const safeRoomName = sanitizeFilename(this.room.name ?? _t("Unnamed Room")); + protected makeFileNameNoExtension(brand: string = "matrix"): string { + // First try to use the real name of the room, then a translated copy of a generic name, + // then finally hardcoded default to guarantee we'll have a name. + const safeRoomName = sanitizeFilename(this.room.name ?? _t("Unnamed Room")).trim() || "Unnamed Room"; const safeDate = formatFullDateNoDayISO(new Date()) .replace(/:/g, '-'); // ISO format automatically removes a lot of stuff for us - return `${brand} - ${safeRoomName} - Chat Export - ${safeDate}`; + const safeBrand = sanitizeFilename(brand); + return `${safeBrand} - ${safeRoomName} - Chat Export - ${safeDate}`; } protected async downloadZIP(): Promise { - const brand = SdkConfig.get().brand; - const filenameWithoutExt = this.makeFileNameNoExtension(brand); - const filename = `${filenameWithoutExt}.zip`; + const filename = this.destinationFileName; + const filenameWithoutExt = filename.substring(0, filename.length - 4); // take off the .zip const { default: JSZip } = await import('jszip'); const zip = new JSZip(); diff --git a/src/utils/exportUtils/JSONExport.ts b/src/utils/exportUtils/JSONExport.ts index d17d08d7cb2..a0dc5e036e6 100644 --- a/src/utils/exportUtils/JSONExport.ts +++ b/src/utils/exportUtils/JSONExport.ts @@ -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. @@ -38,6 +38,10 @@ export default class JSONExporter extends Exporter { super(room, exportType, exportOptions, setProgressText); } + public get destinationFileName(): string { + return this.makeFileNameNoExtension() + ".json"; + } + protected createJSONString(): string { const exportDate = formatFullDateNoDayNoTime(new Date()); const creator = this.room.currentState.getStateEvents(EventType.RoomCreate, "")?.getSender(); @@ -108,7 +112,7 @@ export default class JSONExporter extends Exporter { this.addFile("export.json", new Blob([text])); await this.downloadZIP(); } else { - const fileName = this.makeFileNameNoExtension() + ".json"; + const fileName = this.destinationFileName; this.downloadPlainText(fileName, text); } diff --git a/src/utils/exportUtils/PlainTextExport.ts b/src/utils/exportUtils/PlainTextExport.ts index fe537fd5e7b..3150b15c642 100644 --- a/src/utils/exportUtils/PlainTextExport.ts +++ b/src/utils/exportUtils/PlainTextExport.ts @@ -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. @@ -42,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; @@ -136,7 +140,7 @@ export default class PlainTextExporter extends Exporter { this.addFile("export.txt", new Blob([text])); await this.downloadZIP(); } else { - const fileName = this.makeFileNameNoExtension() + ".txt"; + const fileName = this.destinationFileName; this.downloadPlainText(fileName, text); } diff --git a/test/test-utils/date.ts b/test/test-utils/date.ts new file mode 100644 index 00000000000..c3010b2ae94 --- /dev/null +++ b/test/test-utils/date.ts @@ -0,0 +1,17 @@ +/* +Copyright 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. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +export const REPEATABLE_DATE = new Date(2022, 10, 17, 16, 58, 32, 517); diff --git a/test/utils/DateUtils-test.ts b/test/utils/DateUtils-test.ts index 7804fd6e9cf..7fffcd84551 100644 --- a/test/utils/DateUtils-test.ts +++ b/test/utils/DateUtils-test.ts @@ -14,7 +14,8 @@ See the License for the specific language governing permissions and limitations under the License. */ -import { formatSeconds, formatRelativeTime, formatDuration } from "../../src/DateUtils"; +import { formatSeconds, formatRelativeTime, formatDuration, formatFullDateNoDayISO } from "../../src/DateUtils"; +import { REPEATABLE_DATE } from "../test-utils/date"; describe("formatSeconds", () => { it("correctly formats time with hours", () => { @@ -92,3 +93,9 @@ describe('formatDuration()', () => { expect(formatDuration(input)).toEqual(expectedResult); }); }); + +describe("formatFullDateNoDayISO", () => { + it("should return ISO format", () => { + expect(formatFullDateNoDayISO(REPEATABLE_DATE)).toEqual("2022-11-17T16:58:32.517Z"); + }); +}); diff --git a/test/utils/exportUtils/HTMLExport-test.ts b/test/utils/exportUtils/HTMLExport-test.ts new file mode 100644 index 00000000000..1f2225e64ef --- /dev/null +++ b/test/utils/exportUtils/HTMLExport-test.ts @@ -0,0 +1,52 @@ +/* +Copyright 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. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +import { createTestClient, mkStubRoom } from "../../test-utils"; +import { ExportType, IExportOptions } from "../../../src/utils/exportUtils/exportUtils"; +import { REPEATABLE_DATE } from "../../test-utils/date"; +import SdkConfig from "../../../src/SdkConfig"; +import { mocked } from "jest-mock"; +import HTMLExporter from "../../../src/utils/exportUtils/HtmlExport"; + +describe("HTMLExport", () => { + beforeEach(() => { + jest.useFakeTimers('modern'); + jest.setSystemTime(REPEATABLE_DATE); + }); + + afterEach(() => { + mocked(SdkConfig.get).mockRestore(); + }); + + it("should have an SDK-branded destination file name", () => { + const roomName = "My / Test / Room: Welcome"; + const client = createTestClient(); + const stubOptions: IExportOptions = { + attachmentsIncluded: false, + maxSize: 50000000, + }; + const stubRoom = mkStubRoom("!myroom:example.org", roomName, client); + const exporter = new HTMLExporter(stubRoom, ExportType.Timeline, stubOptions, () => {}); + + expect(exporter.destinationFileName).toMatchSnapshot(); + + jest.spyOn(SdkConfig, "get").mockImplementation(() => { + return { brand: "BrandedChat/WithSlashes/ForFun" }; + }); + + expect(exporter.destinationFileName).toMatchSnapshot(); + }); +}); diff --git a/test/utils/exportUtils/JSONExport-test.ts b/test/utils/exportUtils/JSONExport-test.ts new file mode 100644 index 00000000000..92e005ee545 --- /dev/null +++ b/test/utils/exportUtils/JSONExport-test.ts @@ -0,0 +1,40 @@ +/* +Copyright 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. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +import JSONExporter from "../../../src/utils/exportUtils/JSONExport"; +import { createTestClient, mkStubRoom } from "../../test-utils"; +import { ExportType, IExportOptions } from "../../../src/utils/exportUtils/exportUtils"; +import { REPEATABLE_DATE } from "../../test-utils/date"; + +describe("JSONExport", () => { + beforeEach(() => { + jest.useFakeTimers('modern'); + jest.setSystemTime(REPEATABLE_DATE); + }); + + it("should have a Matrix-branded destination file name", () => { + const roomName = "My / Test / Room: Welcome"; + const client = createTestClient(); + const stubOptions: IExportOptions = { + attachmentsIncluded: false, + maxSize: 50000000, + }; + const stubRoom = mkStubRoom("!myroom:example.org", roomName, client); + const exporter = new JSONExporter(stubRoom, ExportType.Timeline, stubOptions, () => {}); + + expect(exporter.destinationFileName).toMatchSnapshot(); + }); +}); diff --git a/test/utils/exportUtils/PlainTextExport-test.ts b/test/utils/exportUtils/PlainTextExport-test.ts new file mode 100644 index 00000000000..d7545afdffa --- /dev/null +++ b/test/utils/exportUtils/PlainTextExport-test.ts @@ -0,0 +1,40 @@ +/* +Copyright 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. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +import { createTestClient, mkStubRoom } from "../../test-utils"; +import { ExportType, IExportOptions } from "../../../src/utils/exportUtils/exportUtils"; +import PlainTextExporter from "../../../src/utils/exportUtils/PlainTextExport"; +import { REPEATABLE_DATE } from "../../test-utils/date"; + +describe("PlainTextExport", () => { + beforeEach(() => { + jest.useFakeTimers('modern'); + jest.setSystemTime(REPEATABLE_DATE); + }); + + it("should have a Matrix-branded destination file name", () => { + const roomName = "My / Test / Room: Welcome"; + const client = createTestClient(); + const stubOptions: IExportOptions = { + attachmentsIncluded: false, + maxSize: 50000000, + }; + const stubRoom = mkStubRoom("!myroom:example.org", roomName, client); + const exporter = new PlainTextExporter(stubRoom, ExportType.Timeline, stubOptions, () => {}); + + expect(exporter.destinationFileName).toMatchSnapshot(); + }); +}); diff --git a/test/utils/exportUtils/__snapshots__/HTMLExport-test.ts.snap b/test/utils/exportUtils/__snapshots__/HTMLExport-test.ts.snap new file mode 100644 index 00000000000..5cfed9ef902 --- /dev/null +++ b/test/utils/exportUtils/__snapshots__/HTMLExport-test.ts.snap @@ -0,0 +1,5 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`HTMLExport should have an SDK-branded destination file name 1`] = `"Element - My Test Room Welcome - Chat Export - 2022-11-17T16-58-32.517Z.zip"`; + +exports[`HTMLExport should have an SDK-branded destination file name 2`] = `"BrandedChatWithSlashesForFun - My Test Room Welcome - Chat Export - 2022-11-17T16-58-32.517Z.zip"`; diff --git a/test/utils/exportUtils/__snapshots__/JSONExport-test.ts.snap b/test/utils/exportUtils/__snapshots__/JSONExport-test.ts.snap new file mode 100644 index 00000000000..5f0d78cc58c --- /dev/null +++ b/test/utils/exportUtils/__snapshots__/JSONExport-test.ts.snap @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`JSONExport should have a Matrix-branded destination file name 1`] = `"matrix - My Test Room Welcome - Chat Export - 2022-11-17T16-58-32.517Z.json"`; diff --git a/test/utils/exportUtils/__snapshots__/PlainTextExport-test.ts.snap b/test/utils/exportUtils/__snapshots__/PlainTextExport-test.ts.snap new file mode 100644 index 00000000000..ebee2957b76 --- /dev/null +++ b/test/utils/exportUtils/__snapshots__/PlainTextExport-test.ts.snap @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`PlainTextExport should have a Matrix-branded destination file name 1`] = `"matrix - My Test Room Welcome - Chat Export - 2022-11-17T16-58-32.517Z.txt"`; From d07b72a3139b960c6b84f4ae48e1d803433b4150 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Mon, 17 Oct 2022 17:31:37 -0600 Subject: [PATCH 19/20] Apply linters locally --- src/i18n/strings/en_EN.json | 2 +- src/utils/exportUtils/Exporter.ts | 4 ++-- test/utils/exportUtils/HTMLExport-test.ts | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index fa0b1690dcf..ca804ea50bd 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -756,6 +756,7 @@ "Zoom in": "Zoom in", "Zoom out": "Zoom out", "Are you sure you want to exit during this export?": "Are you sure you want to exit during this export?", + "Unnamed Room": "Unnamed Room", "Generating a ZIP": "Generating a ZIP", "Fetched %(count)s events out of %(total)s|other": "Fetched %(count)s events out of %(total)s", "Fetched %(count)s events out of %(total)s|one": "Fetched %(count)s event out of %(total)s", @@ -2768,7 +2769,6 @@ "Or send invite link": "Or send invite link", "Unnamed Space": "Unnamed Space", "Invite to %(roomName)s": "Invite to %(roomName)s", - "Unnamed Room": "Unnamed Room", "Invite someone using their name, email address, username (like ) or share this space.": "Invite someone using their name, email address, username (like ) or share this space.", "Invite someone using their name, username (like ) or share this space.": "Invite someone using their name, username (like ) or share this space.", "Invite someone using their name, email address, username (like ) or share this room.": "Invite someone using their name, email address, username (like ) or share this room.", diff --git a/src/utils/exportUtils/Exporter.ts b/src/utils/exportUtils/Exporter.ts index fed5e0bbfe8..ec20f395e32 100644 --- a/src/utils/exportUtils/Exporter.ts +++ b/src/utils/exportUtils/Exporter.ts @@ -20,6 +20,7 @@ import { MatrixClient } from "matrix-js-sdk/src/client"; import { Direction } from "matrix-js-sdk/src/models/event-timeline"; import { saveAs } from "file-saver"; import { logger } from "matrix-js-sdk/src/logger"; +import sanitizeFilename from "sanitize-filename"; import { MatrixClientPeg } from "../../MatrixClientPeg"; import { ExportType, IExportOptions } from "./exportUtils"; @@ -30,7 +31,6 @@ import { isVoiceMessage } from "../EventUtils"; import { IMediaEventContent } from "../../customisations/models/IMediaEventContent"; import { _t } from "../../languageHandler"; import SdkConfig from "../../SdkConfig"; -import sanitizeFilename from "sanitize-filename"; type BlobFile = { name: string; @@ -80,7 +80,7 @@ export default abstract class Exporter { this.files.push(file); } - protected makeFileNameNoExtension(brand: string = "matrix"): string { + protected makeFileNameNoExtension(brand = "matrix"): string { // First try to use the real name of the room, then a translated copy of a generic name, // then finally hardcoded default to guarantee we'll have a name. const safeRoomName = sanitizeFilename(this.room.name ?? _t("Unnamed Room")).trim() || "Unnamed Room"; diff --git a/test/utils/exportUtils/HTMLExport-test.ts b/test/utils/exportUtils/HTMLExport-test.ts index 1f2225e64ef..bdb4dff89b5 100644 --- a/test/utils/exportUtils/HTMLExport-test.ts +++ b/test/utils/exportUtils/HTMLExport-test.ts @@ -14,11 +14,12 @@ See the License for the specific language governing permissions and limitations under the License. */ +import { mocked } from "jest-mock"; + import { createTestClient, mkStubRoom } from "../../test-utils"; import { ExportType, IExportOptions } from "../../../src/utils/exportUtils/exportUtils"; import { REPEATABLE_DATE } from "../../test-utils/date"; import SdkConfig from "../../../src/SdkConfig"; -import { mocked } from "jest-mock"; import HTMLExporter from "../../../src/utils/exportUtils/HtmlExport"; describe("HTMLExport", () => { From 9226ab1c2cd2ed9a1d17b4152996c7a83f15aa21 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Mon, 17 Oct 2022 17:51:35 -0600 Subject: [PATCH 20/20] Include new date util in index --- test/test-utils/index.ts | 1 + test/utils/DateUtils-test.ts | 2 +- test/utils/exportUtils/HTMLExport-test.ts | 3 +-- test/utils/exportUtils/JSONExport-test.ts | 3 +-- test/utils/exportUtils/PlainTextExport-test.ts | 3 +-- 5 files changed, 5 insertions(+), 7 deletions(-) diff --git a/test/test-utils/index.ts b/test/test-utils/index.ts index 959b41352b9..2fa87e1e678 100644 --- a/test/test-utils/index.ts +++ b/test/test-utils/index.ts @@ -24,3 +24,4 @@ export * from './test-utils'; export * from './call'; export * from './wrappers'; export * from './utilities'; +export * from './date'; diff --git a/test/utils/DateUtils-test.ts b/test/utils/DateUtils-test.ts index 7fffcd84551..784be85ea7e 100644 --- a/test/utils/DateUtils-test.ts +++ b/test/utils/DateUtils-test.ts @@ -15,7 +15,7 @@ limitations under the License. */ import { formatSeconds, formatRelativeTime, formatDuration, formatFullDateNoDayISO } from "../../src/DateUtils"; -import { REPEATABLE_DATE } from "../test-utils/date"; +import { REPEATABLE_DATE } from "../test-utils"; describe("formatSeconds", () => { it("correctly formats time with hours", () => { diff --git a/test/utils/exportUtils/HTMLExport-test.ts b/test/utils/exportUtils/HTMLExport-test.ts index bdb4dff89b5..e009205d8d1 100644 --- a/test/utils/exportUtils/HTMLExport-test.ts +++ b/test/utils/exportUtils/HTMLExport-test.ts @@ -16,9 +16,8 @@ limitations under the License. import { mocked } from "jest-mock"; -import { createTestClient, mkStubRoom } from "../../test-utils"; +import { createTestClient, mkStubRoom, REPEATABLE_DATE } from "../../test-utils"; import { ExportType, IExportOptions } from "../../../src/utils/exportUtils/exportUtils"; -import { REPEATABLE_DATE } from "../../test-utils/date"; import SdkConfig from "../../../src/SdkConfig"; import HTMLExporter from "../../../src/utils/exportUtils/HtmlExport"; diff --git a/test/utils/exportUtils/JSONExport-test.ts b/test/utils/exportUtils/JSONExport-test.ts index 92e005ee545..3f161a23ea2 100644 --- a/test/utils/exportUtils/JSONExport-test.ts +++ b/test/utils/exportUtils/JSONExport-test.ts @@ -15,9 +15,8 @@ limitations under the License. */ import JSONExporter from "../../../src/utils/exportUtils/JSONExport"; -import { createTestClient, mkStubRoom } from "../../test-utils"; +import { createTestClient, mkStubRoom, REPEATABLE_DATE } from "../../test-utils"; import { ExportType, IExportOptions } from "../../../src/utils/exportUtils/exportUtils"; -import { REPEATABLE_DATE } from "../../test-utils/date"; describe("JSONExport", () => { beforeEach(() => { diff --git a/test/utils/exportUtils/PlainTextExport-test.ts b/test/utils/exportUtils/PlainTextExport-test.ts index d7545afdffa..919eb40cfa9 100644 --- a/test/utils/exportUtils/PlainTextExport-test.ts +++ b/test/utils/exportUtils/PlainTextExport-test.ts @@ -14,10 +14,9 @@ See the License for the specific language governing permissions and limitations under the License. */ -import { createTestClient, mkStubRoom } from "../../test-utils"; +import { createTestClient, mkStubRoom, REPEATABLE_DATE } from "../../test-utils"; import { ExportType, IExportOptions } from "../../../src/utils/exportUtils/exportUtils"; import PlainTextExporter from "../../../src/utils/exportUtils/PlainTextExport"; -import { REPEATABLE_DATE } from "../../test-utils/date"; describe("PlainTextExport", () => { beforeEach(() => {