Commit 3221b628 authored by Rodrigo Nascimento's avatar Rodrigo Nascimento

Prevent errors on rooms without usernames

parent 43b6612b
......@@ -13,7 +13,11 @@ RocketChat.sendMessage = (user, message, room, upsert = false) ->
message.rid = room._id
if not room.usernames? || room.usernames.length is 0
room = RocketChat.models.Rooms.findOneById(room._id)
updated_room = RocketChat.models.Rooms.findOneById(room._id)
if updated_room?
room = updated_room
else
room.usernames = []
if message.parseUrls isnt false
if urls = message.msg.match /([A-Za-z]{3,9}):\/\/([-;:&=\+\$,\w]+@{1})?([-A-Za-z0-9\.]+)+:?(\d+)?((\/[-\+=!:~%\/\.@\,\w]*)?\??([-\+=&!:;%@\/\.\,\w]+)?(?:#([^\s\)]+))?)?/g
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment