Skip to content

Commit 7fa8c2f

Browse files
feat(domains): remove free domains from the list (#541)
1 parent 7f200ed commit 7fa8c2f

File tree

3 files changed

+40
-1
lines changed

3 files changed

+40
-1
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//
2+
3+
import { schema, type MonComptePro_PgDatabase } from "..";
4+
5+
//
6+
7+
export async function create_zombie_organization(pg: MonComptePro_PgDatabase) {
8+
const [{ id: organization_id }] = await pg
9+
.insert(schema.organizations)
10+
.values({
11+
cached_libelle: "🧟‍♂️ libelle",
12+
siret: "🧟‍♂️ siret",
13+
cached_est_active: false,
14+
})
15+
.returning({ id: schema.organizations.id });
16+
17+
await pg.insert(schema.email_domains).values({
18+
domain: "zombie.corn",
19+
organization_id,
20+
verification_type: null,
21+
});
22+
23+
return organization_id;
24+
}

packages/~/organizations/repository/src/get_unverified_domains.test.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
create_adora_pony_user,
88
create_unicorn_organization,
99
} from "@~/moncomptepro.database/seed/unicorn";
10+
import { create_zombie_organization } from "@~/moncomptepro.database/seed/zombie";
1011
import { empty_database, migrate, pg } from "@~/moncomptepro.database/testing";
1112
import type { MCP_Moderation } from "@~/moncomptepro.lib/moncomptepro.d";
1213
import { Verification_Type_Schema } from "@~/moncomptepro.lib/verification_type";
@@ -215,7 +216,7 @@ test.each(
215216
},
216217
);
217218

218-
test("returns no organizations", async () => {
219+
test("returns no organizations verified by Trackdechets", async () => {
219220
await create_unicorn_organization(pg);
220221
const troll_organization_id = await create_troll_organization(pg);
221222
await pg.insert(schema.email_domains).values({
@@ -226,3 +227,9 @@ test("returns no organizations", async () => {
226227
const result = await get_unverified_domains(pg, {});
227228
expect(result).toEqual({ count: 0, domains: [] });
228229
});
230+
231+
test("returns no unactive organizations", async () => {
232+
await create_zombie_organization(pg);
233+
const result = await get_unverified_domains(pg, {});
234+
expect(result).toEqual({ count: 0, domains: [] });
235+
});

packages/~/organizations/repository/src/get_unverified_domains.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ const where_unipersonnelle = and(
3535
),
3636
)!;
3737

38+
const where_active_organization = or(
39+
isNull(schema.organizations.cached_est_active),
40+
eq(schema.organizations.cached_est_active, true),
41+
);
42+
43+
//
44+
3845
export async function get_unverified_domains(
3946
pg: MonComptePro_PgDatabase,
4047
{
@@ -53,6 +60,7 @@ export async function get_unverified_domains(
5360

5461
const where = and(
5562
search_where,
63+
where_active_organization,
5664
where_authorized_email_domains,
5765
not(where_unipersonnelle),
5866
);

0 commit comments

Comments
 (0)