diff --git a/src/Mastodon.ts b/src/Mastodon.ts index 6c215a1..5638ba8 100644 --- a/src/Mastodon.ts +++ b/src/Mastodon.ts @@ -177,4 +177,8 @@ ${text.split("\n").map(txt => " > " + txt).join("\n")}`) return mediaAttachment.id } } + + static totalLength(overview: string, rest: string[]) { + return overview.length + rest.join("\n").length + 1 + } } \ No newline at end of file diff --git a/src/Postbuilder.ts b/src/Postbuilder.ts index 7080402..3f5fc64 100644 --- a/src/Postbuilder.ts +++ b/src/Postbuilder.ts @@ -110,7 +110,7 @@ export class Postbuilder { continue } const overview = await this.createOverviewForContributor(uid, changesetsMade) - if (MastodonPoster.length23(overview) + MastodonPoster.length23(toSend.join("\n")) + 1 /*+1 for the separating \n*/ > 500) { + if (MastodonPoster.totalLength(overview, toSend) > 500) { break } toSend.push(overview) @@ -140,7 +140,7 @@ export class Postbuilder { const themeId = theme.key const changesetsMade = perTheme.get(themeId) const overview = await this.createOverviewForTheme(themeId, changesetsMade) - if (MastodonPoster.length23(overview) + MastodonPoster.length23(toSend.join("\n")) + 1 > 500) { + if (MastodonPoster.totalLength(overview, toSend) > 500) { break } toSend.push(overview)