#!/usr/bin/env bash function atfile.lock() { key="$1" locked=$2 unset error # shellcheck disable=SC2154 atfile.say.debug "Getting record...\n↳ NSID: $_nsid_upload\n↳ Repo: $_username\n↳ Key: $key" upload_record="$(com.atproto.repo.getRecord "$_username" "$_nsid_upload" "$key")" error="$(atfile.util.get_xrpc_error $? "$upload_record")" if [[ -z "$error" ]]; then if [[ $locked == 1 ]]; then locked=true else locked=false fi lock_record="$(blue.zio.atfile.lock $locked)" # shellcheck disable=SC2154 atfile.say.debug "Updating record...\n↳ NSID: $_nsid_lock\n↳ Repo: $_username\n↳ Key: $key" record="$(com.atproto.repo.putRecord "$_username" "$_nsid_lock" "$key" "$lock_record")" error="$(atfile.util.get_xrpc_error $? "$record")" fi if [[ -z "$error" ]]; then # shellcheck disable=SC2154 if [[ $_output_json == 1 ]]; then echo -e "{ \"locked\": $locked }" | jq else if [[ $locked == true ]]; then echo "Locked: $key" else echo "Unlocked: $key" fi fi else if [[ $locked == true ]]; then atfile.die.xrpc_error "Unable to lock '$key'" "$error" else atfile.die.xrpc_error "Unable to unlock '$key'" "$error" fi fi }