Encrypted, ephemeral, private memos on atproto

feat(consumer): delete item by record key

graham.systems 4da335fa 6a7981ea

verified
Changed files
+16 -3
packages
consumer
+16 -3
packages/consumer/mod.ts
··· 1 1 import { produceRequirements } from "@cistern/shared"; 2 2 import { generateKeys } from "@cistern/crypto"; 3 3 import { generateRandomName } from "@puregarlic/randimal"; 4 - import { is, parse } from "@atcute/lexicons"; 4 + import { is, parse, type RecordKey } from "@atcute/lexicons"; 5 5 import { JetstreamSubscription } from "@atcute/jetstream"; 6 6 import type { Did } from "@atcute/lexicons/syntax"; 7 7 import type { Client, CredentialManager } from "@atcute/client"; ··· 157 157 158 158 /** 159 159 * Deletes an item from the user's PDS by record key. 160 - * @todo Delete item from PDS 161 160 */ 162 - async deleteItem() {} 161 + async deleteItem(key: RecordKey) { 162 + const res = await this.rpc.post("com.atproto.repo.deleteRecord", { 163 + input: { 164 + collection: "app.cistern.lexicon.item", 165 + repo: this.did, 166 + rkey: key, 167 + }, 168 + }); 169 + 170 + if (!res.ok) { 171 + throw new Error( 172 + `failed to delete item ${key}: ${res.status} ${res.data.error}`, 173 + ); 174 + } 175 + } 163 176 }