feat(mattermost): add matterbridge integration to mattermost module

This commit is contained in:
Mohammad Rafiq 2025-06-18 03:24:50 +08:00
parent 506fdf8ad9
commit d26df1fafa
No known key found for this signature in database
2 changed files with 37 additions and 2 deletions

View file

@ -21,6 +21,7 @@ mkWebApp {
(mkDir cfg.dataDir)
];
extraOptions = {
teamName = mkStrOption;
configDir = mkStrOption // {
default = "/etc/mattermost";
};
@ -49,6 +50,38 @@ mkWebApp {
host = "0.0.0.0";
siteUrl = "https://${cfg.domain}";
};
services.matterbridge = {
enable = true;
inherit (upstreamCfg) user group;
configPath = config.sops.templates."matterbridge-conf".path;
};
sops.secrets."matterbridge/mattermost-password" = { };
sops.templates."matterbridge-conf" = {
owner = upstreamCfg.user;
content = # toml
''
[[gateway]]
name="gateway1"
enable=true
[[gateway.inout]]
account="mattermost.${config.hostname}"
channel="matterbridge"
[mattermost.${config.hostname}]
Server="${cfg.domain}"
Team="${cfg.teamName}"
Login="matterbridge"
Password="${config.sops.placeholder."matterbridge/mattermost-password"}"
RemoteNickFormat="[{PROTOCOL}] <{NICK}> "
PrefixMessagesWithNick=true
PreserveThreading=true
'';
};
services.nginx.virtualHosts.${cfg.domain}.locations."~ /api/v[0-9]+/(users/)?websocket$" = {
proxyPass = "http://${config.hostname}:${toString cfg.port}";
proxyWebsockets = true;
};
services.postgresql = {
ensureDatabases = singleton upstreamCfg.database.name;
ensureUsers = singleton {