use To header field to know the backend to use (instead of In-Reply-To)
This commit is contained in:
parent
b616a9aa5f
commit
1aad7e430f
1 changed files with 18 additions and 4 deletions
|
|
@ -50,17 +50,26 @@ class Monboob(ConsoleApplication):
|
||||||
|
|
||||||
return self.process_command(*argv[1:])
|
return self.process_command(*argv[1:])
|
||||||
|
|
||||||
|
def get_email_address_ident(self, msg, header):
|
||||||
|
s = msg.get(header)
|
||||||
|
m = re.match('.*<(.*)@(.*)>', s)
|
||||||
|
if m:
|
||||||
|
return m.group(1)
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
return s.split('@')[0]
|
||||||
|
except IndexError:
|
||||||
|
return s
|
||||||
|
|
||||||
@ConsoleApplication.command("pipe with a mail to post message")
|
@ConsoleApplication.command("pipe with a mail to post message")
|
||||||
def command_post(self):
|
def command_post(self):
|
||||||
msg = message_from_file(sys.stdin)
|
msg = message_from_file(sys.stdin)
|
||||||
reply_to = msg.get('In-Reply-To')
|
to = self.get_email_address_ident(msg, 'To')
|
||||||
|
reply_to = self.get_email_address_ident(msg, 'In-Reply-To')
|
||||||
if not reply_to:
|
if not reply_to:
|
||||||
print >>sys.stderr, 'This is not a reply (no Reply-To field)'
|
print >>sys.stderr, 'This is not a reply (no Reply-To field)'
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
m = re.match('<(.*)@(.*)>', reply_to)
|
|
||||||
if m:
|
|
||||||
reply_to = m.group(1)
|
|
||||||
title = msg.get('Subject')
|
title = msg.get('Subject')
|
||||||
if title:
|
if title:
|
||||||
new_title = u''
|
new_title = u''
|
||||||
|
|
@ -88,6 +97,11 @@ class Monboob(ConsoleApplication):
|
||||||
content = content.split(u'\n-- \n')[0]
|
content = content.split(u'\n-- \n')[0]
|
||||||
|
|
||||||
bname, id = reply_to.split('.', 1)
|
bname, id = reply_to.split('.', 1)
|
||||||
|
|
||||||
|
# Default use the To header field to know the backend to use.
|
||||||
|
if to and bname != to:
|
||||||
|
bname = to
|
||||||
|
|
||||||
try:
|
try:
|
||||||
backend = self.weboob.backends[bname]
|
backend = self.weboob.backends[bname]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue