tangled
alpha
login
or
join now
leaflet.pub
/
leaflet
289
fork
atom
a tool for shared writing and social publishing
289
fork
atom
overview
issues
27
pulls
pipelines
add identity_id col to custom_domains
awarm.space
8 months ago
b3d90897
244504f4
+21
-10
2 changed files
expand all
collapse all
unified
split
actions
domains
addDomain.ts
supabase
migrations
20250704144448_add_identity_id_rel_to_custom_domains.sql
+16
-10
actions/domains/addDomain.ts
···
19
20
export async function addDomain(domain: string) {
21
let identity = await getIdentityData();
22
-
if (!identity || !identity.email) return {};
23
if (
24
domain.includes("leaflet.pub") &&
25
-
![
26
-
"celine@hyperlink.academy",
27
-
"brendan@hyperlink.academy",
28
-
"jared@hyperlink.academy",
29
-
"brendan.schlagel@gmail.com",
30
-
].includes(identity.email)
0
31
)
32
return {};
33
-
return await createDomain(domain, identity.email);
34
}
35
36
export async function addPublicationDomain(
···
46
.single();
47
48
if (publication?.identity_did !== identity.atp_did) return {};
49
-
let { error } = await createDomain(domain, null);
50
if (error) return { error };
51
await supabase.from("publication_domains").insert({
52
publication: publication_uri,
···
56
return {};
57
}
58
59
-
async function createDomain(domain: string, email: string | null) {
0
0
0
0
60
try {
61
await vercel.projects.addProjectDomain({
62
idOrName: "prj_9jX4tmYCISnm176frFxk07fF74kG",
···
87
domain,
88
identity: email,
89
confirmed: false,
0
90
});
91
return {};
92
}
···
19
20
export async function addDomain(domain: string) {
21
let identity = await getIdentityData();
22
+
if (!identity || (!identity.email && !identity.atp_did)) return {};
23
if (
24
domain.includes("leaflet.pub") &&
25
+
(!identity.email ||
26
+
![
27
+
"celine@hyperlink.academy",
28
+
"brendan@hyperlink.academy",
29
+
"jared@hyperlink.academy",
30
+
"brendan.schlagel@gmail.com",
31
+
].includes(identity.email))
32
)
33
return {};
34
+
return await createDomain(domain, identity.email, identity.id);
35
}
36
37
export async function addPublicationDomain(
···
47
.single();
48
49
if (publication?.identity_did !== identity.atp_did) return {};
50
+
let { error } = await createDomain(domain, null, identity.id);
51
if (error) return { error };
52
await supabase.from("publication_domains").insert({
53
publication: publication_uri,
···
57
return {};
58
}
59
60
+
async function createDomain(
61
+
domain: string,
62
+
email: string | null,
63
+
identity_id: string,
64
+
) {
65
try {
66
await vercel.projects.addProjectDomain({
67
idOrName: "prj_9jX4tmYCISnm176frFxk07fF74kG",
···
92
domain,
93
identity: email,
94
confirmed: false,
95
+
identity_id,
96
});
97
return {};
98
}
+5
supabase/migrations/20250704144448_add_identity_id_rel_to_custom_domains.sql
···
0
0
0
0
0
···
1
+
alter table "public"."custom_domains" add column "identity_id" uuid;
2
+
3
+
alter table "public"."custom_domains" add constraint "custom_domains_identity_id_fkey" FOREIGN KEY (identity_id) REFERENCES identities(id) ON DELETE CASCADE not valid;
4
+
5
+
alter table "public"."custom_domains" validate constraint "custom_domains_identity_id_fkey";