test update json

This commit is contained in:
2025-06-15 15:31:53 +09:00
parent 095f6ec386
commit 8dac463345
19 changed files with 959 additions and 576 deletions

View File

@ -1,11 +1,11 @@
#!/bin/zsh
#[collection] [pds] [did] [token]
set -e
cb=ai.syui.log
cl=( $cb.chat $cb.chat.comment $cb.chat.lang )
f=~/.config/syui/ai/bot/token.json
default_collection="ai.syui.log.chat"
default_collection="ai.syui.log.chat.comment"
default_pds="bsky.social"
default_did=`cat $f|jq -r .did`
default_token=`cat $f|jq -r .accessJwt`
@ -16,27 +16,15 @@ collection=${1:-$default_collection}
pds=${2:-$default_pds}
did=${3:-$default_did}
token=${4:-$default_token}
req=com.atproto.repo.deleteRecord
url=https://$pds/xrpc/$req
delete_record() {
local rkey=$1
local req="com.atproto.repo.deleteRecord"
local url="https://$pds/xrpc/$req"
local json="{\"collection\":\"$collection\", \"rkey\":\"$rkey\", \"repo\":\"$did\"}"
curl -sL -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $token" \
-d "$json" \
"$url"
if [ $? -eq 0 ]; then
echo " ✓ Deleted: $rkey"
else
echo " ✗ Failed: $rkey"
fi
}
rkeys=($(curl -sL "https://$default_pds/xrpc/com.atproto.repo.listRecords?repo=$did&collection=$collection&limit=100"|jq -r ".records[]?.uri"|cut -d '/' -f 5))
for rkey in "${rkeys[@]}"; do
echo $rkey
delete_record $rkey
for i in $cl; do
echo $i
rkeys=($(curl -sL "https://$default_pds/xrpc/com.atproto.repo.listRecords?repo=$did&collection=$i&limit=100"|jq -r ".records[]?.uri"|cut -d '/' -f 5))
for rkey in "${rkeys[@]}"; do
echo $rkey
json="{\"collection\":\"$i\", \"rkey\":\"$rkey\", \"repo\":\"$did\"}"
curl -sL -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $token" -d "$json" $url
done
done