Index: /trunk/ChangeLog
===================================================================
--- /trunk/ChangeLog	(revision 193)
+++ /trunk/ChangeLog	(revision 194)
@@ -1,3 +1,3 @@
-2007-XX-XX
+2008-02-04
 	* Added version check and exit if we do not support the trac version
 	  closes bug #23
@@ -24,4 +24,37 @@
 
 	  Implemented by: Bas van der Vlies
+
+	* greedy matching in Subject line, We must stop after the first ':'
+	  else we get wrong values for ticket fields when we update a ticket
+	  via mail, closes ticket #37
+	  Reported by: dmaziuk at bmrb dot wisc dot edu
+	  Fixed    by: Bas van der Vlies
+
+	* added IGNORECASE flag to regular expression for black list. This
+	  is a quick fix, still want to implement this as configuration 
+	  option, closed bug #39
+
+	  Reported By: jodok at lovelysystems dot com
+	  Fixed by   : Bas van der Vlies
+
+	* When a known user mails a ticket. We will set the Reporter to
+	  its login name, closes bug #33, #41
+
+	  Also add configuration option: 
+	  	ignore_trac_user_settings : 0 (default value)
+
+	  This option will skip the email address to trac user login name
+	  mapping.
+
+	  Reported by: anonymous
+	  Fixed by   : Bas van der Vlies
+
+	
+	* SPAM detection was only for new mails not for ticket updates,
+	  closed ticket #44
+
+	  Reported by: Bas van der Vlies
+	  Fixed by   : Bas van der Vlies
+	  
 	   
 2007-07-18
Index: /trunk/email2trac.conf
===================================================================
--- /trunk/email2trac.conf	(revision 193)
+++ /trunk/email2trac.conf	(revision 194)
@@ -16,4 +16,5 @@
 email_quote: >
 strip_quotes: 0
+ignore_trac_user_settings: 0
 
 
Index: /trunk/email2trac.py.in
===================================================================
--- /trunk/email2trac.py.in	(revision 193)
+++ /trunk/email2trac.py.in	(revision 194)
@@ -230,4 +230,8 @@
 			self.TMPDIR = os.path.normcase(str(parameters['tmpdir']))
 
+		if parameters.has_key('ignore_trac_user_settings'):
+			self.IGNORE_TRAC_USER_SETTINGS = int(parameters['ignore_trac_user_settings'])
+		else:
+			self.IGNORE_TRAC_USER_SETTINGS = 0
 
 	def spam(self, message):
@@ -236,4 +240,5 @@
 		# Note if Spam_level then '*' are included
 		"""
+		spam = False
 		if message.has_key('X-Spam-Score'):
 			spam_l = string.split(message['X-Spam-Score'])
@@ -241,12 +246,26 @@
 
 			if number >= self.SPAM_LEVEL:
-				return 'Spam'
-
+				spam = True
+				
 		# treat virus mails as spam
 		#
 		elif message.has_key('X-Virus-found'):			
+			spam = True
+
+		# How to handle SPAM messages
+		#
+		if self.DROP_SPAM and spam:
+			if self.DEBUG > 2 : 
+				print 'This message is a SPAM. Automatic ticket insertion refused (SPAM level > %d' % self.SPAM_LEVEL
+
+			return True	
+
+		elif spam:
+
 			return 'Spam'
 
-		return self.get_config('ticket', 'default_component') 
+		else:
+
+			return self.get_config('ticket', 'default_component') 
 
 
@@ -254,5 +273,5 @@
 		FROM_RE = re.compile(r"""
                     MAILER-DAEMON@
-                    """, re.VERBOSE)
+                    """, re.VERBOSE|re.IGNORECASE)
 		result =  FROM_RE.search(self.email_addr)
 		if result:
@@ -353,24 +372,30 @@
 			ticket['owner'] = None
 
-	def get_author_emailaddrs(self, message):
+	def get_sender_info(self, message):
 		"""
 		Get the default author name and email address from the message
 		"""
-		temp = self.email_to_unicode(message['from'])
-		#print temp.encode('utf-8')
-
-		self.author, self.email_addr  = email.Utils.parseaddr(temp)
-		#print self.author.encode('utf-8', 'replace')
-
-		# Look for email address in registered trac users
-		#
-		users = [ u for (u, n, e) in self.env.get_known_users(self.db)
+
+		self.email_from = self.email_to_unicode(message['from'])
+		self.author, self.email_addr  = email.Utils.parseaddr(self.email_from)
+
+		# Maybe for later user
+		#self.email_from =  self.email_to_unicode(self.email_addr)
+
+
+		if self.IGNORE_TRAC_USER_SETTINGS:
+			return
+
+		# Is this a registered user, use email address as search key:
+		# result:
+		#   u : login name
+		#   n : Name that the user has set in the settings tab
+		#   e : email address that the user has set in the settings tab 
+		#
+		users = [ (u,n,e) for (u, n, e) in self.env.get_known_users(self.db)
 				if e == self.email_addr ]
 
 		if len(users) == 1:
-			self.email_from = users[0]
-		else:
-			self.email_from =  self.email_to_unicode(message['from'])
-			#self.email_from =  self.email_to_unicode(self.email_addr)
+			self.email_from = users[0][0]
 
 	def set_reply_fields(self, ticket, message):
@@ -513,5 +538,5 @@
 		TICKET_RE = re.compile(r"""
 					(?P<ticketnr>[#][0-9]+:)
-					|(?P<ticketnr_fields>[#][\d]+\?.*:)
+					|(?P<ticketnr_fields>[#][\d]+\?.*?:)
 					""", re.VERBOSE)
 
@@ -538,10 +563,12 @@
 
 
-		# Get current time
-		# to do
-		#when = int(time.time())
-		#
-		utc = UTC()
-		when = datetime.now(utc)
+		# When is the change committed
+		# 
+		#
+		if self.VERSION == 0.11:
+			utc = UTC()
+			when = datetime.now(utc)
+		else:
+			when = int(time.time())
 
 		try:
@@ -577,5 +604,5 @@
 		return True
 
-	def new_ticket(self, msg):
+	def new_ticket(self, msg, component):
 		"""
 		Create a new ticket
@@ -596,16 +623,8 @@
 			tkt['summary'] = self.email_to_unicode(msg['Subject'])
 
-
 		if settings.has_key('component'):
 			tkt['component'] = settings['component']
 		else:
-			tkt['component'] = self.spam(msg)
-
-		# Discard SPAM messages.
-		#
-		if self.DROP_SPAM and (tkt['component'] == 'Spam'):
-			if self.DEBUG > 2 :
-			  print 'This message is a SPAM. Automatic ticket insertion refused (SPAM level > %d' % self.SPAM_LEVEL
-			return False	
+			tkt['component'] = component
 
 		# Set default owner for component, HvB
@@ -680,5 +699,5 @@
 
 		self.db = self.env.get_db_cnx()
- 		self.get_author_emailaddrs(m)
+ 		self.get_sender_info(m)
 
  		if self.blacklisted_from():
@@ -687,4 +706,11 @@
  			return False
 
+	    # If component is true then we drop the message drop message
+		#
+		component =  self.spam(m)
+		if component == True:
+			return False
+
+
 		if self.get_config('notification', 'smtp_enabled') in ['true']:
 			self.notification = 1
@@ -698,5 +724,5 @@
 				return True
 
-		self.new_ticket(m)
+		self.new_ticket(m, component)
 
 	def strip_signature(self, text):
