Skip to content

Commit

Permalink
b
Browse files Browse the repository at this point in the history
  • Loading branch information
Govorunb committed Jun 15, 2024
1 parent ce50035 commit a226429
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
14 changes: 1 addition & 13 deletions ebs/src/modules/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import { addFulfilledTransaction, deletePrepurchase, getPrepurchase, isReceiptUs
import { sendToLogger } from "../util/logger";
import { connection } from "./game";
import { TwitchUser } from "./game/messages";
import { getHelixUser } from "../util/twitch";
import { asyncCatch } from "../util/middleware";
import { sendShock } from "../util/pishock";
import { getTwitchUser } from "./twitch";

app.post(
"/public/prepurchase",
Expand Down Expand Up @@ -287,18 +287,6 @@ app.post(
})
);

async function getTwitchUser(id: string): Promise<TwitchUser | null> {
const user = await getHelixUser(id);
if (!user) {
return null;
}
return {
id: user.id,
displayName: user.displayName,
login: user.name,
};
}

function validateArgs(config: Config, cart: Cart, logContext: LogMessage): string | undefined {
const redeem = config.redeems![cart.id];

Expand Down
15 changes: 14 additions & 1 deletion ebs/src/modules/twitch.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
import { app } from "..";
import { asyncCatch } from "../util/middleware";
import { getHelixUser } from "../util/twitch";
import { TwitchUser } from "./game/messages";

app.get("/private/user/:id", asyncCatch(async (req, res) => {
res.json(await getHelixUser(req.params["id"]));
res.json(await getTwitchUser(req.params["id"]));
}));

export async function getTwitchUser(id: string): Promise<TwitchUser | null> {
const user = await getHelixUser(id);
if (!user) {
return null;
}
return {
id: user.id,
displayName: user.displayName,
login: user.name,
};
}

0 comments on commit a226429

Please sign in to comment.