 		q.version = @DB.lessThanOrEqualTo Number version if version
 		q.when = @DB.lessThanOrEqualTo Number time if time
 		q.processed = !! processed if processed isnt null
+		q.messageId = messageId if messageId
 
 		Logger.log 'getting mails with query %s', q
 

		props.type = @TYPE_MAIL
		props.processed = false

		@DB.save props

	@removeMail: (mail) ->

	@TYPE_MAIL:		'mail'
	@TYPE_USER:		'user'

	@getMails: (user, version, time, processed = null, messageId = null) ->
		q =
			type:		@TYPE_MAIL

