Mercurial > pumpbridge
annotate src/facebook.coffee @ 20:9436298e6d78
wrong callback
author | Mathias Gebbe <mgebbe@intevation.de> |
---|---|
date | Fri, 13 Jun 2014 18:29:55 +0200 |
parents | a52b5b244e51 |
children | b90e6df48d2d |
rev | line source |
---|---|
0
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
1 # Copyright (C) 2014 by Intevation GmbH |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
2 # Author: Mathias Gebbe <mgebbe@intevation.de> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
3 # |
3 | 4 # This file is Free Software under the Apache License, Version 2.0; |
5 # and comes with NO WARRANTY! | |
6 # See the documentation coming with pumpbridge for details. | |
0
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
7 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
8 https = require("https") |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
9 async = require("async") |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
10 _ = require("underscore") |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
11 Routes = require("./routes") |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
12 FB = require('fb') |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
13 EdgeControl = require("./edgecontrol") |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
14 Edge = require("./edge") |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
15 CommentToESN = require("./commenttoesn") |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
16 ToESN = require("./toESN") |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
17 FromESN = require("./fromESN") |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
18 Pump = require("./pumpio") |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
19 User = require("./user") |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
20 Sync = require("./sync") |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
21 Usermap = require("./usermap") |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
22 Config = require("./config") |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
23 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
24 config = Config.config |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
25 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
26 bridgeid = config.bridgeid |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
27 secret = config.fbSECRET |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
28 appid = config.fbAPPID |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
29 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
30 ####################################### |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
31 ###### facebook sync ##### |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
32 ####################################### |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
33 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
34 sync = (user) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
35 me = user.user_pumpio |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
36 id = user.user_ESN.substr(0,user.user_ESN.indexOf('@')) |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
37 pubuser = "" |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
38 post = "" |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
39 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
40 # GET NEW POSTS |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
41 #### |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
42 async.waterfall [ |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
43 (callback) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
44 getFriends(user) |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
45 getPages(user) |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
46 getUser(user) |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
47 getStream user,callback |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
48 ], (err, posts) -> |
17
a52b5b244e51
removed unnecessary underscore and replaced it with async
Mathias Gebbe <mgebbe@intevation.de>
parents:
14
diff
changeset
|
49 return if not posts? or posts.length is 0 |
0
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
50 #console.log JSON.stringify(posts) # all posts from network (100) |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
51 async.eachSeries posts, ((post, callback) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
52 async.waterfall [ |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
53 (callback) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
54 FromESN.search {uid: post.id + "@facebook_to_" + me, recipientUser: me}, callback |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
55 (result, callback) -> |
7
2123f355ab68
go back interval or 15 min, delete credentials, layout
Mathias Gebbe <mgebbe@intevation.de>
parents:
4
diff
changeset
|
56 return if result.length isnt 0 or post.from.id is id |
0
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
57 #console.log "postid: " + post.from.id + "id:" + id |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
58 # if this is your own post return!!! |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
59 getPublicUserInfo(post.from.id , callback) |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
60 (pubuser, callback) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
61 pubuser = pubuser |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
62 User.search {id: pubuser.id + "@facebook"}, callback |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
63 (dbuser, callback) -> |
8
6fd0a307850f
check empty strings and users
Mathias Gebbe <mgebbe@intevation.de>
parents:
7
diff
changeset
|
64 if (dbuser[0]?) |
6fd0a307850f
check empty strings and users
Mathias Gebbe <mgebbe@intevation.de>
parents:
7
diff
changeset
|
65 Sync.postParser post, dbuser[0], 'facebook', callback |
6fd0a307850f
check empty strings and users
Mathias Gebbe <mgebbe@intevation.de>
parents:
7
diff
changeset
|
66 else |
6fd0a307850f
check empty strings and users
Mathias Gebbe <mgebbe@intevation.de>
parents:
7
diff
changeset
|
67 return |
0
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
68 (parsed, callback) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
69 Pump.postUser bridgeid, me, parsed, callback |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
70 (pumppost, callback) -> |
17
a52b5b244e51
removed unnecessary underscore and replaced it with async
Mathias Gebbe <mgebbe@intevation.de>
parents:
14
diff
changeset
|
71 return if not pumppost? or not post.actions[0]? |
0
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
72 pumppost = JSON.parse(pumppost) |
17
a52b5b244e51
removed unnecessary underscore and replaced it with async
Mathias Gebbe <mgebbe@intevation.de>
parents:
14
diff
changeset
|
73 postlink = post.actions[0].link |
0
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
74 FromESN.create |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
75 postid: post.id + "@facebook" |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
76 sourceUser: post.from.id |
7
2123f355ab68
go back interval or 15 min, delete credentials, layout
Mathias Gebbe <mgebbe@intevation.de>
parents:
4
diff
changeset
|
77 sourcePost: postlink |
0
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
78 pumpPost: pumppost.object.id |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
79 recipientUser: me |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
80 created: Date.now() |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
81 , callback |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
82 ], (err, result) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
83 callback null, 'done' |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
84 ), (err) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
85 if err |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
86 console.log 'one post fail to process' |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
87 else |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
88 console.log 'all posts processed' |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
89 return |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
90 #### |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
91 # TO DO: GET NEW COMMENTS |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
92 # for each fromESN check the comments |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
93 # if comment author = me |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
94 # post comment |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
95 # if comment author != me |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
96 # post comment with 'user schreibt' |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
97 async.waterfall [ |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
98 (callback) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
99 FromESN.search {recipientUser: me}, callback |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
100 (allESN, callback) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
101 async.each allESN, ((fromesn, callback) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
102 async.waterfall [ |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
103 (cb) -> |
8
6fd0a307850f
check empty strings and users
Mathias Gebbe <mgebbe@intevation.de>
parents:
7
diff
changeset
|
104 if fromesn.sourcePost.indexOf('www.facebook.com') is -1 |
6fd0a307850f
check empty strings and users
Mathias Gebbe <mgebbe@intevation.de>
parents:
7
diff
changeset
|
105 return |
0
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
106 Usermap.search {id: me + '_to_' + me}, cb |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
107 (pumpuser, cb) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
108 Pump.getNote(pumpuser[0], fromesn.pumpPost, cb) |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
109 (note, cb) -> |
8
6fd0a307850f
check empty strings and users
Mathias Gebbe <mgebbe@intevation.de>
parents:
7
diff
changeset
|
110 return if not (note?) |
4
f352c74a6a5b
remove typeof, corrected facebooks toESN entrys
Mathias Gebbe <mgebbe@intevation.de>
parents:
3
diff
changeset
|
111 if note.liked is true |
0
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
112 obj = fromesn.postid.substr(0,fromesn.postid.indexOf('@')) |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
113 postLike(user,obj) |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
114 if (note.replies?) |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
115 reply = JSON.stringify(note.replies) |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
116 rep = JSON.parse(reply) |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
117 if rep.totalItems >= 1 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
118 async.each rep.items, ((r, callback) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
119 if r.author.id is "acct:" + me |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
120 obj = fromesn.postid.substr(0,fromesn.postid.indexOf('@')) |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
121 postComment(user, obj, r.id , r.content) |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
122 callback null, 'done' |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
123 ), (err) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
124 cb null, 'done' |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
125 ], (err, result) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
126 #done |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
127 ), (err) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
128 callback null, 'done' |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
129 ], (err, result) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
130 #done |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
131 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
132 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
133 # GET PUBLIC PUMP POSTS AND POST THEM |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
134 async.waterfall [ |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
135 (callback) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
136 Usermap.search {id: me + '_to_' + me}, callback |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
137 (user, callback) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
138 Pump.getUserFeed(user[0],callback) |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
139 (feed, callback) -> |
7
2123f355ab68
go back interval or 15 min, delete credentials, layout
Mathias Gebbe <mgebbe@intevation.de>
parents:
4
diff
changeset
|
140 interval = config.interval |
2123f355ab68
go back interval or 15 min, delete credentials, layout
Mathias Gebbe <mgebbe@intevation.de>
parents:
4
diff
changeset
|
141 if not (interval?) |
2123f355ab68
go back interval or 15 min, delete credentials, layout
Mathias Gebbe <mgebbe@intevation.de>
parents:
4
diff
changeset
|
142 interval = 15 * 60 * 1000 # 900 000 ms (15min) |
2123f355ab68
go back interval or 15 min, delete credentials, layout
Mathias Gebbe <mgebbe@intevation.de>
parents:
4
diff
changeset
|
143 ti = new Date().getTime() - interval |
0
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
144 async.eachSeries feed.items, ((post, callback) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
145 # do for each post |
7
2123f355ab68
go back interval or 15 min, delete credentials, layout
Mathias Gebbe <mgebbe@intevation.de>
parents:
4
diff
changeset
|
146 ts = Date.parse(post.updated) |
2123f355ab68
go back interval or 15 min, delete credentials, layout
Mathias Gebbe <mgebbe@intevation.de>
parents:
4
diff
changeset
|
147 if (ts >= ti and post.verb is "post" or post.verb is "share") and (post.object.objectType is "note" or post.object.objectType is "image") and (Pump.isPublicActivity(post)) and not (post.object.deleted?) |
0
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
148 postStream(user,post) |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
149 callback null, 'done' |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
150 ), (err) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
151 callback null, 'done' |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
152 ],(err, result) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
153 #console.log 'done.' |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
154 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
155 return |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
156 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
157 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
158 ####################################### |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
159 ###### get user facebook ##### |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
160 ####################################### |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
161 getUser = (user) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
162 data = "" |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
163 id = user.user_ESN.substr(0,user.user_ESN.indexOf('@')) |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
164 token = user.oauth_token |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
165 fields = 'fields=id,name,picture,link' |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
166 options = |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
167 host: 'graph.facebook.com' |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
168 port: 443 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
169 path: '/' + id + '?access_token=' + token + '&' + fields |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
170 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
171 https.get(options, (res) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
172 #console.log "Got response: " + res.statusCode |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
173 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
174 res.on "data", (chunk) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
175 data += chunk |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
176 return |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
177 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
178 res.on "end", () -> |
12
f190abf340ef
fixed some problems with facebook (caused by developers.facebook.com) removed fql :D
Mathias Gebbe <mgebbe@intevation.de>
parents:
11
diff
changeset
|
179 if (data?) |
f190abf340ef
fixed some problems with facebook (caused by developers.facebook.com) removed fql :D
Mathias Gebbe <mgebbe@intevation.de>
parents:
11
diff
changeset
|
180 try |
f190abf340ef
fixed some problems with facebook (caused by developers.facebook.com) removed fql :D
Mathias Gebbe <mgebbe@intevation.de>
parents:
11
diff
changeset
|
181 user = JSON.parse(data) |
f190abf340ef
fixed some problems with facebook (caused by developers.facebook.com) removed fql :D
Mathias Gebbe <mgebbe@intevation.de>
parents:
11
diff
changeset
|
182 ### with app id ### |
f190abf340ef
fixed some problems with facebook (caused by developers.facebook.com) removed fql :D
Mathias Gebbe <mgebbe@intevation.de>
parents:
11
diff
changeset
|
183 Routes.updateUserDB(user.id+'@facebook',user.name,user.name,user.link,user.picture.data.url) if user? |
f190abf340ef
fixed some problems with facebook (caused by developers.facebook.com) removed fql :D
Mathias Gebbe <mgebbe@intevation.de>
parents:
11
diff
changeset
|
184 ### with link ### |
f190abf340ef
fixed some problems with facebook (caused by developers.facebook.com) removed fql :D
Mathias Gebbe <mgebbe@intevation.de>
parents:
11
diff
changeset
|
185 Routes.updateUserDB(user.link,user.name,user.name,user.link,user.picture.data.url) if user? |
f190abf340ef
fixed some problems with facebook (caused by developers.facebook.com) removed fql :D
Mathias Gebbe <mgebbe@intevation.de>
parents:
11
diff
changeset
|
186 catch err |
f190abf340ef
fixed some problems with facebook (caused by developers.facebook.com) removed fql :D
Mathias Gebbe <mgebbe@intevation.de>
parents:
11
diff
changeset
|
187 console.log "User Error" |
0
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
188 return |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
189 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
190 ).on "error", (e) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
191 console.log "Got error: " + e.message |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
192 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
193 return |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
194 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
195 ############################################## |
12
f190abf340ef
fixed some problems with facebook (caused by developers.facebook.com) removed fql :D
Mathias Gebbe <mgebbe@intevation.de>
parents:
11
diff
changeset
|
196 ###### get facebook likes ###### |
0
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
197 ############################################## |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
198 getFriends = (user) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
199 me = user.user_pumpio |
12
f190abf340ef
fixed some problems with facebook (caused by developers.facebook.com) removed fql :D
Mathias Gebbe <mgebbe@intevation.de>
parents:
11
diff
changeset
|
200 token = user.oauth_token |
f190abf340ef
fixed some problems with facebook (caused by developers.facebook.com) removed fql :D
Mathias Gebbe <mgebbe@intevation.de>
parents:
11
diff
changeset
|
201 |
f190abf340ef
fixed some problems with facebook (caused by developers.facebook.com) removed fql :D
Mathias Gebbe <mgebbe@intevation.de>
parents:
11
diff
changeset
|
202 FB.setAccessToken token |
f190abf340ef
fixed some problems with facebook (caused by developers.facebook.com) removed fql :D
Mathias Gebbe <mgebbe@intevation.de>
parents:
11
diff
changeset
|
203 |
f190abf340ef
fixed some problems with facebook (caused by developers.facebook.com) removed fql :D
Mathias Gebbe <mgebbe@intevation.de>
parents:
11
diff
changeset
|
204 FB.api "me/friends?limit=5000", |
f190abf340ef
fixed some problems with facebook (caused by developers.facebook.com) removed fql :D
Mathias Gebbe <mgebbe@intevation.de>
parents:
11
diff
changeset
|
205 fields: [ |
f190abf340ef
fixed some problems with facebook (caused by developers.facebook.com) removed fql :D
Mathias Gebbe <mgebbe@intevation.de>
parents:
11
diff
changeset
|
206 "id" |
f190abf340ef
fixed some problems with facebook (caused by developers.facebook.com) removed fql :D
Mathias Gebbe <mgebbe@intevation.de>
parents:
11
diff
changeset
|
207 ] |
f190abf340ef
fixed some problems with facebook (caused by developers.facebook.com) removed fql :D
Mathias Gebbe <mgebbe@intevation.de>
parents:
11
diff
changeset
|
208 , (res) -> |
f190abf340ef
fixed some problems with facebook (caused by developers.facebook.com) removed fql :D
Mathias Gebbe <mgebbe@intevation.de>
parents:
11
diff
changeset
|
209 if not res or res.error |
f190abf340ef
fixed some problems with facebook (caused by developers.facebook.com) removed fql :D
Mathias Gebbe <mgebbe@intevation.de>
parents:
11
diff
changeset
|
210 console.log (if not res then "error occurred" else res.error) |
f190abf340ef
fixed some problems with facebook (caused by developers.facebook.com) removed fql :D
Mathias Gebbe <mgebbe@intevation.de>
parents:
11
diff
changeset
|
211 |
17
a52b5b244e51
removed unnecessary underscore and replaced it with async
Mathias Gebbe <mgebbe@intevation.de>
parents:
14
diff
changeset
|
212 async.each res.data, ((person, cb) -> |
12
f190abf340ef
fixed some problems with facebook (caused by developers.facebook.com) removed fql :D
Mathias Gebbe <mgebbe@intevation.de>
parents:
11
diff
changeset
|
213 getUserById(me,person.id,token) |
17
a52b5b244e51
removed unnecessary underscore and replaced it with async
Mathias Gebbe <mgebbe@intevation.de>
parents:
14
diff
changeset
|
214 cb() |
12
f190abf340ef
fixed some problems with facebook (caused by developers.facebook.com) removed fql :D
Mathias Gebbe <mgebbe@intevation.de>
parents:
11
diff
changeset
|
215 return |
17
a52b5b244e51
removed unnecessary underscore and replaced it with async
Mathias Gebbe <mgebbe@intevation.de>
parents:
14
diff
changeset
|
216 ), (err) -> |
a52b5b244e51
removed unnecessary underscore and replaced it with async
Mathias Gebbe <mgebbe@intevation.de>
parents:
14
diff
changeset
|
217 return |
12
f190abf340ef
fixed some problems with facebook (caused by developers.facebook.com) removed fql :D
Mathias Gebbe <mgebbe@intevation.de>
parents:
11
diff
changeset
|
218 return |
f190abf340ef
fixed some problems with facebook (caused by developers.facebook.com) removed fql :D
Mathias Gebbe <mgebbe@intevation.de>
parents:
11
diff
changeset
|
219 |
f190abf340ef
fixed some problems with facebook (caused by developers.facebook.com) removed fql :D
Mathias Gebbe <mgebbe@intevation.de>
parents:
11
diff
changeset
|
220 ####################################### |
f190abf340ef
fixed some problems with facebook (caused by developers.facebook.com) removed fql :D
Mathias Gebbe <mgebbe@intevation.de>
parents:
11
diff
changeset
|
221 ###### get user facebook3 ##### |
f190abf340ef
fixed some problems with facebook (caused by developers.facebook.com) removed fql :D
Mathias Gebbe <mgebbe@intevation.de>
parents:
11
diff
changeset
|
222 ####################################### |
f190abf340ef
fixed some problems with facebook (caused by developers.facebook.com) removed fql :D
Mathias Gebbe <mgebbe@intevation.de>
parents:
11
diff
changeset
|
223 getFriends3 = (user) -> |
f190abf340ef
fixed some problems with facebook (caused by developers.facebook.com) removed fql :D
Mathias Gebbe <mgebbe@intevation.de>
parents:
11
diff
changeset
|
224 data = "" |
f190abf340ef
fixed some problems with facebook (caused by developers.facebook.com) removed fql :D
Mathias Gebbe <mgebbe@intevation.de>
parents:
11
diff
changeset
|
225 id = user.user_ESN.substr(0,user.user_ESN.indexOf('@')) |
f190abf340ef
fixed some problems with facebook (caused by developers.facebook.com) removed fql :D
Mathias Gebbe <mgebbe@intevation.de>
parents:
11
diff
changeset
|
226 token = user.oauth_token |
f190abf340ef
fixed some problems with facebook (caused by developers.facebook.com) removed fql :D
Mathias Gebbe <mgebbe@intevation.de>
parents:
11
diff
changeset
|
227 options = |
f190abf340ef
fixed some problems with facebook (caused by developers.facebook.com) removed fql :D
Mathias Gebbe <mgebbe@intevation.de>
parents:
11
diff
changeset
|
228 host: 'graph.facebook.com' |
f190abf340ef
fixed some problems with facebook (caused by developers.facebook.com) removed fql :D
Mathias Gebbe <mgebbe@intevation.de>
parents:
11
diff
changeset
|
229 port: 443 |
f190abf340ef
fixed some problems with facebook (caused by developers.facebook.com) removed fql :D
Mathias Gebbe <mgebbe@intevation.de>
parents:
11
diff
changeset
|
230 path: 'me/friends?limit=5000&access_token=' + token + '&client_id='+ appid + '&client_secret=' + secret |
f190abf340ef
fixed some problems with facebook (caused by developers.facebook.com) removed fql :D
Mathias Gebbe <mgebbe@intevation.de>
parents:
11
diff
changeset
|
231 |
f190abf340ef
fixed some problems with facebook (caused by developers.facebook.com) removed fql :D
Mathias Gebbe <mgebbe@intevation.de>
parents:
11
diff
changeset
|
232 https.get(options, (res) -> |
f190abf340ef
fixed some problems with facebook (caused by developers.facebook.com) removed fql :D
Mathias Gebbe <mgebbe@intevation.de>
parents:
11
diff
changeset
|
233 console.log "Got response: " + res.statusCode |
f190abf340ef
fixed some problems with facebook (caused by developers.facebook.com) removed fql :D
Mathias Gebbe <mgebbe@intevation.de>
parents:
11
diff
changeset
|
234 |
f190abf340ef
fixed some problems with facebook (caused by developers.facebook.com) removed fql :D
Mathias Gebbe <mgebbe@intevation.de>
parents:
11
diff
changeset
|
235 res.on "data", (chunk) -> |
f190abf340ef
fixed some problems with facebook (caused by developers.facebook.com) removed fql :D
Mathias Gebbe <mgebbe@intevation.de>
parents:
11
diff
changeset
|
236 data += chunk |
f190abf340ef
fixed some problems with facebook (caused by developers.facebook.com) removed fql :D
Mathias Gebbe <mgebbe@intevation.de>
parents:
11
diff
changeset
|
237 return |
f190abf340ef
fixed some problems with facebook (caused by developers.facebook.com) removed fql :D
Mathias Gebbe <mgebbe@intevation.de>
parents:
11
diff
changeset
|
238 |
f190abf340ef
fixed some problems with facebook (caused by developers.facebook.com) removed fql :D
Mathias Gebbe <mgebbe@intevation.de>
parents:
11
diff
changeset
|
239 res.on "end", () -> |
f190abf340ef
fixed some problems with facebook (caused by developers.facebook.com) removed fql :D
Mathias Gebbe <mgebbe@intevation.de>
parents:
11
diff
changeset
|
240 console.log data |
f190abf340ef
fixed some problems with facebook (caused by developers.facebook.com) removed fql :D
Mathias Gebbe <mgebbe@intevation.de>
parents:
11
diff
changeset
|
241 return |
f190abf340ef
fixed some problems with facebook (caused by developers.facebook.com) removed fql :D
Mathias Gebbe <mgebbe@intevation.de>
parents:
11
diff
changeset
|
242 |
f190abf340ef
fixed some problems with facebook (caused by developers.facebook.com) removed fql :D
Mathias Gebbe <mgebbe@intevation.de>
parents:
11
diff
changeset
|
243 ).on "error", (e) -> |
f190abf340ef
fixed some problems with facebook (caused by developers.facebook.com) removed fql :D
Mathias Gebbe <mgebbe@intevation.de>
parents:
11
diff
changeset
|
244 console.log "Got error: " + e.message |
f190abf340ef
fixed some problems with facebook (caused by developers.facebook.com) removed fql :D
Mathias Gebbe <mgebbe@intevation.de>
parents:
11
diff
changeset
|
245 |
f190abf340ef
fixed some problems with facebook (caused by developers.facebook.com) removed fql :D
Mathias Gebbe <mgebbe@intevation.de>
parents:
11
diff
changeset
|
246 return |
f190abf340ef
fixed some problems with facebook (caused by developers.facebook.com) removed fql :D
Mathias Gebbe <mgebbe@intevation.de>
parents:
11
diff
changeset
|
247 |
f190abf340ef
fixed some problems with facebook (caused by developers.facebook.com) removed fql :D
Mathias Gebbe <mgebbe@intevation.de>
parents:
11
diff
changeset
|
248 ############################################## |
f190abf340ef
fixed some problems with facebook (caused by developers.facebook.com) removed fql :D
Mathias Gebbe <mgebbe@intevation.de>
parents:
11
diff
changeset
|
249 ###### get facebook friends2 ###### |
f190abf340ef
fixed some problems with facebook (caused by developers.facebook.com) removed fql :D
Mathias Gebbe <mgebbe@intevation.de>
parents:
11
diff
changeset
|
250 ############################################## |
f190abf340ef
fixed some problems with facebook (caused by developers.facebook.com) removed fql :D
Mathias Gebbe <mgebbe@intevation.de>
parents:
11
diff
changeset
|
251 getFriends2 = (user) -> |
f190abf340ef
fixed some problems with facebook (caused by developers.facebook.com) removed fql :D
Mathias Gebbe <mgebbe@intevation.de>
parents:
11
diff
changeset
|
252 me = user.user_pumpio |
11
9d17cb5147ca
back to fql, added fb user_friends permission
Mathias Gebbe <mgebbe@intevation.de>
parents:
10
diff
changeset
|
253 id = user.user_ESN.substr(0,user.user_ESN.indexOf('@')) |
0
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
254 token = user.oauth_token |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
255 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
256 EdgeControl.removeEdges(me,'@facebook') |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
257 EdgeControl.removeEdges(me,'www.facebook.com') |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
258 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
259 FB.setAccessToken token |
11
9d17cb5147ca
back to fql, added fb user_friends permission
Mathias Gebbe <mgebbe@intevation.de>
parents:
10
diff
changeset
|
260 FB.api "fql", |
9d17cb5147ca
back to fql, added fb user_friends permission
Mathias Gebbe <mgebbe@intevation.de>
parents:
10
diff
changeset
|
261 q: "SELECT uid2 FROM friend WHERE uid1 = me()" |
0
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
262 , (res) -> |
11
9d17cb5147ca
back to fql, added fb user_friends permission
Mathias Gebbe <mgebbe@intevation.de>
parents:
10
diff
changeset
|
263 console.log res |
0
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
264 if not res or res.error |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
265 console.log (if not res then "error occurred" else res.error) |
11
9d17cb5147ca
back to fql, added fb user_friends permission
Mathias Gebbe <mgebbe@intevation.de>
parents:
10
diff
changeset
|
266 return |
0
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
267 |
17
a52b5b244e51
removed unnecessary underscore and replaced it with async
Mathias Gebbe <mgebbe@intevation.de>
parents:
14
diff
changeset
|
268 async.each res.data, ((user, cb) -> |
12
f190abf340ef
fixed some problems with facebook (caused by developers.facebook.com) removed fql :D
Mathias Gebbe <mgebbe@intevation.de>
parents:
11
diff
changeset
|
269 getUserById(me,user.uid2,token) |
17
a52b5b244e51
removed unnecessary underscore and replaced it with async
Mathias Gebbe <mgebbe@intevation.de>
parents:
14
diff
changeset
|
270 cb() |
0
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
271 return |
17
a52b5b244e51
removed unnecessary underscore and replaced it with async
Mathias Gebbe <mgebbe@intevation.de>
parents:
14
diff
changeset
|
272 ), (err) -> |
a52b5b244e51
removed unnecessary underscore and replaced it with async
Mathias Gebbe <mgebbe@intevation.de>
parents:
14
diff
changeset
|
273 return |
11
9d17cb5147ca
back to fql, added fb user_friends permission
Mathias Gebbe <mgebbe@intevation.de>
parents:
10
diff
changeset
|
274 return |
9d17cb5147ca
back to fql, added fb user_friends permission
Mathias Gebbe <mgebbe@intevation.de>
parents:
10
diff
changeset
|
275 |
10
ccf1d9e741bd
corrected google apikey query, removed facebook query language
Mathias Gebbe <mgebbe@intevation.de>
parents:
8
diff
changeset
|
276 return |
ccf1d9e741bd
corrected google apikey query, removed facebook query language
Mathias Gebbe <mgebbe@intevation.de>
parents:
8
diff
changeset
|
277 |
ccf1d9e741bd
corrected google apikey query, removed facebook query language
Mathias Gebbe <mgebbe@intevation.de>
parents:
8
diff
changeset
|
278 |
ccf1d9e741bd
corrected google apikey query, removed facebook query language
Mathias Gebbe <mgebbe@intevation.de>
parents:
8
diff
changeset
|
279 ############################################## |
ccf1d9e741bd
corrected google apikey query, removed facebook query language
Mathias Gebbe <mgebbe@intevation.de>
parents:
8
diff
changeset
|
280 ###### get facebook likes ###### |
ccf1d9e741bd
corrected google apikey query, removed facebook query language
Mathias Gebbe <mgebbe@intevation.de>
parents:
8
diff
changeset
|
281 ############################################## |
ccf1d9e741bd
corrected google apikey query, removed facebook query language
Mathias Gebbe <mgebbe@intevation.de>
parents:
8
diff
changeset
|
282 getPages = (user) -> |
ccf1d9e741bd
corrected google apikey query, removed facebook query language
Mathias Gebbe <mgebbe@intevation.de>
parents:
8
diff
changeset
|
283 me = user.user_pumpio |
ccf1d9e741bd
corrected google apikey query, removed facebook query language
Mathias Gebbe <mgebbe@intevation.de>
parents:
8
diff
changeset
|
284 token = user.oauth_token |
ccf1d9e741bd
corrected google apikey query, removed facebook query language
Mathias Gebbe <mgebbe@intevation.de>
parents:
8
diff
changeset
|
285 |
ccf1d9e741bd
corrected google apikey query, removed facebook query language
Mathias Gebbe <mgebbe@intevation.de>
parents:
8
diff
changeset
|
286 FB.setAccessToken token |
ccf1d9e741bd
corrected google apikey query, removed facebook query language
Mathias Gebbe <mgebbe@intevation.de>
parents:
8
diff
changeset
|
287 |
ccf1d9e741bd
corrected google apikey query, removed facebook query language
Mathias Gebbe <mgebbe@intevation.de>
parents:
8
diff
changeset
|
288 FB.api "me/likes?limit=5000", |
ccf1d9e741bd
corrected google apikey query, removed facebook query language
Mathias Gebbe <mgebbe@intevation.de>
parents:
8
diff
changeset
|
289 fields: [ |
ccf1d9e741bd
corrected google apikey query, removed facebook query language
Mathias Gebbe <mgebbe@intevation.de>
parents:
8
diff
changeset
|
290 "id" |
ccf1d9e741bd
corrected google apikey query, removed facebook query language
Mathias Gebbe <mgebbe@intevation.de>
parents:
8
diff
changeset
|
291 ] |
ccf1d9e741bd
corrected google apikey query, removed facebook query language
Mathias Gebbe <mgebbe@intevation.de>
parents:
8
diff
changeset
|
292 , (res) -> |
ccf1d9e741bd
corrected google apikey query, removed facebook query language
Mathias Gebbe <mgebbe@intevation.de>
parents:
8
diff
changeset
|
293 if not res or res.error |
ccf1d9e741bd
corrected google apikey query, removed facebook query language
Mathias Gebbe <mgebbe@intevation.de>
parents:
8
diff
changeset
|
294 console.log (if not res then "error occurred" else res.error) |
ccf1d9e741bd
corrected google apikey query, removed facebook query language
Mathias Gebbe <mgebbe@intevation.de>
parents:
8
diff
changeset
|
295 |
17
a52b5b244e51
removed unnecessary underscore and replaced it with async
Mathias Gebbe <mgebbe@intevation.de>
parents:
14
diff
changeset
|
296 async.each res.data, ((page,cb) -> |
11
9d17cb5147ca
back to fql, added fb user_friends permission
Mathias Gebbe <mgebbe@intevation.de>
parents:
10
diff
changeset
|
297 getUserById(me,page.id,token) |
17
a52b5b244e51
removed unnecessary underscore and replaced it with async
Mathias Gebbe <mgebbe@intevation.de>
parents:
14
diff
changeset
|
298 cb() |
10
ccf1d9e741bd
corrected google apikey query, removed facebook query language
Mathias Gebbe <mgebbe@intevation.de>
parents:
8
diff
changeset
|
299 return |
17
a52b5b244e51
removed unnecessary underscore and replaced it with async
Mathias Gebbe <mgebbe@intevation.de>
parents:
14
diff
changeset
|
300 ), (err) -> |
a52b5b244e51
removed unnecessary underscore and replaced it with async
Mathias Gebbe <mgebbe@intevation.de>
parents:
14
diff
changeset
|
301 return |
0
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
302 return |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
303 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
304 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
305 ####################################### |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
306 ###### get facebook stream ###### |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
307 ####################################### |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
308 getStream = (user,callback) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
309 token = user.oauth_token |
7
2123f355ab68
go back interval or 15 min, delete credentials, layout
Mathias Gebbe <mgebbe@intevation.de>
parents:
4
diff
changeset
|
310 interval = config.interval |
2123f355ab68
go back interval or 15 min, delete credentials, layout
Mathias Gebbe <mgebbe@intevation.de>
parents:
4
diff
changeset
|
311 if not (interval?) |
2123f355ab68
go back interval or 15 min, delete credentials, layout
Mathias Gebbe <mgebbe@intevation.de>
parents:
4
diff
changeset
|
312 interval = 15 * 60 * 1000 # 900 000 ms (15min) |
2123f355ab68
go back interval or 15 min, delete credentials, layout
Mathias Gebbe <mgebbe@intevation.de>
parents:
4
diff
changeset
|
313 ts = Math.round(((new Date()).getTime() - interval)/1000) |
12
f190abf340ef
fixed some problems with facebook (caused by developers.facebook.com) removed fql :D
Mathias Gebbe <mgebbe@intevation.de>
parents:
11
diff
changeset
|
314 |
0
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
315 FB.setAccessToken token |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
316 |
17
a52b5b244e51
removed unnecessary underscore and replaced it with async
Mathias Gebbe <mgebbe@intevation.de>
parents:
14
diff
changeset
|
317 FB.api "me/home?limit=10&?since="+ts, |
0
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
318 fields: [ |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
319 "id" |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
320 "type" |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
321 "from" |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
322 "privacy" |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
323 "message" |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
324 "picture" |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
325 "link" |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
326 "status_type" |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
327 "caption" |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
328 "created_time" |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
329 "updated_time" |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
330 "picture" |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
331 "actions" |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
332 ] |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
333 , (res) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
334 if not res or res.error |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
335 console.log (if not res then "error occurred" else res.error) |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
336 callback null, null |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
337 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
338 newposts = new Array() |
17
a52b5b244e51
removed unnecessary underscore and replaced it with async
Mathias Gebbe <mgebbe@intevation.de>
parents:
14
diff
changeset
|
339 async.each res.data, ((post,cb) -> |
0
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
340 newposts.push(post) if (post.type is 'status' or post.type is 'photo' or post.type is 'link' or post.type is 'video') and (post.status_type is 'mobile_status_update' or post.status_type is 'added_photos' or post.status_type is 'shared_story') |
17
a52b5b244e51
removed unnecessary underscore and replaced it with async
Mathias Gebbe <mgebbe@intevation.de>
parents:
14
diff
changeset
|
341 cb() |
a52b5b244e51
removed unnecessary underscore and replaced it with async
Mathias Gebbe <mgebbe@intevation.de>
parents:
14
diff
changeset
|
342 return |
a52b5b244e51
removed unnecessary underscore and replaced it with async
Mathias Gebbe <mgebbe@intevation.de>
parents:
14
diff
changeset
|
343 ), (err) -> |
a52b5b244e51
removed unnecessary underscore and replaced it with async
Mathias Gebbe <mgebbe@intevation.de>
parents:
14
diff
changeset
|
344 callback null, newposts.reverse() |
a52b5b244e51
removed unnecessary underscore and replaced it with async
Mathias Gebbe <mgebbe@intevation.de>
parents:
14
diff
changeset
|
345 return |
a52b5b244e51
removed unnecessary underscore and replaced it with async
Mathias Gebbe <mgebbe@intevation.de>
parents:
14
diff
changeset
|
346 return |
0
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
347 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
348 ####################################### |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
349 ###### post facebook stream ###### |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
350 ####################################### |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
351 postStream = (user, post) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
352 token = user.oauth_token |
7
2123f355ab68
go back interval or 15 min, delete credentials, layout
Mathias Gebbe <mgebbe@intevation.de>
parents:
4
diff
changeset
|
353 text = "" |
0
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
354 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
355 FB.setAccessToken token |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
356 |
4
f352c74a6a5b
remove typeof, corrected facebooks toESN entrys
Mathias Gebbe <mgebbe@intevation.de>
parents:
3
diff
changeset
|
357 return if not post.object.content? or post.object.content is "" |
f352c74a6a5b
remove typeof, corrected facebooks toESN entrys
Mathias Gebbe <mgebbe@intevation.de>
parents:
3
diff
changeset
|
358 ToESN.search {uid: post.object.id + "@facebook"}, (err, result) -> |
0
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
359 if result.length is 0 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
360 body = post.object.content.replace(/<(?:.|\n)*?>/gm, '') + " " + post.object.url |
7
2123f355ab68
go back interval or 15 min, delete credentials, layout
Mathias Gebbe <mgebbe@intevation.de>
parents:
4
diff
changeset
|
361 if post.verb is "share" |
2123f355ab68
go back interval or 15 min, delete credentials, layout
Mathias Gebbe <mgebbe@intevation.de>
parents:
4
diff
changeset
|
362 text = post.object.author.url + " wrotes:" |
0
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
363 FB.api "me/feed", "post", |
7
2123f355ab68
go back interval or 15 min, delete credentials, layout
Mathias Gebbe <mgebbe@intevation.de>
parents:
4
diff
changeset
|
364 message: text + body |
0
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
365 , (res) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
366 if not res or res.error |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
367 console.log (if not res then "error occurred" else res.error) |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
368 return |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
369 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
370 async.waterfall [ |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
371 (callback) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
372 savePost = new ToESN() |
4
f352c74a6a5b
remove typeof, corrected facebooks toESN entrys
Mathias Gebbe <mgebbe@intevation.de>
parents:
3
diff
changeset
|
373 savePost.uid = post.object.id + "@facebook" |
0
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
374 savePost.sourceUser = post.actor.id |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
375 savePost.sourcePost = post.object.id |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
376 savePost.targetUser = user.user_ESN |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
377 savePost.targetPost = res.id |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
378 savePost.recipientUser = 'public' |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
379 savePost.updated = Date.now() |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
380 savePost.save callback |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
381 ], (err, result) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
382 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
383 return |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
384 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
385 return |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
386 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
387 ################################################## |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
388 ###### post comment to facebook stream ###### |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
389 ################################################## |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
390 postComment = (user, object_id, pumpid, text) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
391 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
392 # check if the comment is allready posted (search bla return) |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
393 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
394 CommentToESN.search { uid: pumpid + "_to_" + "https://facebook.com/" + object_id}, (err, result) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
395 if result.length is 0 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
396 token = user.oauth_token |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
397 text = text.replace /<(?:.|\n)*?>/g, "" |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
398 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
399 FB.setAccessToken token |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
400 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
401 FB.api "" + object_id + "/comments", "POST", |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
402 message: text |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
403 , (res) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
404 if not res or res.error |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
405 console.log (if not res then "error occurred" else res.error) |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
406 return |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
407 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
408 CommentToESN.create |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
409 ESNPost: "https://facebook.com/" + object_id |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
410 pumpComment: pumpid |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
411 created: Date.now() |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
412 , (err, result) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
413 console.log 'comment saved' |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
414 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
415 return |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
416 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
417 ################################################## |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
418 ###### like post on facebook stream ###### |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
419 ################################################## |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
420 postLike = (user, object_id) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
421 token = user.oauth_token |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
422 FB.setAccessToken token |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
423 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
424 FB.api "" + object_id + "/likes", "POST" |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
425 , (res) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
426 if not res or res.error |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
427 console.log (if not res then "error occurred" else res.error) |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
428 return |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
429 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
430 console.log 'liked' |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
431 return |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
432 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
433 return |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
434 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
435 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
436 ###################################################################### |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
437 ###### get user facebook by id and add him to UserDB and EDGES ##### |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
438 ###################################################################### |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
439 getUserById = (me,id,token) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
440 data = "" |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
441 token = token |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
442 fields = 'fields=id,name,picture,link' |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
443 options = |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
444 host: 'graph.facebook.com' |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
445 port: 443 |
10
ccf1d9e741bd
corrected google apikey query, removed facebook query language
Mathias Gebbe <mgebbe@intevation.de>
parents:
8
diff
changeset
|
446 path: '/' + id + '?access_token=' + token + '&client_secret=' + secret + '&' + fields |
0
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
447 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
448 https.get(options, (res) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
449 #console.log "Got response: " + res.statusCode |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
450 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
451 res.on "data", (chunk) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
452 data += chunk |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
453 return |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
454 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
455 res.on "end", () -> |
4
f352c74a6a5b
remove typeof, corrected facebooks toESN entrys
Mathias Gebbe <mgebbe@intevation.de>
parents:
3
diff
changeset
|
456 user = JSON.parse(data) if data? |
0
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
457 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
458 #### with app user id ### |
4
f352c74a6a5b
remove typeof, corrected facebooks toESN entrys
Mathias Gebbe <mgebbe@intevation.de>
parents:
3
diff
changeset
|
459 if user? |
f352c74a6a5b
remove typeof, corrected facebooks toESN entrys
Mathias Gebbe <mgebbe@intevation.de>
parents:
3
diff
changeset
|
460 Routes.updateUserDB(user.id+'@facebook',user.name,user.name,user.link,user.picture.data.url) |
f352c74a6a5b
remove typeof, corrected facebooks toESN entrys
Mathias Gebbe <mgebbe@intevation.de>
parents:
3
diff
changeset
|
461 EdgeControl.addEdge(me,user.id+'@facebook') |
f352c74a6a5b
remove typeof, corrected facebooks toESN entrys
Mathias Gebbe <mgebbe@intevation.de>
parents:
3
diff
changeset
|
462 #### with profile url ### |
f352c74a6a5b
remove typeof, corrected facebooks toESN entrys
Mathias Gebbe <mgebbe@intevation.de>
parents:
3
diff
changeset
|
463 Routes.updateUserDB(user.link,user.name,user.name,user.link,user.picture.data.url) |
f352c74a6a5b
remove typeof, corrected facebooks toESN entrys
Mathias Gebbe <mgebbe@intevation.de>
parents:
3
diff
changeset
|
464 EdgeControl.addEdge(me,user.link) |
0
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
465 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
466 return |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
467 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
468 ).on "error", (e) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
469 console.log "Got error: " + e.message |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
470 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
471 return |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
472 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
473 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
474 ###################################################################### |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
475 ###### get user facebook by id and add him to UserDB and EDGES ##### |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
476 ###################################################################### |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
477 getPublicUserInfo = (id, callback) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
478 FB.api ""+id, |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
479 (res) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
480 if not res or res.error |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
481 console.log (if not res then "error occurred" else res.error) |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
482 callback null,res |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
483 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
484 return |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
485 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
486 ###################################################################### |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
487 ###### get facebook long lived token ##### |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
488 ###################################################################### |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
489 getLongLivedToken = (token, callback) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
490 data = "" |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
491 options = |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
492 host: 'graph.facebook.com' |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
493 port: 443 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
494 path: '/oauth/access_token?' + 'grant_type=fb_exchange_token&client_id='+ appid + '&client_secret=' + secret + '&fb_exchange_token=' + token + '' |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
495 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
496 https.get(options, (res) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
497 res.on "data", (chunk) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
498 data += chunk |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
499 return |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
500 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
501 res.on "end", () -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
502 # returns --> "access_token=CAAK9efmXh2IBAAm9abitB98TvF6HHF5ducYDkV5PBrooG6MVNoP9eOy06yvyL0hMKQVzh1xvJPM8XMAYe8L0ZARzZCdolahSymrZCDXN2ZAfr0aIFbWocr8K5DMLu64ZD&expires=5183792" |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
503 ltoken = JSON.stringify(data) |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
504 callback ltoken.substring(ltoken.indexOf('=')+1,ltoken.indexOf('&')) |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
505 return |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
506 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
507 ).on "error", (e) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
508 console.log "Got error: " + e.message |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
509 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
510 return |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
511 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
512 exports.getUser = getUser |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
513 exports.getPages = getPages |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
514 exports.getStream = getStream |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
515 exports.getFriends = getFriends |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
516 exports.postStream = postStream |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
517 exports.getLongLivedToken = getLongLivedToken |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
518 exports.getPublicUserInfo = getPublicUserInfo |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
519 exports.getUserById = getUserById |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
520 exports.sync = sync |