add a root message for the "match" event
This commit is contained in:
parent
54f7643423
commit
0e38bab406
2 changed files with 20 additions and 5 deletions
|
|
@ -100,7 +100,6 @@ class TinderBackend(BaseBackend, ICapMessages, ICapMessagesPost, ICapDating):
|
||||||
t = Thread(thread['_id'])
|
t = Thread(thread['_id'])
|
||||||
t.flags = Thread.IS_DISCUSSION
|
t.flags = Thread.IS_DISCUSSION
|
||||||
t.title = u'Discussion with %s' % thread['person']['name']
|
t.title = u'Discussion with %s' % thread['person']['name']
|
||||||
parent = None
|
|
||||||
contact = self.storage.get('contacts', t.id, default={'lastmsg': 0})
|
contact = self.storage.get('contacts', t.id, default={'lastmsg': 0})
|
||||||
|
|
||||||
birthday = parse_date(thread['person']['birth_date']).date()
|
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'\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'\nPhotos:\n\t%s' % '\n\t'.join([photo['url'] for photo in thread['person']['photos']])
|
||||||
signature += u'\n\n%s' % thread['person']['bio']
|
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']:
|
for msg in thread['messages']:
|
||||||
flags = 0
|
flags = 0
|
||||||
if int(contact['lastmsg']) < msg['timestamp']:
|
if int(contact['lastmsg']) < msg['timestamp']:
|
||||||
|
|
@ -124,10 +134,7 @@ class TinderBackend(BaseBackend, ICapMessages, ICapMessagesPost, ICapDating):
|
||||||
parent=parent,
|
parent=parent,
|
||||||
signature=signature if msg['to'] == self.browser.my_id else u'',
|
signature=signature if msg['to'] == self.browser.my_id else u'',
|
||||||
flags=flags)
|
flags=flags)
|
||||||
if parent is None:
|
parent.children.append(msg)
|
||||||
t.root = msg
|
|
||||||
else:
|
|
||||||
parent.children.append(msg)
|
|
||||||
parent = msg
|
parent = msg
|
||||||
|
|
||||||
yield t
|
yield t
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,8 @@
|
||||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
|
import datetime
|
||||||
|
from dateutil.parser import parse as parse_date
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from weboob.tools.browser2 import DomainBrowser, HTMLPage, Profile
|
from weboob.tools.browser2 import DomainBrowser, HTMLPage, Profile
|
||||||
|
|
@ -116,6 +118,12 @@ class TinderBrowser(DomainBrowser):
|
||||||
return
|
return
|
||||||
|
|
||||||
profile = self.recs.pop()
|
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'])
|
resp = self.request('/like/%s' % profile['_id'])
|
||||||
|
|
||||||
if resp['match']:
|
if resp['match']:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue