From a05a6dfb5412774f92b3b6a64db6781d2cd2b58d Mon Sep 17 00:00:00 2001 From: nxshock Date: Wed, 24 Jul 2019 20:02:04 +0500 Subject: [PATCH] Fix room.ID() method --- internal/backends/memory/rooms.go | 4 +++- internal/backends/memory/rooms_test.go | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/backends/memory/rooms.go b/internal/backends/memory/rooms.go index aa6e625..6e1c5be 100644 --- a/internal/backends/memory/rooms.go +++ b/internal/backends/memory/rooms.go @@ -20,6 +20,8 @@ type Room struct { events []RoomEvent + server *Backend + mutex sync.RWMutex } @@ -27,7 +29,7 @@ func (room *Room) ID() string { room.mutex.RLock() defer room.mutex.RUnlock() - return room.id + return "!" + room.id + ":" + room.server.hostname } func (room *Room) Name() string { diff --git a/internal/backends/memory/rooms_test.go b/internal/backends/memory/rooms_test.go index 5c31cf2..d71529f 100644 --- a/internal/backends/memory/rooms_test.go +++ b/internal/backends/memory/rooms_test.go @@ -26,6 +26,7 @@ func TestCreateRoom(t *testing.T) { assert.Equal(t, request.Topic, room.Topic()) assert.Equal(t, user.ID(), room.Creator().ID()) assert.Equal(t, 1, len(backend.rooms)) + assert.Equal(t, "!"+room.(*Room).id+":"+backend.hostname, room.ID()) } func TestCreateAlreadyExistingRoom(t *testing.T) {