Registrations currently disabled due to spam. Contact me externally if you need an account

Unverified Commit 3221b628 authored by Rodrigo Nascimento's avatar Rodrigo Nascimento
Browse files

Prevent errors on rooms without usernames

parent 43b6612b
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -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