[FIX] No new room created when conversation is closed#13753
[FIX] No new room created when conversation is closed#13753renatobecker-zz merged 6 commits intoRocketChat:developfrom
Conversation
| } | ||
|
|
||
| // Check if conversation is closed or not. | ||
| const closed = Rooms.findOneLivechatById(rid, fields); |
There was a problem hiding this comment.
We can't add this validation here because the current version of the Livechat client needs to create a new room when the current room is closed.
The point is that the issue #13733 is related to REST API endpoints, and our new Livechat client works over this approach, so I suggest you add validation on the Livechat message endpoint:
| throw new Meteor.Error('invalid-room'); | ||
| } | ||
|
|
||
| const closed = findRoomClosed(rid); |
There was a problem hiding this comment.
You don't need to create another method to find rooms.
| } | ||
|
|
||
| const closed = findRoomClosed(rid); | ||
| if (closed && closed.closedAt) { |
There was a problem hiding this comment.
You can check the open field, like:
if !(room && room.open) {
...
There was a problem hiding this comment.
I think it should be if (room && !room.open)
There was a problem hiding this comment.
Actually my suggestion was to check both room and room.open in only one validation, but if you want to check the room.open separately, yeah you just need to check:
if (!room.open) {
...
Below the existing validation:
if (!room) {
throw new Meteor.Error('invalid-room');
}
app/models/server/models/Rooms.js
Outdated
| return this.find(query, options); | ||
| } | ||
|
|
||
| findOneLivechatById(_id, fields) { |
|
@renatobecker updated |
| throw new Meteor.Error('invalid-room'); | ||
| } | ||
|
|
||
| if (room && !room.open) { |
There was a problem hiding this comment.
You can just check:
if (!room.open) {
...
}
Because the room object is checked here:
https://github.com/RocketChat/Rocket.Chat/blob/develop/app/livechat/server/api/v1/message.js#L33
There was a problem hiding this comment.
cool, let me update it
| } | ||
|
|
||
| if (!room.open) { | ||
| throw new Meteor.Error('chat-closed'); |
There was a problem hiding this comment.
Please, replace the chat-closed to room-closed, according we do here:
https://github.com/RocketChat/Rocket.Chat/blob/develop/app/livechat/server/api/v1/room.js#L56

Closes #13733
This PR solves the problem of creating a new room, again and again, once the conversation is closed.
Also fixed little CSS for analytics page from
to
cc @renatobecker would you please review.