Monorepo for Aesthetic.Computer aesthetic.computer
4
fork

Configure Feed

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

at main 66 lines 1.8 kB view raw
1#!/usr/bin/env node 2// Delete and recreate tape ATProto record with fixed slug 3 4import { deleteMediaRecord, MediaTypes } from './media-atproto.mjs'; 5import { connect } from './database.mjs'; 6 7async function main() { 8 const rkey = process.argv[2]; 9 const code = process.argv[3]; 10 11 if (!rkey || !code) { 12 console.error('Usage: node delete-and-recreate-tape.mjs <rkey> <code>'); 13 console.error('Example: node delete-and-recreate-tape.mjs 3m4hn7do6n22e ez2'); 14 process.exit(1); 15 } 16 17 const db = await connect(); 18 19 try { 20 // Get the tape to find the user 21 const tape = await db.db.collection('tapes').findOne({ code }); 22 if (!tape) { 23 console.error(`❌ Tape not found: ${code}`); 24 process.exit(1); 25 } 26 27 console.log(`📼 Tape: ${code}`); 28 console.log(` Slug: ${tape.slug}`); 29 console.log(` User: ${tape.user}`); 30 31 // Get user info 32 const users = db.db.collection('users'); 33 const user = await users.findOne({ _id: tape.user }); 34 35 if (!user || !user.atproto) { 36 console.error(`❌ User not found or no ATProto credentials`); 37 process.exit(1); 38 } 39 40 console.log(`\n🗑️ Deleting old ATProto record: ${rkey}`); 41 42 // Delete the old record 43 await deleteMediaRecord( 44 db, 45 MediaTypes.TAPE, 46 tape.user, 47 rkey 48 ); 49 50 console.log('✅ Old ATProto record deleted'); 51 52 // Now run sync-atproto to recreate it with the correct slug 53 console.log('\n🔄 Now run: node sync-atproto.mjs live --user ' + user._id + ' --tapes-only'); 54 55 } catch (error) { 56 console.error('❌ Error:', error.message); 57 throw error; 58 } finally { 59 await db.disconnect(); 60 } 61} 62 63main().catch(err => { 64 console.error('💥 Fatal error:', err); 65 process.exit(1); 66});