 	updateUserStatus: updateUserStatus
 	onlineUsers: onlineUsers
 	updateMentionsMarksOfRoom: updateMentionsMarksOfRoom
+	getOpenedRoomByRid: getOpenedRoomByRid

Meteor.startup ->
	ChatMessage.find().observe
		removed: (record) ->
			recordBefore = ChatMessage.findOne {ts: {$lt: record.ts}}, {sort: {ts: -1}}
			if recordBefore?
				ChatMessage.update {_id: recordBefore._id}, {$set: {tick: new Date}}

			recordAfter = ChatMessage.findOne {ts: {$gt: record.ts}}, {sort: {ts: 1}}
			if recordAfter?
				ChatMessage.update {_id: recordAfter._id}, {$set: {tick: new Date}}


onDeleteMessageStream = (msg) ->

				Dep.depend()
				return openedRooms[typeName].ready
		}

	getOpenedRoomByRid = (rid) ->
		for typeName, openedRoom of openedRooms
			if openedRoom.rid is rid
				return openedRoom

	getDomOfRoom = (typeName, rid) ->
		room = openedRooms[typeName]
