 	sendMessage: (message) ->
 
 		check message, Object
+
+		if not Meteor.userId()
+			throw new Meteor.Error('error-invalid-user', "Invalid user", { method: 'sendMessage' })
 
 		if message.ts
 			tsDiff = Math.abs(moment(message.ts).diff())

	type: 'method'
	name: 'sendMessage'
	userId: (userId) ->
		return 'bot' not in RocketChat.models.Users.findOneById(userId)?.roles
, 5, 1000


		if message.msg?.length > RocketChat.settings.get('Message_MaxAllowedSize')
			throw new Meteor.Error('error-message-size-exceeded', 'Message size exceeds Message_MaxAllowedSize', { method: 'sendMessage' })

		user = RocketChat.models.Users.findOneById Meteor.userId(), fields: username: 1, name: 1

