From 69a22788654244b24085f04e557c568cff5f1769 Mon Sep 17 00:00:00 2001 From: MeaTLoTioN Date: Wed, 18 Jan 2023 00:21:00 +0000 Subject: [PATCH] add purge_history and purge_history_status --- purge_history | 30 ++++++++++++++++++++++++++++++ purge_history_status | 25 +++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100755 purge_history create mode 100755 purge_history_status diff --git a/purge_history b/purge_history new file mode 100755 index 0000000..793df9d --- /dev/null +++ b/purge_history @@ -0,0 +1,30 @@ +#!/bin/bash + +usage() { + echo "Not enough arguments supplied." + echo "Syntax: $(basename $0) {roomid} {date yyyy-mm-dd}" + echo +} + +if [[ $# -lt 2 ]]; then + usage + exit 1 +fi + +. $(dirname $0)/auth + +RID=$1 +DS=$2 +TS=$(date -d "${DS}" "+%s%3N") + +curl -s --insecure -X POST \ + -H "Authorization: Bearer $TOKEN" \ + -H "Content-Type: application/json" \ + -d '{ + "delete_local_events": true, + "purge_up_to_ts": '${TS}' + }' \ + "http://localhost:8008/_synapse/admin/v1/purge_history/${RID}" \ + # | sed 's/,/,\n /g; s/{/{\n /g; s/}/\n}/g' + +echo diff --git a/purge_history_status b/purge_history_status new file mode 100755 index 0000000..951bbca --- /dev/null +++ b/purge_history_status @@ -0,0 +1,25 @@ +#!/bin/bash + +usage() { + echo "Not enough arguments supplied." + echo "Syntax: $(basename $0) {statusid}" + echo +} + +if [[ $# -lt 1 ]]; then + usage + exit 1 +fi + +. $(dirname $0)/auth + +SID=$1 +echo "Using status_id: ${SID}" + +curl -s -X GET \ + -H "Authorization: Bearer $TOKEN" \ + -H "Content-Type: application/json" \ + "http://localhost:8008/_synapse/admin/v1/purge_history_status/${SID}" \ + # | sed 's/,/,\n /g; s/{/{\n /g; s/}/\n}/g' + +echo