add a root message for the "match" event

This commit is contained in:
Roger Philibert 2014-05-10 15:01:49 +02:00 committed by Romain Bignon
commit 0e38bab406
2 changed files with 20 additions and 5 deletions

View file

@ -100,7 +100,6 @@ class TinderBackend(BaseBackend, ICapMessages, ICapMessagesPost, ICapDating):
t = Thread(thread['_id'])
t.flags = Thread.IS_DISCUSSION
t.title = u'Discussion with %s' % thread['person']['name']
parent = None
contact = self.storage.get('contacts', t.id, default={'lastmsg': 0})
birthday = parse_date(thread['person']['birth_date']).date()
@ -108,6 +107,17 @@ class TinderBackend(BaseBackend, ICapMessages, ICapMessagesPost, ICapDating):
signature += u'\nLast ping: %s' % parse_date(thread['person']['ping_time']).strftime('%Y-%m-%d %H:%M:%S')
signature += u'\nPhotos:\n\t%s' % '\n\t'.join([photo['url'] for photo in thread['person']['photos']])
signature += u'\n\n%s' % thread['person']['bio']
t.root = Message(thread=t, id=1, title=t.title,
sender=unicode(thread['person']['name']),
receivers=[self.browser.my_name],
date=parse_date(thread['created_date']),
content=u'Match!',
children=[],
signature=signature,
flags=Message.IS_UNREAD if int(contact['lastmsg']) < 1 else 0)
parent = t.root
for msg in thread['messages']:
flags = 0
if int(contact['lastmsg']) < msg['timestamp']:
@ -124,10 +134,7 @@ class TinderBackend(BaseBackend, ICapMessages, ICapMessagesPost, ICapDating):
parent=parent,
signature=signature if msg['to'] == self.browser.my_id else u'',
flags=flags)
if parent is None:
t.root = msg
else:
parent.children.append(msg)
parent.children.append(msg)
parent = msg
yield t

View file

@ -18,6 +18,8 @@
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
import datetime
from dateutil.parser import parse as parse_date
import re
from weboob.tools.browser2 import DomainBrowser, HTMLPage, Profile
@ -116,6 +118,12 @@ class TinderBrowser(DomainBrowser):
return
profile = self.recs.pop()
birthday = parse_date(profile['birth_date'])
if birthday.date() > datetime.date(1994, 1, 1):
print self.request('/pass/%s' % profile['_id'])
return
resp = self.request('/like/%s' % profile['_id'])
if resp['match']: