From 6e3aa94f86f1f91ae500284c7050c9fd00083663 Mon Sep 17 00:00:00 2001 From: Bianca Date: Mon, 26 Oct 2026 19:23:01 +0100 Subject: [PATCH] fix(people): accept unknown Telegram group admins in the Capo area Backend PoliNetworkOrg/backend#93 drops tg_group_admins (RFC v3 Phase 6). Group admins are native Telegram status, which the backend does not store, so the Capo area now reports `admins: null` per group. The contract accepted only a number, so the page would fail to load. A null count is now accepted and shows neither a count nor the "No admins" badge, which stays for a known count of zero. --- src/features/people/capo-page.tsx | 2 +- src/features/people/people.contract.ts | 3 ++- tests/people-input.test.mjs | 12 ++++++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/features/people/capo-page.tsx b/src/features/people/capo-page.tsx index 081ac6e0..0bd23082 100644 --- a/src/features/people/capo-page.tsx +++ b/src/features/people/capo-page.tsx @@ -173,7 +173,7 @@ export function CapoPage({ area }: { area: CapoArea }) { {group.chatId} - {group.admins ? null : No admins} + {group.admins === 0 ? No admins : null} ))} diff --git a/src/features/people/people.contract.ts b/src/features/people/people.contract.ts index b2ecf8be..55d43982 100644 --- a/src/features/people/people.contract.ts +++ b/src/features/people/people.contract.ts @@ -387,7 +387,8 @@ export type ImportPreview = z.infer export const capoAreaSchema = z.object({ scope: z.string(), - groups: z.array(groupSchema.extend({ admins: z.number().int() })), + // `admins` is null while the backend does not know a group's Telegram admins. + groups: z.array(groupSchema.extend({ admins: z.number().int().nullable() })), admins: z.array(personRowSchema), requests: z.array(z.object({ id: z.string(), person: personRefSchema, group: groupSchema, requestedOn: z.string() })), }) diff --git a/tests/people-input.test.mjs b/tests/people-input.test.mjs index ee1b01e2..aa7cf866 100644 --- a/tests/people-input.test.mjs +++ b/tests/people-input.test.mjs @@ -5,6 +5,7 @@ import { validateCensusImport } from "../src/features/people/census-import.serve import { askToBeAddedInputSchema, campaignInputSchema, + capoAreaSchema, createMemberInputSchema, personInputSchema, resolveReviewInputSchema, @@ -48,3 +49,14 @@ void test("admission cannot claim a transfer upload that does not exist", () => false ) }) + +void test("the Capo area accepts groups whose Telegram admins the backend does not know", () => { + const area = (admins) => ({ + scope: "Informatica", + groups: [{ chatId: "-1001", title: "Analisi 1", admins }], + admins: [], + requests: [], + }) + assert.equal(capoAreaSchema.safeParse(area(null)).success, true) + assert.equal(capoAreaSchema.safeParse(area(2)).success, true) +})