Fix keys maybe

This commit is contained in:
Neil Alexander 2022-11-15 09:37:07 +00:00
parent 73c3097c55
commit 2c92b29d22
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944

View file

@ -16,7 +16,6 @@ package routing
import ( import (
"encoding/json" "encoding/json"
"fmt"
"net/http" "net/http"
"time" "time"
@ -138,17 +137,13 @@ func ClaimOneTimeKeys(
func LocalKeys(cfg *config.FederationAPI, serverName gomatrixserverlib.ServerName) util.JSONResponse { func LocalKeys(cfg *config.FederationAPI, serverName gomatrixserverlib.ServerName) util.JSONResponse {
keys, err := localKeys(cfg, serverName) keys, err := localKeys(cfg, serverName)
if err != nil { if err != nil {
return util.ErrorResponse(err) return util.MessageResponse(http.StatusNotFound, err.Error())
} }
return util.JSONResponse{Code: http.StatusOK, JSON: keys} return util.JSONResponse{Code: http.StatusOK, JSON: keys}
} }
func localKeys(cfg *config.FederationAPI, serverName gomatrixserverlib.ServerName) (*gomatrixserverlib.ServerKeys, error) { func localKeys(cfg *config.FederationAPI, serverName gomatrixserverlib.ServerName) (*gomatrixserverlib.ServerKeys, error) {
var keys gomatrixserverlib.ServerKeys var keys gomatrixserverlib.ServerKeys
if !cfg.Matrix.IsLocalServerName(serverName) {
return nil, fmt.Errorf("server name not known")
}
var virtualHost *config.VirtualHost var virtualHost *config.VirtualHost
for _, v := range cfg.Matrix.VirtualHosts { for _, v := range cfg.Matrix.VirtualHosts {
if v.ServerName != serverName { if v.ServerName != serverName {