~sumner/nixos-configuration

23703c975ed3ce51527d5711301bfb6e7a8f4720 — Sumner Evans 6 months ago e5a37f4 synapse-cleanup
synapse: add cleanup scripts
2 files changed, 18 insertions(+), 0 deletions(-)

M modules/services/matrix/default.nix
A modules/services/matrix/synapse-cleanup.nix
M modules/services/matrix/default.nix => modules/services/matrix/default.nix +1 -0
@@ 3,5 3,6 @@
    ./heisenbridge.nix
    ./quotesfilebot.nix
    ./synapse.nix
    ./synapse-cleanup.nix
  ];
}

A modules/services/matrix/synapse-cleanup.nix => modules/services/matrix/synapse-cleanup.nix +17 -0
@@ 0,0 1,17 @@
{ config, lib, pkgs, ... }: with pkgs; with lib; let
  synapseCfg = config.services.matrix-synapse;
  adminAccessToken = "";

  port = toString (elemAt synapseCfg.listeners 0).port;

  deleteForgottenRoomsScript = writeShellScriptBin "delete-forgotten-rooms" ''
    ${curl}/bin/curl \
        --header "Authorization: Bearer ${adminAccessToken}" \
        'http://localhost:${port}/_synapse/admin/v1/rooms?limit=1000&order_by=joined_local_members&dir=b' |
      ${jq}/bin/jq \
        '.rooms[] | select(.joined_local_members == 0)'
  '';
in
{
  environment.systemPackages = [ deleteForgottenRoomsScript ];
}