[CORL-827/828] Scrub downloaded comments of html tags, rename archive (#2767)

* Prefix comment download filename with "coral"

CORL-827

* Scrub html tags from downloaded comment data

CORL-828

Co-authored-by: Kim Gardner <kgardnr@gmail.com>
Co-authored-by: Wyatt Johnson <accounts+github@wyattjoh.ca>
This commit is contained in:
Nick Funk
2019-12-20 23:46:24 +00:00
committed by Wyatt Johnson
co-authored by Kim Gardner Wyatt Johnson
parent 9d050e8b51
commit 0f456330c5
@@ -2,6 +2,7 @@ import archiver from "archiver";
import stringify from "csv-stringify";
import DataLoader from "dataloader";
import { Response } from "express";
import htmlToText from "html-to-text";
import { kebabCase } from "lodash";
import { Db } from "mongodb";
@@ -52,7 +53,7 @@ export async function sendUserDownload(
let commentBatch: Array<Readonly<Comment>> = [];
// Generate the filename of the file that the user will download.
const filename = `talk-${kebabCase(user.username)}-${kebabCase(
const filename = `coral-${kebabCase(user.username)}-${kebabCase(
formatter.format(latestContentDate)
)}.zip`;
@@ -107,7 +108,7 @@ export async function sendUserDownload(
const urlBuilder = new URL(storyURL);
urlBuilder.searchParams.set("commentID", commentID);
const commentURL = urlBuilder.href;
const body = revision.body;
const body = htmlToText.fromString(revision.body);
csv.write([commentID, createdAt, storyURL, commentURL, body]);
}