From 1e6b5996491d7d27147a0dea2b52c36577820d63 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Thu, 10 May 2018 20:07:24 +0300 Subject: [PATCH] Don't parse room ID --- interface/matrix.go | 2 +- matrix/matrix.go | 7 +------ ui/view-main.go | 7 ++++++- 3 files changed, 8 insertions(+), 8 deletions(-) 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)