 		result = result.sortBy 'user'
 		result
 
+	@cancelMails: (user, messageId) ->
+		scheduledMails = @getMails user, null, null, false, messageId
+		modified = while result.hasNext()
+			mail.next().processed = 'canceled'
+
+		if modified.length > 0
+			@DB.saveBatch modified, false
+			@DB.allOk modified
+		else
+			true
+
 	@storeMail: (user, version, props) ->
 		return null if not props or not user or not version
 		props.user = user

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

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


		props.type = @TYPE_MAIL
		props.processed = false

		@cancelMails user, props.messageId
		@DB.save props

	@removeMail: (mail) ->
