Group by timelines; auto update home, local, direct timelines; Create status

This commit is contained in:
localhost_frssoft 2022-08-06 16:00:46 +03:00
parent 49ebf083e1
commit 02fb276232
5 changed files with 49 additions and 22 deletions

View file

@ -1,6 +1,8 @@
#!/bin/sh #!/bin/sh
if [ -z "$instance" ]; then
instance=$(jj -i config.json instance) instance=$(jj -i config.json instance)
fi
alias default_auth_browser=links alias default_auth_browser=links
export main_basedir=$(dirname $0) export main_basedir=$(dirname $0)
@ -983,10 +985,14 @@ statuses_auto_update()
{ {
while true; do while true; do
echo "Updating statuses..." echo "Updating statuses..."
timeline='home' for i in home local direct; do
export instance echo "checking timeline $i"
timeline="$i"
export instance timeline
timeline_api | ./utils/statuses2files.sh timeline_api | ./utils/statuses2files.sh
echo "Waiting..." sleep 3
done
echo "Sleeping..."
sleep 30 sleep 30
done done
} }
@ -1028,6 +1034,23 @@ if [ "$daemon_mode" = 'yes' ]; then
;; ;;
esac esac
fi fi
write_status_action=$(/bin/ls $main_basedir/all_statuses/$instance/create 2>/dev/null)
if [ -n "$write_status_action" ]; then
dir_write_status=$(dirname "$write_status_action")
if [ -d "$dir_status/attachments" ]; then
attach_id=''
echo "Uploading attachments..."
for attach in "$dir_write_status"/attachments/*; do
attach_id=$(upload_api_media "@$attach" | jj id)
attach_id="${attach_id},"
echo $attach_id
done
mediaattach=$(echo $attach_id | sed 's/,$//g')
echo $mediaattach
fi
write_api_status $dir_write_status/message
rm $write_status_action
fi
done done
done done
fi fi

View file

@ -31,4 +31,4 @@ for i in $ids; do
done done
export ids export ids
echo "$json" | "$main_basedir"/utils/statuses2files_acct.sh echo "$json" | "$main_basedir"/utils/statuses2files_group.sh

View file

@ -6,6 +6,7 @@ ids=$(echo "$json" | jj -l '#.id' | sed 's/"//g')
mkdir -p "$main_basedir/all_statuses/$instance" mkdir -p "$main_basedir/all_statuses/$instance"
mkdir -p "$main_basedir/statuses/$instance" mkdir -p "$main_basedir/statuses/$instance"
mkdir -p "$main_basedir/timelines/$instance/$timeline"
for i in $ids; do for i in $ids; do
if [ -f "$main_basedir"/all_statuses/$instance/$i/$i.json ]; then if [ -f "$main_basedir"/all_statuses/$instance/$i/$i.json ]; then

View file

@ -1,16 +0,0 @@
#!/bin/sh
# Move statuses to acct dirs
json=$(cat)
for i in $ids; do
status_id=$i
acct=$(echo "$json" | jj "#[id=$i].account.acct")
mkdir -m 711 -p "$main_basedir"/statuses/$instance/$acct
if [ -n "$status_id" ]; then
ln -s -r "$main_basedir"/all_statuses/$instance/$status_id "$main_basedir"/statuses/$instance/$acct/$status_id
touch --reference "$main_basedir"/all_statuses/$instance/$status_id "$main_basedir"/statuses/$instance/$acct/$status_id
fi
done

19
utils/statuses2files_group.sh Executable file
View file

@ -0,0 +1,19 @@
#!/bin/sh
# Group statuses by acct and timelines dirs
json=$(cat)
for i in $ids; do
status_id=$i
acct=$(echo "$json" | jj "#[id=$i].account.acct")
mkdir -m 711 -p "$main_basedir"/statuses/$instance/$acct
if [ -n "$status_id" ]; then
ln -s -r "$main_basedir"/all_statuses/$instance/$status_id "$main_basedir"/statuses/$instance/$acct/$status_id
touch --reference "$main_basedir"/all_statuses/$instance/$status_id "$main_basedir"/statuses/$instance/$acct/$status_id
ln -s -r "$main_basedir"/all_statuses/$instance/$status_id "$main_basedir"/timelines/$instance/$timeline/$status_id
touch --reference "$main_basedir"/all_statuses/$instance/$status_id "$main_basedir"/timelines/$instance/$timeline/$status_id
fi
done