diff --git a/interface/matrix.go b/interface/matrix.go index 73d9ec9..6430686 100644 --- a/interface/matrix.go +++ b/interface/matrix.go @@ -35,7 +35,7 @@ type MatrixContainer interface { SendMessage(roomID, msgtype, message string) (string, error) SendMarkdownMessage(roomID, msgtype, message string) (string, error) SendTyping(roomID string, typing bool) - JoinRoom(roomID string) (*rooms.Room, error) + JoinRoom(roomID, server string) (*rooms.Room, error) LeaveRoom(roomID string) error GetHistory(roomID, prevBatch string, limit int) ([]gomatrix.Event, string, error) diff --git a/matrix/matrix.go b/matrix/matrix.go index 4609876..de65b60 100644 --- a/matrix/matrix.go +++ b/matrix/matrix.go @@ -438,16 +438,11 @@ func (c *Container) SendTyping(roomID string, typing bool) { } // JoinRoom makes the current user try to join the given room. -func (c *Container) JoinRoom(roomID string) (*rooms.Room, error) { +func (c *Container) JoinRoom(roomID, server string) (*rooms.Room, error) { if len(roomID) == 0 { return nil, fmt.Errorf("invalid room ID") } - server := "" - if roomID[0] == '!' { - server = roomID[strings.Index(roomID, ":")+1:] - } - resp, err := c.client.JoinRoom(roomID, server, nil) if err != nil { return nil, err diff --git a/ui/view-main.go b/ui/view-main.go index ac7f3d2..c8b24f1 100644 --- a/ui/view-main.go +++ b/ui/view-main.go @@ -164,7 +164,12 @@ func (view *MainView) HandleCommand(roomView *RoomView, command string, args []s roomView.AddServiceMessage("Usage: /join ") break } - room, err := view.matrix.JoinRoom(args[0]) + identifer := args[0] + server := "" + if len(args) > 1 { + server = args[1] + } + room, err := view.matrix.JoinRoom(identifer, server) debug.Print("Join room error:", err) if err == nil { view.AddRoom(room)