Don't parse room ID

This commit is contained in:
Tulir Asokan 2018-05-10 20:07:24 +03:00
parent 248db71c76
commit 1e6b599649
3 changed files with 8 additions and 8 deletions

View File

@ -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)

View File

@ -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

View File

@ -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)