summary refs log tree commit diff
path: root/host/Rory-nginx/services/matrix/synapse/workers/single/user-dir.nix
diff options
context:
space:
mode:
Diffstat (limited to 'host/Rory-nginx/services/matrix/synapse/workers/single/user-dir.nix')
-rw-r--r--host/Rory-nginx/services/matrix/synapse/workers/single/user-dir.nix43
1 files changed, 28 insertions, 15 deletions
diff --git a/host/Rory-nginx/services/matrix/synapse/workers/single/user-dir.nix b/host/Rory-nginx/services/matrix/synapse/workers/single/user-dir.nix
index 0253438..4fd3fb3 100644
--- a/host/Rory-nginx/services/matrix/synapse/workers/single/user-dir.nix
+++ b/host/Rory-nginx/services/matrix/synapse/workers/single/user-dir.nix
@@ -3,14 +3,16 @@
 let
   cfg = config.services.matrix-synapse;
   dbGroup = "solo";
-  hasClientResource = true;
-  hasFederationResource = false;
   workerName = "user_dir";
-  workerRoutes = [
-    "~ ^/_matrix/client/(api/v1|r0|v3|unstable)/user_directory/search$"
-    "~ ^/_matrix/client/v3/profile/.*/(displayname|avatar_url)$"
-    "~ ^/_matrix/client/v3/profile/.*$"
-  ];
+  workerRoutes = {
+    client = [
+      "~ ^/_matrix/client/(api/v1|r0|v3|unstable)/user_directory/search$"
+      "~ ^/_matrix/client/v3/profile/.*/(displayname|avatar_url)$"
+      "~ ^/_matrix/client/v3/profile/.*$"
+    ];
+    federation = [ ];
+    media = [ ];
+  };
 in
 {
   config = lib.mkIf cfg.enableUserDirWorker {
@@ -41,7 +43,7 @@ in
                 ];
               }
             ]
-            ++ lib.optional hasClientResource {
+            ++ lib.optional (lib.length workerRoutes.client > 0) {
               type = "http";
               path = "/run/matrix-synapse/${workerName}-client.sock";
               mode = "666";
@@ -52,7 +54,7 @@ in
                 }
               ];
             }
-            ++ lib.optional hasFederationResource {
+            ++ lib.optional (lib.length workerRoutes.federation > 0) {
               type = "http";
               path = "/run/matrix-synapse/${workerName}-federation.sock";
               mode = "666";
@@ -71,12 +73,23 @@ in
 
     services.nginx = {
       virtualHosts."${cfg.nginxVirtualHostName}".locations = lib.listToAttrs (
-        lib.map (route: {
-          name = route;
-          value = {
-            proxyPass = "http://${workerName}";
-          };
-        }) workerRoutes
+        lib.flatten (
+          lib.forEach
+            [
+              "client"
+              "federation"
+              "media"
+            ]
+            (
+              type:
+              lib.map (route: {
+                name = route;
+                value = {
+                  proxyPass = "http://unix:/run/matrix-synapse/${workerName}-${type}.sock";
+                };
+              }) workerRoutes.${type}
+            )
+        )
       );
     };
   };