Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow customizing mastodon server url via env var #3

Merged
merged 2 commits into from
Nov 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading