Compare commits

..

No commits in common. "7df5311859216128e3aa3d5720d0945a85bbca0f" and "dad01767b54da9d9935cae94ad2761496512f341" have entirely different histories.

3 changed files with 1 additions and 70 deletions

View File

@ -1,36 +0,0 @@
{ config, lib, pkgs, ... }:
let
path = with pkgs; [ jq postgresql_15 matrix-synapse-tools.synadm ];
environment = {
HOME = "/home/nathan";
XDG_CONFIG_DIRS =
"/etc/xdg:/home/nathan/.nix-profile/etc/xdg:/etc/profiles/per-user/nathan/etc/xdg:/nix/var/nix/profiles/default/etc/xdg:/run/current-system/sw/etc/xdg";
XDG_CONFIG_HOME = "/home/nathan/.config";
};
synapse-script = { name, script, schedule }: {
systemd.services."synapse-script-${name}" = {
inherit environment;
inherit path;
inherit script;
serviceConfig = {
Type = "oneshot";
User = "nathan";
Group = "users";
};
};
systemd.timers."synapse-script-${name}" = {
wantedBy = [ "timers.target" ];
partOf = [ "synapse-script-${name}.service" ];
timerConfig = {
OnCalendar = schedule;
Unit = "synapse-script-${name}.service";
};
};
};
in lib.mkMerge [
(synapse-script {
name = "clean-vacant-rooms";
schedule = "23:00";
script = builtins.readFile ../../scripts/matrix/clean-old-rooms.sh;
})
]

View File

@ -1,7 +1,7 @@
{ config, lib, pkgs, inputs, ... }: { config, lib, pkgs, inputs, ... }:
{ {
imports = [ ./matrix.nix ./automation.nix ]; imports = [ ./matrix.nix ];
# Sops setup for this machine # Sops setup for this machine
sops.secrets = { sops.secrets = {
"borg-ssh-key" = { "borg-ssh-key" = {

View File

@ -1,33 +0,0 @@
#!/usr/bin/env bash
set -eou pipefail
# Get the list of rooms with no local users
empty_rooms() {
psql -d synapse -c "SELECT room_id FROM room_stats_current WHERE local_users_in_room = 0 \
ORDER BY current_state_events DESC LIMIT 1;" -t --csv
}
# Delete a room and purge its history
delete_room() {
details=$(synadm room details $1)
name=$(echo $details | jq -r '.name')
canonical_alias=$(echo $details | jq -r '.canonical_aliacanonical_alias')
topic=$(echo $details | jq -r '.topic')
joined_local_members=$(echo $details | jq -r '.joined_local_members')
state_events=$(echo $details | jq -r '.state_events')
echo "Deleting room $1 (name: $name, canonical alias: $canonical_alias, topic: $topic)[$joined_local_members]"
echo "This will remove $state_events state events"
if [[ $joined_local_members == "0" ]];
then
time synadm --yes room delete $1
else
echo "Room still had active members!!! $1"
fi
echo ""
}
log_file="empty-removal-$(date -Iminutes).log"
touch $log_file
for room in $(empty_rooms); do
delete_room $room | tee -a $log_file
done