import { readString, store } from './shared.ts' import { deleteWatch } from './watch-store.ts' /** * Stop watching one thread. Stored messages and the thread webhook stay. * @example * import unwatch from 'kody:@kentcdodds/exchange-threads/unwatch' * const result = await unwatch({ threadId: 'th_1' }) * // => { ok: true, threadId: 'th_1', removed: true } */ export default async function unwatch(params: { threadId?: string } = {}) { const threadId = readString(params.threadId) if (!threadId) return { ok: false, error: 'threadId is required.' } const bucket = await store() return { ok: true, threadId, removed: await deleteWatch(bucket, threadId) } }