Skip to content

Commit

Permalink
fix comments
Browse files Browse the repository at this point in the history
  • Loading branch information
upacyxou committed Oct 25, 2023
1 parent 7e39951 commit fa784ef
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/controllers/token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,21 @@ export default class TokenController {
@Ctx() ctx: Context
) {
const { token } = body
if (!token) return ctx.throw(badRequest('No token'))
const existingToken = await TokenModel.findOne({ token })
if (existingToken) {
existingToken.waitlist = true
await existingToken.save()
return { success: true }
}
if (!token) return ctx.throw(badRequest('No token'))
const newToken = new TokenModel({ token, waitlist: true })
await newToken.save()
return { success: true }
}

@Put('/waitlist/:token')
async markAsReceived(
@Params('token') notificationToken: string,
@Ctx() ctx: Context
) {
const tokenDoc = await TokenModel.findOne({ token: notificationToken })
async markAsReceived(@Params('token') token: string, @Ctx() ctx: Context) {
const tokenDoc = await TokenModel.findOne({ token })
if (!tokenDoc) return ctx.throw(badRequest('Token not found'))
tokenDoc.waitlist = undefined
await tokenDoc.save()
Expand Down

0 comments on commit fa784ef

Please sign in to comment.