aboutsummaryrefslogtreecommitdiff
path: root/federationsender/internal/query.go
diff options
context:
space:
mode:
authorNeil Alexander <neilalexander@users.noreply.github.com>2020-05-01 13:01:50 +0100
committerGitHub <noreply@github.com>2020-05-01 13:01:50 +0100
commit908108c23e47df5fbf0d6629b676e105abd2a564 (patch)
tree5fe328d0e339fb2149dd44ba9054878b5a86f075 /federationsender/internal/query.go
parent17e046f18fc182731c112e1dd653cc7021ebd422 (diff)
Rename FS queue package to internal (#997)
Diffstat (limited to 'federationsender/internal/query.go')
-rw-r--r--federationsender/internal/query.go39
1 files changed, 39 insertions, 0 deletions
diff --git a/federationsender/internal/query.go b/federationsender/internal/query.go
new file mode 100644
index 00000000..88dd50a6
--- /dev/null
+++ b/federationsender/internal/query.go
@@ -0,0 +1,39 @@
+package internal
+
+import (
+ "context"
+
+ "github.com/matrix-org/dendrite/federationsender/api"
+ "github.com/matrix-org/gomatrixserverlib"
+)
+
+// QueryJoinedHostsInRoom implements api.FederationSenderInternalAPI
+func (f *FederationSenderInternalAPI) QueryJoinedHostsInRoom(
+ ctx context.Context,
+ request *api.QueryJoinedHostsInRoomRequest,
+ response *api.QueryJoinedHostsInRoomResponse,
+) (err error) {
+ response.JoinedHosts, err = f.db.GetJoinedHosts(ctx, request.RoomID)
+ return
+}
+
+// QueryJoinedHostServerNamesInRoom implements api.FederationSenderInternalAPI
+func (f *FederationSenderInternalAPI) QueryJoinedHostServerNamesInRoom(
+ ctx context.Context,
+ request *api.QueryJoinedHostServerNamesInRoomRequest,
+ response *api.QueryJoinedHostServerNamesInRoomResponse,
+) (err error) {
+ joinedHosts, err := f.db.GetJoinedHosts(ctx, request.RoomID)
+ if err != nil {
+ return
+ }
+
+ response.ServerNames = make([]gomatrixserverlib.ServerName, 0, len(joinedHosts))
+ for _, host := range joinedHosts {
+ response.ServerNames = append(response.ServerNames, host.ServerName)
+ }
+
+ // TODO: remove duplicates?
+
+ return
+}