mirror of
https://github.com/matrix-org/dendrite.git
synced 2024-11-29 17:51:56 -06:00
fedsender: de-duplicate without sorting server names (#1073)
This commit is contained in:
parent
5307c499fe
commit
fe5cf6f880
|
@ -44,8 +44,9 @@ func (h *httpFederationSenderInternalAPI) PerformDirectoryLookup(
|
||||||
}
|
}
|
||||||
|
|
||||||
type PerformJoinRequest struct {
|
type PerformJoinRequest struct {
|
||||||
RoomID string `json:"room_id"`
|
RoomID string `json:"room_id"`
|
||||||
UserID string `json:"user_id"`
|
UserID string `json:"user_id"`
|
||||||
|
// The sorted list of servers to try. Servers will be tried sequentially, after de-duplication.
|
||||||
ServerNames types.ServerNames `json:"server_names"`
|
ServerNames types.ServerNames `json:"server_names"`
|
||||||
Content map[string]interface{} `json:"content"`
|
Content map[string]interface{} `json:"content"`
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,8 +46,19 @@ func (r *FederationSenderInternalAPI) PerformJoin(
|
||||||
supportedVersions = append(supportedVersions, version)
|
supportedVersions = append(supportedVersions, version)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deduplicate the server names we were provided.
|
// Deduplicate the server names we were provided but keep the ordering
|
||||||
util.SortAndUnique(request.ServerNames)
|
// as this encodes useful information about which servers are most likely
|
||||||
|
// to respond.
|
||||||
|
seenSet := make(map[gomatrixserverlib.ServerName]bool)
|
||||||
|
var uniqueList []gomatrixserverlib.ServerName
|
||||||
|
for _, srv := range request.ServerNames {
|
||||||
|
if seenSet[srv] {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
seenSet[srv] = true
|
||||||
|
uniqueList = append(uniqueList, srv)
|
||||||
|
}
|
||||||
|
request.ServerNames = uniqueList
|
||||||
|
|
||||||
// Try each server that we were provided until we land on one that
|
// Try each server that we were provided until we land on one that
|
||||||
// successfully completes the make-join send-join dance.
|
// successfully completes the make-join send-join dance.
|
||||||
|
|
Loading…
Reference in a new issue