Skip to content

Commit 056d3af

Browse files
committed
fix: improve search room
1 parent 1ad1fc6 commit 056d3af

File tree

2 files changed

+3
-20
lines changed

2 files changed

+3
-20
lines changed

matrix/client.go

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -168,28 +168,10 @@ func (mc *MatrixClient) CreateDirectRoom(ctx context.Context, userID id.UserID,
168168
func (mc *MatrixClient) JoinRoom(ctx context.Context, userID id.UserID, roomID id.RoomID) (*mautrix.RespJoinRoom, error) {
169169
mc.mu.Lock()
170170
defer mc.mu.Unlock()
171-
172171
mc.cli.UserID = userID
173-
174-
// Extract homeserver from room ID for federated joins
175-
// Room ID format: !opaque:homeserver.name
176-
roomIDStr := string(roomID)
177172
req := &mautrix.ReqJoinRoom{}
178-
179-
if idx := strings.Index(roomIDStr, ":"); idx > 0 && idx < len(roomIDStr)-1 {
180-
roomServerName := roomIDStr[idx+1:]
181-
182-
// Only add Via if the room is on a different homeserver (federated)
183-
if roomServerName != "" && roomServerName != mc.homeserverName {
184-
req.Via = []string{roomServerName}
185-
logger.Debug().Str("user_id", string(userID)).Str("room_id", roomIDStr).Str("room_server", roomServerName).Str("local_server", mc.homeserverName).Msg("matrix: joining federated room with homeserver hint")
186-
} else {
187-
logger.Debug().Str("user_id", string(userID)).Str("room_id", roomIDStr).Msg("matrix: joining local room without via")
188-
}
189-
}
190-
191-
logger.Debug().Str("user_id", string(userID)).Str("room_id", roomIDStr).Bool("has_via", len(req.Via) > 0).Msg("matrix: calling JoinRoom")
192-
return mc.cli.JoinRoom(ctx, roomIDStr, req)
173+
logger.Debug().Str("user_id", string(userID)).Str("room_id", string(roomID)).Msg("matrix: joining local room")
174+
return mc.cli.JoinRoom(ctx, string(roomID), req)
193175
}
194176

195177
// ResolveRoomAlias resolves a room alias to a room ID.

service/messages.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ func (s *MessageService) ensureDirectRoom(ctx context.Context, actingUserID, tar
339339
logger.Debug().Str("key", key).Msg("Searching for direct room with alias")
340340
roomID := s.matrixClient.ResolveRoomAlias(ctx, key)
341341
if roomID != "" {
342+
logger.Debug().Str("alias", key).Msg("direct room already exists")
342343
return id.RoomID(roomID), nil
343344
}
344345

0 commit comments

Comments
 (0)