Skip to content

Commit

Permalink
fix(badge): make sure the 365 streak badge is not awarded multiple times
Browse files Browse the repository at this point in the history
  • Loading branch information
Miodec committed Sep 4, 2023
1 parent 2a478a0 commit babd92d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion backend/src/api/controllers/result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,15 @@ export async function addResult(

const shouldGetBadge =
streak >= 365 &&
user.inventory?.badges?.find((b) => b.id === 14) === undefined;
user.inventory?.badges?.find((b) => b.id === 14) === undefined &&
(
user.inbox
?.map((i) =>
(i.rewards ?? []).map((r) => (r.type === "badge" ? r.item.id : null))
)
.flat() ?? []
).includes(14) === false;

if (shouldGetBadge) {
const mail = buildMonkeyMail({
subject: "Badge",
Expand Down

0 comments on commit babd92d

Please sign in to comment.