Working tree is now the canonical repo. Off-chain play-money + trustless on-chain (FPMM AMM + CLOB via UMA settlement), AI market factory, creator/social/distribution, mobile shell + push, one-command demo + deploy-kit. Secrets excluded (see ENV-AND-KEYS.md). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
48 lines
1.4 KiB
TypeScript
48 lines
1.4 KiB
TypeScript
// Fill all groups without privacyStatus to 'public'
|
|
|
|
import * as admin from 'firebase-admin'
|
|
import { initAdmin } from 'shared/init-admin'
|
|
import { log, writeAsync } from 'shared/utils'
|
|
|
|
initAdmin()
|
|
const db = admin.firestore()
|
|
|
|
if (require.main === module) {
|
|
async function addVisibilityToPostsWithoutVisibilityField(): Promise<void> {
|
|
try {
|
|
// Get all posts
|
|
const postSnapshot = await db.collection('posts').get()
|
|
|
|
if (postSnapshot.empty) {
|
|
console.log('No posts found.')
|
|
return
|
|
}
|
|
|
|
const updatePostPromises: Promise<any>[] = []
|
|
|
|
// Iterate over posts and add 'visibility': 'public' if the 'visibility' field is missing
|
|
postSnapshot.forEach((postDoc) => {
|
|
const postData = postDoc.data()
|
|
|
|
if (!postData.hasOwnProperty('visibility')) {
|
|
const postId = postDoc.id
|
|
const postRef = db.collection('posts').doc(postId)
|
|
console.log(postId)
|
|
|
|
// Add 'visibility': 'public' to the post
|
|
updatePostPromises.push(postRef.update({ visibility: 'public' }))
|
|
}
|
|
})
|
|
|
|
// Wait for all post updates to complete
|
|
await Promise.all(updatePostPromises)
|
|
|
|
console.log('Added visibility field to all posts without visibility.')
|
|
} catch (error) {
|
|
console.error('Error adding visibility field to posts:', error)
|
|
}
|
|
}
|
|
|
|
addVisibilityToPostsWithoutVisibilityField()
|
|
}
|