your personal website on atproto - mirror blento.app
26
fork

Configure Feed

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

Merge pull request #298 from tylersayshi/fix-type-validation

fix: add `$type` field to new records

authored by

Florian and committed by
GitHub
f75e2fce 41a4caa3

+15 -2
+15 -2
src/lib/atproto/server/repo.remote.ts
··· 27 27 const { locals } = getRequestEvent(); 28 28 if (!locals.client || !locals.did) error(401, 'Not authenticated'); 29 29 30 + const record = 31 + input.record.$type === input.collection 32 + ? input.record 33 + : { ...input.record, $type: input.collection }; 34 + 30 35 const response = await locals.client.post('com.atproto.repo.putRecord', { 31 36 input: { 32 37 collection: input.collection as `${string}.${string}.${string}`, 33 38 repo: locals.did, 34 39 rkey: input.rkey || 'self', 35 - record: input.record 40 + record 36 41 } 37 42 }); 38 43 39 - if (!response.ok) error(500, 'Failed to put record'); 44 + if (!response.ok) { 45 + console.error('putRecord failed', { 46 + collection: input.collection, 47 + rkey: input.rkey || 'self', 48 + status: response.status, 49 + data: response.data 50 + }); 51 + error(500, 'Failed to put record'); 52 + } 40 53 41 54 // Immediately index in contrail 42 55 const { platform } = getRequestEvent();