( req: MonkeyRequest<undefined, AddDebugInboxItemRequest>, )
| 45 | } |
| 46 | |
| 47 | export async function addDebugInboxItem( |
| 48 | req: MonkeyRequest<undefined, AddDebugInboxItemRequest>, |
| 49 | ): Promise<MonkeyResponse> { |
| 50 | const { uid } = req.ctx.decodedToken; |
| 51 | const { rewardType } = req.body; |
| 52 | const inboxConfig = req.ctx.configuration.users.inbox; |
| 53 | |
| 54 | const rewards = |
| 55 | rewardType === "xp" |
| 56 | ? [{ type: "xp" as const, item: 1000 }] |
| 57 | : rewardType === "badge" |
| 58 | ? [{ type: "badge" as const, item: { id: 1 } }] |
| 59 | : []; |
| 60 | |
| 61 | const body = |
| 62 | rewardType === "xp" |
| 63 | ? "Here is your 1000 XP reward for debugging." |
| 64 | : rewardType === "badge" |
| 65 | ? "Here is your Developer badge reward." |
| 66 | : "A debug inbox item with no reward."; |
| 67 | |
| 68 | const mail = buildMonkeyMail({ |
| 69 | subject: "Debug Inbox Item", |
| 70 | body, |
| 71 | rewards, |
| 72 | }); |
| 73 | |
| 74 | await UserDal.addToInbox(uid, [mail], inboxConfig); |
| 75 | return new MonkeyResponse("Debug inbox item added", null); |
| 76 | } |
| 77 | |
| 78 | async function getOrCreateUser( |
| 79 | username: string, |
nothing calls this directly
no test coverage detected