Mercurial > pumpbridge
comparison src/google.coffee @ 7:2123f355ab68
go back interval or 15 min, delete credentials, layout
author | Mathias Gebbe <mgebbe@intevation.de> |
---|---|
date | Wed, 11 Jun 2014 02:32:53 +0200 |
parents | f352c74a6a5b |
children | ccf1d9e741bd |
comparison
equal
deleted
inserted
replaced
6:a94ac7c3b182 | 7:2123f355ab68 |
---|---|
19 querystring = require('querystring') | 19 querystring = require('querystring') |
20 | 20 |
21 config = Config.config | 21 config = Config.config |
22 | 22 |
23 bridgeid = config.bridgeid | 23 bridgeid = config.bridgeid |
24 interval = config.interval | |
24 API_KEY = config.gpAPI_KEY | 25 API_KEY = config.gpAPI_KEY |
25 CLIENTID = config.gpCLIENTID | 26 CLIENTID = config.gpCLIENTID |
26 CLIENTSECRET = config.gpCLIENTSECRET | 27 CLIENTSECRET = config.gpCLIENTSECRET |
27 | 28 |
28 ############### | 29 ############### |
30 ############### | 31 ############### |
31 sync = (user) -> | 32 sync = (user) -> |
32 return if not (user?) | 33 return if not (user?) |
33 me = user.user_pumpio | 34 me = user.user_pumpio |
34 id = user.user_ESN.substr(0,user.user_ESN.indexOf('@')) | 35 id = user.user_ESN.substr(0,user.user_ESN.indexOf('@')) |
36 if not (interval?) | |
37 interval = 15 * 60 * 1000 # 900 000 ms (15min) | |
35 | 38 |
36 async.waterfall [ | 39 async.waterfall [ |
37 (callback) -> | 40 (callback) -> |
38 updateToken(user,callback) | 41 updateToken(user,callback) |
39 (updateuser,callback) -> | 42 (updateuser,callback) -> |
51 async.waterfall [ | 54 async.waterfall [ |
52 (callback) -> | 55 (callback) -> |
53 FromESN.search {uid: post.id + "@google_to_" + me, recipientUser: me}, callback | 56 FromESN.search {uid: post.id + "@google_to_" + me, recipientUser: me}, callback |
54 (result, callback) -> | 57 (result, callback) -> |
55 return if result.length isnt 0 | 58 return if result.length isnt 0 |
56 Sync.postParser post, null, 'google', callback | 59 ti = new Date().getTime() - interval |
60 ts = Date.parse(post.published) | |
61 if (ts >= ti) | |
62 Sync.postParser post, null, 'google', callback | |
63 else | |
64 return | |
57 (parsed, callback) -> | 65 (parsed, callback) -> |
58 Pump.postUser bridgeid, me, parsed, callback | 66 Pump.postUser bridgeid, me, parsed, callback |
59 (pumppost, callback) -> | 67 (pumppost, callback) -> |
60 pumppost = JSON.parse(pumppost) | 68 pumppost = JSON.parse(pumppost) |
61 FromESN.create | 69 FromESN.create |