 					if err
 						sails.log.error err
 		cb()
-		
+
 	afterPublishCreate: (values, req) ->
 		# send push notification to all subscribers excluding sender
 		sails.services.roster

			.then ->
				cb()
			.catch cb
		
	afterDestroy: (values, cb) ->
		_.each values, (msg) ->
			if msg.file

								sails.sockets.get(id).user.canEnter group
				else
					broadcast _.filter clients, (id) ->
						to == sails.sockets.get(id).user.jid or from == sails.sockets.get(id).user.jid
			.catch sails.log.error

	beforeCreate: (values, cb) ->
		values.type = sails.services.jid.type values.to
		cb()

	afterCreate: (values, cb) ->
		# find or create roster items for those subscribers for msg.from and msg.to
		sails.services.roster
			.subscribeAll values.from, values.to
			.then ->
				if sails.services.jid.isMuc values.to
					# search for all subscribed rosters
					sails.models.roster
