ai/at
1
0
This commit is contained in:
2025-12-06 16:07:16 +09:00
parent 9a99ba9d89
commit 948551c185
5 changed files with 321 additions and 20 deletions

View File

@@ -1,7 +1,9 @@
#!/bin/zsh
function at-repos-env() {
APP_PASSWORD=xxx
host=syu.is
handle=ai.syui.ai
did=did:plc:6qyecktefllvenje24fcxnie
repos=(
"https://github.com/did-method-plc/did-method-plc"
@@ -20,6 +22,7 @@ function at-repos-env() {
"bgs"
"ozone"
"social-app"
"feed"
)
handles=(
"syui.syui.ai"
@@ -51,6 +54,7 @@ PATCH_FILES=(
"140-social-app-yarn-network-timeout.patch"
"130-atproto-ozone-enable-daemon-v2.patch"
"190-bgs-disable-ratelimit.patch"
"200-feed-generator-custom.patch"
)
function at-repos-clone() {
@@ -78,7 +82,7 @@ function at-repos-pull() {
echo $repo
if [ -d $d/repos/${repo##*/} ];then
cd $d/repos/${repo##*/}
git stash
git stash -u
if ! git pull;then
rm -rf $d/repos/${repo##*/}
at-repos-clone
@@ -249,6 +253,8 @@ function at-repos-patch-apply-all() {
repo="atproto"
elif [[ $filename == *"indigo"* || $filename == *"bgs"* ]]; then
repo="indigo"
elif [[ $filename == *"feed"* ]]; then
repo="feed-generator"
fi
patch-apply "$title" "$repo" "$filename"
@@ -337,7 +343,7 @@ function at-repos-push-docker() {
service=${services[$i]}
docker tag at-${service}:latest localhost:${dport}/${service}:latest
docker push localhost:${dport}/${service}:latest
if [ "$service" == "ozone" ]];then
if [ "$service" == "ozone" ];then
docker tag at-${service}-web:latest localhost:${dport}/${service}-web:latest
docker push localhost:${dport}/${service}-web:latest
fi
@@ -406,6 +412,66 @@ function at-repos-reset-bgs-db() {
done
}
function at-repos-feed-generator-start-push() {
cd $d/repos/feed-generator
yarn install
FEEDGEN_HANDLE=${handle}
FEEDGEN_PASSWORD=${APP_PASSWORD}
FEEDGEN_RECORD_NAME=app
FEEDGEN_AVATAR=$d/repos/atproto/packages/dev-env/assets/at.png
npx tsx scripts/publish.ts
}
function at-repos-feed-generator-update() {
resp=$(curl -sL -X POST -H "Content-Type: application/json" -d "{\"identifier\":\"$handle\",\"password\":\"${APP_PASSWORD}\"}" https://${host}/xrpc/com.atproto.server.createSession)
token=$(echo $resp | jq -r .accessJwt)
if [ -z "$token" ] || [ "$token" == "null" ]; then
echo "Login failed: $resp"
exit 1
fi
avatar_json="{\"\$type\":\"blob\",\"ref\":{\"\$link\":\"${img_id}\"},\"mimeType\":\"image/jpeg\",\"size\":375259}"
# 3. Delete cmd record
#curl -sL -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $token" \
# -d "{\"repo\":\"$handle\",\"collection\":\"app.bsky.feed.generator\",\"rkey\":\"cmd\"}" \
# https://${host}/xrpc/com.atproto.repo.deleteRecord
# 4. Put app record
echo "Creating app record..."
now=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
# Create JSON payload
# Note: feeding avatar_json directly into jq
payload=$(jq -n \
--arg repo "$handle" \
--arg collection "app.bsky.feed.generator" \
--arg rkey "app" \
--arg did "did:web:feed.${host}" \
--arg type "app.bsky.feed.generator" \
--arg created "$now" \
--arg display "App Feed" \
--arg desc "Automated App Feed" \
--argjson avatar "$avatar_json" \
'{
repo: $repo,
collection: $collection,
rkey: $rkey,
record: {
did: $did,
"$type": $type,
createdAt: $created,
displayName: $display,
description: $desc,
avatar: $avatar
}
}')
curl -sL -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $token" \
-d @- \
https://${host}/xrpc/com.atproto.repo.putRecord
}
at-repos-env
case "$1" in
pull)
@@ -436,11 +502,15 @@ case "$1" in
cd $d;docker compose down
exit
;;
feed-push)
at-repos-feed-generator-start-push
exit
;;
esac
case "`cat /etc/hostname`" in
at)
if [ "$1" = "reset-bgs-db" ];then
if [ "$1" = "bgs-reset" ];then
at-repos-reset-bgs-db
exit
fi