changeset 1687:1d358ccc0f2f

mail_import_pagename_search determines where and in which order to look for target pagename
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 26 Nov 2006 16:12:55 +0100
parents b010f7260ab6
children 07da298b129a
files MoinMoin/config/multiconfig.py MoinMoin/mail/mailimport.py
diffstat 2 files changed, 25 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/config/multiconfig.py	Sun Nov 26 13:01:56 2006 +0100
+++ b/MoinMoin/config/multiconfig.py	Sun Nov 26 16:12:55 2006 +0100
@@ -310,6 +310,7 @@
     mail_from = None # u'Juergen Wiki <noreply@jhwiki.org>'
 
     mail_import_subpage_template = u"$from-$date-$subject" # used for mail import
+    mail_import_pagename_search = ['subject', 'to', ] # where to look for target pagename (and in which order)
     mail_import_pagename_envelope = u"%s" # use u"+ %s/" to add "+ " and "/" automatically
     mail_import_wiki_addrs = [] # the e-mail addresses for e-mails that should go into the wiki
     mail_import_secret = ""
--- a/MoinMoin/mail/mailimport.py	Sun Nov 26 13:01:56 2006 +0100
+++ b/MoinMoin/mail/mailimport.py	Sun Nov 26 16:12:55 2006 +0100
@@ -133,34 +133,37 @@
     email_subpage_template = cfg.mail_import_subpage_template
     email_pagename_envelope = cfg.mail_import_pagename_envelope
     wiki_addrs = cfg.mail_import_wiki_addrs
-
-    pagename_tpl = ""
-    for addr in msg['target_addrs']:
-        if addr[1].strip().lower() in wiki_addrs:
-            pagename_tpl = addr[0]
-            break
+    search_list = cfg.mail_import_pagename_search
 
-    if not pagename_tpl:
-        subj = msg['subject'].strip()
-        m = re_subject.search(subj)
-        if m:
-            pagename_tpl = m.group(1)
-            # remove the pagename template from the subject:
-            subj = re_subject.sub('', subj, 1).strip()
-        msg['subject'] = subj
-    else:
-        # special fix for outlook users :-)
-        if pagename_tpl[-1] == pagename_tpl[0] == "'":
-            pagename_tpl = pagename_tpl[1:-1]
-
-    if not msg['subject'].strip():
-        msg['subject'] = '(...)' # we need non-empty subject
+    subj = msg['subject'].strip()
+    pagename_tpl = ""
+    for method in search_list:
+        if method == 'to':
+            for addr in msg['target_addrs']:
+                if addr[1].strip().lower() in wiki_addrs:
+                    pagename_tpl = addr[0]
+                    # special fix for outlook users :-)
+                    if pagename_tpl[-1] == pagename_tpl[0] == "'":
+                        pagename_tpl = pagename_tpl[1:-1]
+                    break
+        elif method == 'subj':
+            m = re_subject.search(subj)
+            if m:
+                pagename_tpl = m.group(1)
+                # remove the pagename template from the subject:
+                subj = re_subject.sub('', subj, 1).strip()
+        if pagename_tpl:
+            break
 
     pagename_tpl = pagename_tpl.strip()
     # last resort
     if not pagename_tpl:
         pagename_tpl = email_subpage_template
 
+    if not subj:
+        subj = '(...)' # we need non-empty subject
+    msg['subject'] = subj
+
     # for normal use, email_pagename_envelope is just u"%s" - so nothing changes.
     # for special use, you can use u"+ %s/" - so you don't need to enter "+"
     # and "/" in every email, but you get the result as if you did.