Skip to content

Commit

Permalink
oop
Browse files Browse the repository at this point in the history
  • Loading branch information
Govorunb committed Jul 7, 2024
1 parent a980104 commit f967bf4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions ebs/src/modules/orders/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ app.post(
if (!req.user.login || !req.user.displayName) {
try {
await updateUserTwitchInfo(req.user);
userInfo.login = req.user.login!;
userInfo.displayName = req.user.displayName!;
} catch (error) {
logContext.important = true;
logMessage.header = "Could not get Twitch user info";
Expand Down
3 changes: 2 additions & 1 deletion ebs/src/modules/twitch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import { TwitchUser } from "./game/messages";
export async function getTwitchUser(id: string): Promise<TwitchUser | null> {
const user = await getHelixUser(id);
if (!user) {
console.warn(`Twitch user ${id} was not found`);
return null;
}
return {
id: user.id,
displayName: user.displayName,
login: user.name,
displayName: user.displayName,
};
}
5 changes: 3 additions & 2 deletions ebs/src/util/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export async function saveOrder(order: Order) {
SET state = ?, cart = ?, receipt = ?, result = ?, updatedAt = ?
WHERE id = ?
`,
[order.state, JSON.stringify(order.cart), order.receipt, order.receipt, order.updatedAt, order.id]
[order.state, JSON.stringify(order.cart), order.receipt, order.result, order.updatedAt, order.id]
);
}

Expand Down Expand Up @@ -135,7 +135,7 @@ export async function saveUser(user: User) {
}
}

export async function updateUserTwitchInfo(user: User) {
export async function updateUserTwitchInfo(user: User): Promise<User> {
try {
user = {
...user,
Expand All @@ -159,4 +159,5 @@ export async function updateUserTwitchInfo(user: User) {
console.error(e);
throw e;
}
return user;
}

0 comments on commit f967bf4

Please sign in to comment.