frontend client for gemstone. decentralised workplace app
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: actually submit the cid

serenity aeaed26f fa9a23e1

+43 -1
+43 -1
src/lib/utils/gmstn.ts
··· 1 - import type { Did } from "@/lib/types/atproto"; 1 + import type { ComAtprotoRepoStrongRef, Did } from "@/lib/types/atproto"; 2 2 import type { SystemsGmstnDevelopmentShard } from "@/lib/types/lexicon/systems.gmstn.development.shard"; 3 3 import { getEndpointFromDid } from "@/lib/utils/atproto"; 4 4 import { isDomain } from "@/lib/utils/domains"; 5 5 import type { Result } from "@/lib/utils/result"; 6 6 import type { Agent } from "@atproto/api"; 7 + import * as TID from "@atcute/tid"; 8 + import type { SystemsGmstnDevelopmentLattice } from "@/lib/types/lexicon/systems.gmstn.development.lattice"; 9 + import type { SystemsGmstnDevelopmentChannelInvite } from "@/lib/types/lexicon/systems.gmstn.development.channel.invite"; 7 10 8 11 export const getLatticeEndpointFromDid = async (did: Did) => { 9 12 return await getEndpointFromDid(did, "GemstoneLattice"); ··· 100 103 101 104 return { ok: true }; 102 105 }; 106 + 107 + export const inviteNewUser = async ({ 108 + did, 109 + channel, 110 + agent, 111 + }: { 112 + did: Did; 113 + channel: ComAtprotoRepoStrongRef; 114 + agent: Agent; 115 + }): Promise<Result<undefined, string>> => { 116 + const now = new Date(); 117 + const rkey = TID.create(now.getTime(), Math.random()); 118 + 119 + const record: Omit<SystemsGmstnDevelopmentChannelInvite, "$type"> = { 120 + // @ts-expect-error we want to explicitly use the ISO string variant 121 + createdAt: now.toISOString(), 122 + recipient: did, 123 + channel, 124 + }; 125 + 126 + const { success } = await agent.call( 127 + "com.atproto.repo.createRecord", 128 + {}, 129 + { 130 + repo: agent.did, 131 + collection: "systems.gmstn.development.channel.invite", 132 + rkey, 133 + record, 134 + }, 135 + ); 136 + 137 + if (!success) 138 + return { 139 + ok: false, 140 + error: "Attempted to create lattice record failed. Check the domain inputs.", 141 + }; 142 + 143 + return { ok: true }; 144 + };