Add tournament and multiplayer community chat moderation
All checks were successful
Deploy MineGeo to Dokploy / deploy (push) Successful in 12m17s

This commit is contained in:
2026-10-27 12:54:15 +05:00
parent b8a430d4c2
commit 9c314ecb4e
19 changed files with 1070 additions and 16 deletions

View File

@@ -68,6 +68,63 @@ try {
JSON.stringify({ ...base, ...payload }),
])
)[0].id;
const communityEvent = await create();
const eventAction = (account, action, payload = {}) =>
q("select public.tournament_action($1,$2,$3,$4)", [
communityEvent,
account,
action,
JSON.stringify(payload),
]);
const community = (account, action, payload = {}) =>
q("select public.tournament_community($1,$2,$3,$4) value", [
communityEvent,
account,
action,
JSON.stringify(payload),
]);
const chat = (account, text = null, clientId = null) =>
q("select public.tournament_chat($1,$2,$3,$4) value", [
communityEvent,
account,
text,
clientId,
]);
await eventAction(users[1], "join");
await eventAction(users[2], "join");
await assert.rejects(
community(users[1], "ban", { accountId: users[2] }),
/moderator permission/,
);
await community(users[0], "admin", { accountId: users[1] });
await assert.rejects(
community(users[1], "ban", { accountId: users[0] }),
/owner or yourself/,
);
await community(users[1], "tag", { accountId: users[2], tag: "Explorer" });
await community(users[1], "slow", { seconds: 10 });
const messageId = randomUUID();
await chat(users[2], "Hello", messageId);
const repeated = await chat(users[2], "Hello", messageId);
assert.equal(repeated[0].value.messages.length, 1);
assert.equal(repeated[0].value.messages[0].tag, "Explorer");
await assert.rejects(chat(users[2], "Too fast", randomUUID()), /slow mode/);
await community(users[1], "ban", { accountId: users[2] });
await assert.rejects(chat(users[2]), /membership/);
await assert.rejects(eventAction(users[2], "join"), /banned/);
await community(users[1], "unban", { accountId: users[2] });
await eventAction(users[2], "join");
await eventAction(users[1], "leave");
await assert.rejects(
community(users[1], "slow", { seconds: 0 }),
/membership/,
);
await eventAction(users[1], "join");
await assert.rejects(
community(users[1], "slow", { seconds: 0 }),
/moderator permission/,
);
await q("delete from public.tournaments where id=$1", [communityEvent]);
const voidEvent = await create({
difficulty: "void",
roundTimeSeconds: 10,