pax_global_header 0000666 0000000 0000000 00000000064 13435444765 0014531 g ustar 00root root 0000000 0000000 52 comment=139760e841ad4875b59fe11e052af1bb56dc06ea
woob-139760e841ad4875b59fe11e052af1bb56dc06ea-modules-mailinator/ 0000775 0000000 0000000 00000000000 13435444765 0023277 5 ustar 00root root 0000000 0000000 woob-139760e841ad4875b59fe11e052af1bb56dc06ea-modules-mailinator/modules/ 0000775 0000000 0000000 00000000000 13435444765 0024747 5 ustar 00root root 0000000 0000000 woob-139760e841ad4875b59fe11e052af1bb56dc06ea-modules-mailinator/modules/mailinator/ 0000775 0000000 0000000 00000000000 13435444765 0027106 5 ustar 00root root 0000000 0000000 woob-139760e841ad4875b59fe11e052af1bb56dc06ea-modules-mailinator/modules/mailinator/__init__.py 0000664 0000000 0000000 00000001517 13435444765 0031223 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright(C) 2013 Vincent A
#
# This file is part of a weboob module.
#
# This weboob module is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This weboob module is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this weboob module. If not, see .
from .module import MailinatorModule
__all__ = ['MailinatorModule']
woob-139760e841ad4875b59fe11e052af1bb56dc06ea-modules-mailinator/modules/mailinator/browser.py 0000664 0000000 0000000 00000004206 13435444765 0031145 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright(C) 2013 Vincent A
#
# This file is part of a weboob module.
#
# This weboob module is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This weboob module is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this weboob module. If not, see .
from weboob.browser.browsers import APIBrowser, ClientError
from weboob.tools.date import datetime
from weboob.tools.decorators import retry
__all__ = ['MailinatorBrowser']
class MailinatorBrowser(APIBrowser):
BASEURL = 'https://www.mailinator.com'
ENCODING = 'utf-8'
@retry(ClientError)
def get_mails(self, boxid, after=None):
mails = self.request('/api/webinbox2?x=0&public_to=%s' % boxid)
for mail in mails['public_msgs']:
d = {
'id': mail['id'],
'from': mail['fromfull'],
'to': mail['to'],
'from_name': mail['from'],
'datetime': frommillis(mail['time']),
'subject': mail['subject'],
'box': boxid
}
yield d
@retry(ClientError)
def get_mail_content(self, mailid):
data = self.request('/fetchmail?msgid=%s&zone=public' % mailid)['data']
if 'parts' not in data:
return 'text', ''
for part in data['parts']:
content_type = part['headers'].get('content-type', '')
if content_type.startswith('text/plain'):
return 'text', part['body']
elif content_type.startswith('text/html'):
return 'html', part['body']
return 'text', ''
def frommillis(millis):
return datetime.fromtimestamp(millis / 1000)
woob-139760e841ad4875b59fe11e052af1bb56dc06ea-modules-mailinator/modules/mailinator/favicon.png 0000664 0000000 0000000 00000001027 13435444765 0031241 0 ustar 00root root 0000000 0000000 PNG
IHDR @ @ iq bKGD pHYs tIME)1ڒ} tEXtComment Created with GIMPW IDATxY[0kPpb}mb-M&;K8 'iX9&55ek>=*D7w$xg|᭢M&=sMj?Ye_LXvb"̙ )osÝvH%&
{@G%u٬R]8ƖإjnV!.-Ee|l:5ymP]lD^*xKdK Pm_yV# !һxJ6,@
ra]zJ*hݱkSpgN cMK`1x"@B
O# (#/d_.L{ k r} IENDB` woob-139760e841ad4875b59fe11e052af1bb56dc06ea-modules-mailinator/modules/mailinator/module.py 0000664 0000000 0000000 00000006205 13435444765 0030750 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright(C) 2013 Vincent A
#
# This file is part of a weboob module.
#
# This weboob module is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This weboob module is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this weboob module. If not, see .
from weboob.tools.backend import Module, BackendConfig
from weboob.capabilities.messages import CapMessages, Thread, Message
from weboob.tools.value import Value
from .browser import MailinatorBrowser
__all__ = ['MailinatorModule']
# There is only one thread per inbox, and the thread id is the inbox name
# TODO but this can lead to bans if there are too many messages...
class MailinatorModule(Module, CapMessages):
NAME = 'mailinator'
DESCRIPTION = u'mailinator temp mailbox'
MAINTAINER = u'Vincent A'
EMAIL = 'dev@indigo.re'
LICENSE = 'AGPLv3+'
VERSION = '1.5'
BROWSER = MailinatorBrowser
CONFIG = BackendConfig(Value('inbox', label='Inbox', default=''))
def iter_threads(self):
inbox = self.config['inbox'].get()
if not inbox:
raise NotImplementedError()
else:
for d in self.browser.get_mails(inbox):
thread = Thread(d['id'])
thread.title = d['subject']
thread.flags = thread.IS_DISCUSSION
msg = self.make_message(d, thread)
if not msg.content:
self._fetch_content(msg)
thread.root = msg
yield thread
def _fetch_content(self, msg):
msg_type, msg.content = self.browser.get_mail_content(msg.id)
if msg_type == 'html':
msg.flags = Message.IS_HTML
def _get_messages_thread(self, inbox, thread):
first = True
for d in self.browser.get_mails(inbox):
msg = self.make_message(d, thread)
if first:
first = False
thread.root = msg
else:
msg.parent = thread.root
msg.parent.children.append(msg)
def get_thread(self, _id):
thread = Thread(_id)
thread.title = 'Mail for %s' % _id
thread.flags = thread.IS_DISCUSSION
self._get_messages_thread(_id, thread)
return thread
def make_message(self, d, thread):
msg = Message(thread, d['id'])
msg.children = []
msg.sender = d['from']
msg.flags = 0
msg.title = d['subject']
msg.date = d['datetime']
msg.receivers = [d['to']]
return msg
def fill_msg(self, msg, fields):
if 'content' in fields:
self._fetch_content(msg)
return msg
OBJECTS = {Message: fill_msg}
woob-139760e841ad4875b59fe11e052af1bb56dc06ea-modules-mailinator/modules/mailinator/test.py 0000664 0000000 0000000 00000002255 13435444765 0030443 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright(C) 2013 Vincent A
#
# This file is part of a weboob module.
#
# This weboob module is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This weboob module is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this weboob module. If not, see .
from weboob.tools.test import BackendTest
class MailinatorTest(BackendTest):
MODULE = 'mailinator'
def test_mailinator(self):
t = self.backend.get_thread('qwerty')
assert t
assert t.root
assert t.root.title
assert t.root.date
assert t.root.sender
assert t.root.receivers
self.backend.fillobj(t.root, ('content',))
assert t.root.content