1
0

add mastodon

This commit is contained in:
2023-07-10 12:43:09 +09:00
parent c3bd20d90b
commit dc01c83e9d
21 changed files with 2481 additions and 1817 deletions

View File

@ -1,6 +1,5 @@
#!/bin/zsh
echo username card cp
read
host=https://api.syui.ai
pass=`cat ~/.config/atr/api_card.json|jq -r .password`
if [ -z "$1" ];then
@ -18,5 +17,6 @@ read
id=`curl -sL "$host/users?itemsPerPage=2000"|jq ".[]|select(.username == \"$1\")"|jq -r .id`
card=$2
cp=$3
s="normal"
curl -X POST -H "Content-Type: application/json" -d "{\"owner\":$id,\"card\":$card,\"status\":\"$s\",\"cp\":$cp,\"password\":\"$pass\"}" -sL $host/cards
s=super
skill=normal
curl -X POST -H "Content-Type: application/json" -d "{\"owner\":$id,\"card\":$card,\"status\":\"$s\",\"cp\":$cp,\"password\":\"$pass\",\"skill\":\"$skill\"}" -sL $host/cards

View File

@ -6,8 +6,8 @@ case $OSTYPE in
;;
esac
username=syui
id=1
username=ai
id=2
host=https://api.syui.ai
token=`cat ~/.config/atr/api_card.json|jq -r .token`
@ -17,10 +17,24 @@ data=`curl -sL "$host_users"|jq .`
nd=`date +"%Y%m%d"`
nd=20230101
title=card_patch
echo $title
card_id=1
curl -X PATCH -H "Content-Type: application/json" -d "{\"cp\":1,\"token\":\"$token\"}" $host/cards/$card_id
#title=card_patch
#echo $title
#card_id=1
#curl -X PATCH -H "Content-Type: application/json" -d "{\"cp\":1,\"token\":\"$token\"}" $host/cards/$card_id
#read
#
## card pass
echo "\ntest get card (no password)"
curl -X POST -H "Content-Type: application/json" -d "{\"owner\":$id}" $host/cards
echo "\ntest select card (no password)"
curl -X POST -H "Content-Type: application/json" -d "{\"owner\":$id,\"card\":0,\"status\":\"normal\",\"cp\":1}" $host/cards
## token
echo "\ntest token (no token)"
curl -X PATCH -H "Content-Type: application/json" -d "{\"next\":\"1\"}" -s $host/users/$id
echo "\ntest token (yes token)"
curl -X PATCH -H "Content-Type: application/json" -d "{\"next\":\"$nd\",\"token\":\"$token\"}" -s $host/users/$id
read
## users
@ -35,11 +49,7 @@ read
curl -sL "$host/cards?itemsPerPage=2550"|jq .
read
## token
echo "\ntest token (no token)"
curl -X PATCH -H "Content-Type: application/json" -d "{\"next\":\"$nd\"}" -s $host/users/$id
echo "\ntest token (yes token)"
curl -X PATCH -H "Content-Type: application/json" -d "{\"next\":\"$nd\",\"token\":\"$token\"}" -s $host/users/$id
read
## delete

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -493,6 +493,13 @@ func (h *OgentHandler) CreateUser(ctx context.Context, req *CreateUserReq) (Crea
if v, ok := req.Did.Get(); ok {
b.SetDid(v)
}
if v, ok := req.Bsky.Get(); ok {
b.SetBsky(v)
}
if v, ok := req.Mastodon.Get(); ok {
b.SetMastodon(v)
}
if v, ok := req.Delete.Get(); ok {
b.SetDelete(v)
}
@ -629,6 +636,12 @@ func (h *OgentHandler) UpdateUser(ctx context.Context, req *UpdateUserReq, param
if v, ok := req.Did.Get(); ok {
b.SetDid(v)
}
if v, ok := req.Bsky.Get(); ok {
b.SetBsky(v)
}
if v, ok := req.Mastodon.Get(); ok {
b.SetMastodon(v)
}
if v, ok := req.Delete.Get(); ok {
b.SetDelete(v)
}

24
tmp/t.zsh Normal file
View File

@ -0,0 +1,24 @@
#!/bin/zsh
host=https://api.syui.ai
uid=`curl -sL "$host/users?itemsPerPage=2000"|jq ".[]|select(.username == \"$1\")"|jq -r .id`
did=`curl -sL "$host/users?itemsPerPage=2000"|jq ".[]|select(.username == \"$1\")"|jq -r .did`
pass=`cat ~/.config/atr/api_card.json|jq -r .password`
card=36
cp=`echo $(($RANDOM % 1000 + 400))`
s=$(($RANDOM % 7))
if [ $s -eq 1 ];then
s=super
skill=post
plus=$(($RANDOM % 1000 + 300))
cp=$((cp + plus))
else
s=normal
skill=ten
fi
tmp=`curl -X POST -H "Content-Type: application/json" -d "{\"owner\":$uid,\"card\":$card,\"status\":\"$s\",\"cp\":$cp,\"password\":\"$pass\",\"skill\":\"$skill\"}" -sL $host/cards`
card=`echo $tmp|jq -r .card`
cp=`echo $tmp|jq -r .cp`
body="[card]\nid : $card\ncp : $cp"
atr @ $did -p "`echo $body`"