MCPcopy Create free account
hub / github.com/monkeytypegame/monkeytype / addDebugInboxItem

Function addDebugInboxItem

backend/src/api/controllers/dev.ts:47–76  ·  view source on GitHub ↗
(
  req: MonkeyRequest<undefined, AddDebugInboxItemRequest>,
)

Source from the content-addressed store, hash-verified

45}
46
47export 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
78async function getOrCreateUser(
79 username: string,

Callers

nothing calls this directly

Calls 1

buildMonkeyMailFunction · 0.90

Tested by

no test coverage detected