diff options
author | Tulir Asokan <tulir@maunium.net> | 2018-05-10 20:07:24 +0300 |
---|---|---|
committer | Tulir Asokan <tulir@maunium.net> | 2018-05-10 20:07:24 +0300 |
commit | 1e6b5996491d7d27147a0dea2b52c36577820d63 (patch) | |
tree | c7f55b9a7a3797511254d0e55971ea535f1badf6 | |
parent | 248db71c76988188f4021621837a8d024efa1d73 (diff) |
Don't parse room ID
-rw-r--r-- | interface/matrix.go | 2 | ||||
-rw-r--r-- | matrix/matrix.go | 7 | ||||
-rw-r--r-- | 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 <room>") 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) |