2019-08-22 11:47:52 +00:00
|
|
|
package query
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"github.com/matrix-org/dendrite/federationsender/api"
|
|
|
|
"github.com/matrix-org/gomatrixserverlib"
|
|
|
|
)
|
|
|
|
|
2020-04-29 10:34:31 +00:00
|
|
|
// QueryJoinedHostsInRoom implements api.FederationSenderInternalAPI
|
|
|
|
func (f *FederationSenderInternalAPI) QueryJoinedHostsInRoom(
|
2019-08-22 11:47:52 +00:00
|
|
|
ctx context.Context,
|
|
|
|
request *api.QueryJoinedHostsInRoomRequest,
|
|
|
|
response *api.QueryJoinedHostsInRoomResponse,
|
|
|
|
) (err error) {
|
|
|
|
response.JoinedHosts, err = f.DB.GetJoinedHosts(ctx, request.RoomID)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2020-04-29 10:34:31 +00:00
|
|
|
// QueryJoinedHostServerNamesInRoom implements api.FederationSenderInternalAPI
|
|
|
|
func (f *FederationSenderInternalAPI) QueryJoinedHostServerNamesInRoom(
|
2019-08-22 11:47:52 +00:00
|
|
|
ctx context.Context,
|
|
|
|
request *api.QueryJoinedHostServerNamesInRoomRequest,
|
|
|
|
response *api.QueryJoinedHostServerNamesInRoomResponse,
|
|
|
|
) (err error) {
|
|
|
|
joinedHosts, err := f.DB.GetJoinedHosts(ctx, request.RoomID)
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2019-12-20 13:24:57 +00:00
|
|
|
response.ServerNames = make([]gomatrixserverlib.ServerName, 0, len(joinedHosts))
|
2019-08-22 11:47:52 +00:00
|
|
|
for _, host := range joinedHosts {
|
2019-12-20 13:24:57 +00:00
|
|
|
response.ServerNames = append(response.ServerNames, host.ServerName)
|
2019-08-22 11:47:52 +00:00
|
|
|
}
|
|
|
|
|
2019-12-20 13:24:57 +00:00
|
|
|
// TODO: remove duplicates?
|
2019-08-22 11:47:52 +00:00
|
|
|
|
|
|
|
return
|
|
|
|
}
|