Fix publish not working without content warning

Problem: The new content warning code was applying a content warning to
all posts, which tried to publish an invalid content warning `""` and
threw an error.

Solution: Only publish a content warning if it's a string with non-zero
length.
This commit is contained in:
Christian Bundy 2020-02-13 15:55:41 -08:00
parent 3f78b98a30
commit 8a9e260728
1 changed files with 5 additions and 1 deletions

View File

@ -490,7 +490,11 @@ router
})
.post("/publish/", koaBody(), async ctx => {
const text = String(ctx.request.body.text);
const contentWarning = String(ctx.request.body.contentWarning);
const rawContentWarning = String(ctx.request.body.contentWarning);
// Only submit content warning if it's a string with non-zero length.
const contentWarning =
rawContentWarning.length > 0 ? rawContentWarning : undefined;
const publish = async ({ text, contentWarning }) => {
const mentions =