mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-07-29 12:42:46 +00:00
Miscellaneous fixes (#1060)
* Add missing routing for PerformDirectoryLookupRequest * Tweak output * Fix some bugs in devices * Don't default to federated room joins in response to invite * Update sytest-whitelist * Update comments * Return correct room ID from PerformJoin * Fix appservice and EDU server API setup, update sytest-whitelist * Update sytest-whitelist
This commit is contained in:
parent
492af0f2ec
commit
6d50212f29
12 changed files with 71 additions and 32 deletions
|
@ -24,6 +24,7 @@ type PerformJoinRequest struct {
|
|||
}
|
||||
|
||||
type PerformJoinResponse struct {
|
||||
RoomID string `json:"room_id"`
|
||||
}
|
||||
|
||||
func (h *httpRoomserverInternalAPI) PerformJoin(
|
||||
|
|
|
@ -90,6 +90,12 @@ func (r *RoomserverInternalAPI) performJoinRoomByID(
|
|||
req *api.PerformJoinRequest,
|
||||
res *api.PerformJoinResponse, // nolint:unparam
|
||||
) error {
|
||||
// By this point, if req.RoomIDOrAlias contained an alias, then
|
||||
// it will have been overwritten with a room ID by performJoinRoomByAlias.
|
||||
// We should now include this in the response so that the CS API can
|
||||
// return the right room ID.
|
||||
res.RoomID = req.RoomIDOrAlias
|
||||
|
||||
// Get the domain part of the room ID.
|
||||
_, domain, err := gomatrixserverlib.SplitID('!', req.RoomIDOrAlias)
|
||||
if err != nil {
|
||||
|
@ -121,20 +127,30 @@ func (r *RoomserverInternalAPI) performJoinRoomByID(
|
|||
return fmt.Errorf("eb.SetContent: %w", err)
|
||||
}
|
||||
|
||||
// First work out if this is in response to an existing invite.
|
||||
// If it is then we avoid the situation where we might think we
|
||||
// know about a room in the following section but don't know the
|
||||
// latest state as all of our users have left.
|
||||
// First work out if this is in response to an existing invite
|
||||
// from a federated server. If it is then we avoid the situation
|
||||
// where we might think we know about a room in the following
|
||||
// section but don't know the latest state as all of our users
|
||||
// have left.
|
||||
isInvitePending, inviteSender, err := r.isInvitePending(ctx, req.RoomIDOrAlias, req.UserID)
|
||||
if err == nil && isInvitePending {
|
||||
// Add the server of the person who invited us to the server list,
|
||||
// as they should be a fairly good bet.
|
||||
if _, inviterDomain, ierr := gomatrixserverlib.SplitID('@', inviteSender); ierr == nil {
|
||||
req.ServerNames = append(req.ServerNames, inviterDomain)
|
||||
// Check if there's an invite pending.
|
||||
_, inviterDomain, ierr := gomatrixserverlib.SplitID('@', inviteSender)
|
||||
if ierr != nil {
|
||||
return fmt.Errorf("gomatrixserverlib.SplitID: %w", err)
|
||||
}
|
||||
|
||||
// Perform a federated room join.
|
||||
return r.performFederatedJoinRoomByID(ctx, req, res)
|
||||
// Check that the domain isn't ours. If it's local then we don't
|
||||
// need to do anything as our own copy of the room state will be
|
||||
// up-to-date.
|
||||
if inviterDomain != r.Cfg.Matrix.ServerName {
|
||||
// Add the server of the person who invited us to the server list,
|
||||
// as they should be a fairly good bet.
|
||||
req.ServerNames = append(req.ServerNames, inviterDomain)
|
||||
|
||||
// Perform a federated room join.
|
||||
return r.performFederatedJoinRoomByID(ctx, req, res)
|
||||
}
|
||||
}
|
||||
|
||||
// Try to construct an actual join event from the template.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue