diff --git a/pleroma-cli.sh b/pleroma-cli.sh index 208bb4b..e8e8b4d 100755 --- a/pleroma-cli.sh +++ b/pleroma-cli.sh @@ -439,8 +439,8 @@ statuses_render() if [ "$reversed_statuses" = 'true' ]; then ids_massive=$(echo "$ids_massive" | tr ' ' '\n' | tac | tr '\n' ' ') fi + export instance echo "$jsonmassive" | ./utils/statuses2files.sh - ./utils/extract_text_content.sh for i in $ids_massive; do status=$(echo "$jsonmassive" | jj "#[id=$i]") reblog=$(echo "$status" | jj reblog.id) diff --git a/utils/extract_text_content.sh b/utils/extract_text_content.sh deleted file mode 100755 index 9bae7c3..0000000 --- a/utils/extract_text_content.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -# Extract some content from statuses - -for i in "$main_basedir"/statuses/*/*.json; do - content=$(jj -i $i content | "$main_basedir"/utils/html_to_txt_render) - status_id=$(jj -i $i 'id') - status_date=$(jj -i $i 'created_at') - touch -d "$status_date" "$main_basedir"/statuses/$status_id - jj -i $i content | "$main_basedir"/utils/html_to_txt_render > "$main_basedir"/statuses/$status_id/content - chmod 600 "$main_basedir"/statuses/$status_id/content -done diff --git a/utils/statuses2files.sh b/utils/statuses2files.sh index 01174d6..54e2901 100755 --- a/utils/statuses2files.sh +++ b/utils/statuses2files.sh @@ -3,12 +3,17 @@ # convert statuses as files and dirs json="$(cat)" ids=$(echo "$json" | jj -l '#.id' | sed 's/"//g') + +if [ ! -d "$main_basedir/statuses/$instance" ]; then + mkdir -p "$main_basedir/statuses/$instance" +fi + for i in $ids; do - if [ -f "$main_basedir"/statuses/$i.json ]; then + if [ -f "$main_basedir"/statuses/$instance/$i.json ]; then continue fi - mkdir -m 711 -p "$main_basedir"/statuses/$i - echo "$json" | jj -p "#[id=$i]" > "$main_basedir"/statuses/$i/$i.json - chmod 600 "$main_basedir"/statuses/$i/$i.json + mkdir -m 711 -p "$main_basedir"/statuses/$instance/$i + echo "$json" | jj -p "#[id=$i]" > "$main_basedir"/statuses/$instance/$i/$i.json + chmod 600 "$main_basedir"/statuses/$instance/$i/$i.json done -"$main_basedir"/utils/extract_text_content.sh +"$main_basedir"/utils/extract_fields_statuses.sh