~libqtelegram-team/telegram-app/app-dev-remove-only-some-members

« back to all changes in this revision

Viewing changes to push.py

  • Committer: Michał Karnicki
  • Date: 2014-11-27 14:02:06 UTC
  • mfrom: (182.1.3 telegram-app-dev-args)
  • Revision ID: michal.karnicki@canonical.com-20141127140206-bgshvaqdckz31qnp
Tags: 0.9.11
Support opening of chat from notification.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
#key = message['loc_key']
16
16
#args = message['loc_args']
17
17
custom = message['custom']
 
18
#isChat = 'loc_key' in message and message['loc_key'] == 'CHAT_MESSAGE_TEXT'
 
19
chatId = str(custom['from_id']) if 'from_id' in custom else ''
 
20
chatId = str(custom['chat_id']) if 'chat_id' in custom else chatId
 
21
uri = 'telegram://chat/{0}'.format(chatId)
18
22
 
19
23
oldCard = data['notification']['card']
20
24
 
21
25
card = dict()
22
26
card['summary'] = oldCard['summary'] if 'summary' in oldCard else ''
23
27
card['body'] = oldCard['body'] if 'body' in oldCard else ''
24
 
card['actions'] = [ 'appid://com.ubuntu.telegram/telegram/@APP_VERSION@' ]
 
28
card['actions'] = [ uri ]
25
29
card['popup'] = True
26
30
card['persist'] = True
27
31
 
28
32
emblem = dict()
29
 
emblem['count'] = 0
30
 
emblem['visible'] = False
 
33
emblem['visible'] = True
 
34
emblem['count'] = data['notification']['emblem-counter']['count']
31
35
 
32
36
notification = dict()
33
 
tag = str(custom['from_id']) if 'from_id' in custom else ''
34
 
tag = str(custom['chat_id']) if 'chat_id' in custom else ''
35
 
notification['tag'] = tag
 
37
notification['tag'] = chatId
36
38
notification['card'] = card
37
39
notification['emblem-counter'] = emblem
38
40
notification['sound'] = True