diff options
author | Paul Frazee <pfrazee@gmail.com> | 2022-11-10 16:30:14 -0600 |
---|---|---|
committer | Paul Frazee <pfrazee@gmail.com> | 2022-11-10 16:30:14 -0600 |
commit | d3707f30e30bb717e95b27cc83a1121815b475b5 (patch) | |
tree | 57fcb61e9e937949526713a778e171a6676c9acf /src/state/lib/api.ts | |
parent | ecf56729b0da535f1d0b794268c7856836e76bd6 (diff) | |
download | voidsky-d3707f30e30bb717e95b27cc83a1121815b475b5.tar.zst |
Implement scene invitation and membership controls
Diffstat (limited to 'src/state/lib/api.ts')
-rw-r--r-- | src/state/lib/api.ts | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/state/lib/api.ts b/src/state/lib/api.ts index efaac5c7b..701475532 100644 --- a/src/state/lib/api.ts +++ b/src/state/lib/api.ts @@ -8,6 +8,7 @@ import {sessionClient as AtpApi} from '../../third-party/api' import * as Profile from '../../third-party/api/src/client/types/app/bsky/actor/profile' import * as Post from '../../third-party/api/src/client/types/app/bsky/feed/post' import {AtUri} from '../../third-party/uri' +import {APP_BSKY_GRAPH} from '../../third-party/api' import {RootStoreModel} from '../models/root-store' import {extractEntities} from '../../view/lib/strings' @@ -156,6 +157,54 @@ export async function updateProfile( } } +export async function inviteToScene( + store: RootStoreModel, + sceneDid: string, + subjectDid: string, + subjectDeclarationCid: string, +): Promise<string> { + const res = await store.api.app.bsky.graph.assertion.create( + { + did: sceneDid, + }, + { + subject: { + did: subjectDid, + declarationCid: subjectDeclarationCid, + }, + assertion: APP_BSKY_GRAPH.AssertMember, + createdAt: new Date().toISOString(), + }, + ) + return res.uri +} + +interface Confirmation { + originator: { + did: string + declarationCid: string + } + assertion: { + uri: string + cid: string + } +} +export async function acceptSceneInvite( + store: RootStoreModel, + details: Confirmation, +): Promise<string> { + const res = await store.api.app.bsky.graph.confirmation.create( + { + did: store.me.did || '', + }, + { + ...details, + createdAt: new Date().toISOString(), + }, + ) + return res.uri +} + interface FetchHandlerResponse { status: number headers: Record<string, string> |