From ece5115edbf890188523a51dfcd75f4a34098c08 Mon Sep 17 00:00:00 2001 From: Volpeon Date: Tue, 22 Mar 2022 17:31:16 +0100 Subject: Include all sources in post --- src/api/mastodon/index.ts | 6 +++--- src/services/jobs.ts | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/api/mastodon/index.ts b/src/api/mastodon/index.ts index 3bfe9c8..13185ab 100644 --- a/src/api/mastodon/index.ts +++ b/src/api/mastodon/index.ts @@ -34,13 +34,13 @@ export async function upload(buf: Buffer, filename: string) { export async function createStatus( postUrl: string, - sourceUrl: string | undefined, + sourceUrls: readonly string[], spoiler: string[], attachmentId: string ) { let lines = [postUrl]; - if (sourceUrl) { - lines.push(`Source: ${sourceUrl}`); + for (let i = 0; i < sourceUrls.length; ++i) { + lines.push(`Source ${i + 1}: ${sourceUrls[i]}`); } const spoilerText = spoiler.length ? `CW: ${spoiler.join(", ")}` : undefined; diff --git a/src/services/jobs.ts b/src/services/jobs.ts index 5ecae66..bb0c3e1 100644 --- a/src/services/jobs.ts +++ b/src/services/jobs.ts @@ -27,7 +27,6 @@ export async function postRandomPicture() { } async function handlePost(post: e621.Post) { - const source = post.sources.length ? post.sources[0] : undefined; const cws = config.cw.filter((w) => post.tags.general.includes(w)); console.log(`Downloading image...`); @@ -53,7 +52,7 @@ async function handlePost(post: e621.Post) { console.log(`Posting status...`); - const status = await mastodon.createStatus(`https://e926.net/posts/${post.id}`, source, cws, attachment.id); + const status = await mastodon.createStatus(`https://e926.net/posts/${post.id}`, post.sources, cws, attachment.id); console.log(`Done! ${status.url}`); } -- cgit v1.2.3-70-g09d2