Skip to content

Commit

Permalink
Allow customizing mastodon server url via env var (#3)
Browse files Browse the repository at this point in the history
* Allow customizing mastodon server url via env var

* Make posts unlisted
  • Loading branch information
mraerino authored Nov 13, 2024
1 parent 60dc214 commit d887dc7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/routers/meteApiUsersRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ if (meteBaseUrl.endsWith("/")) {
}

let masto;
if (process.env.MASTODON_ACCESS_TOKEN) {
if (process.env.MASTODON_SERVER_URL && process.env.MASTODON_ACCESS_TOKEN) {
masto = createRestAPIClient({
url: "https://botsin.space",
url: process.env.MASTODON_SERVER_URL,
accessToken: process.env.MASTODON_ACCESS_TOKEN,
});
}

const postDrinkToMastodon = async (drinkId: number) => {
if (!masto) {
console.warn(
"Not posting to mastodon because MASTODON_ACCESS_TOKEN not set"
"Not posting to mastodon because MASTODON_SERVER_URL or MASTODON_ACCESS_TOKEN not set"
);
return;
}
Expand All @@ -39,7 +39,7 @@ const postDrinkToMastodon = async (drinkId: number) => {
const drink = await drinkResponse.json();
await masto.v1.statuses.create({
status: `${drink.name} wurde gekauft!`,
visibility: "public",
visibility: "unlisted",
});
};

Expand Down

0 comments on commit d887dc7

Please sign in to comment.