Mercurial > pumpbridge
annotate src/facebook.coffee @ 32:ca0b44c1a870 tip
Readme: twitter in the summary, it is best working currently.
author | Bernhard Reiter <bernhard@intevation.de> |
---|---|
date | Mon, 13 Oct 2014 13:22:17 +0200 |
parents | 8238d312e281 |
children |
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) |
22
b90e6df48d2d
eachLimit instead of each
Mathias Gebbe <mgebbe@intevation.de>
parents:
17
diff
changeset
|
51 async.eachLimit posts, 10, ((post, callback) -> |
0
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) -> |
22
b90e6df48d2d
eachLimit instead of each
Mathias Gebbe <mgebbe@intevation.de>
parents:
17
diff
changeset
|
54 FromESN.search {uid: post.id + "@facebook_to_" + me}, callback |
0
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 |
22
b90e6df48d2d
eachLimit instead of each
Mathias Gebbe <mgebbe@intevation.de>
parents:
17
diff
changeset
|
90 |
0
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
91 #### |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
92 # TO DO: GET NEW COMMENTS |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
93 # for each fromESN check the comments |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
94 # if comment author = me |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
95 # post comment |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
96 # if comment author != me |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
97 # post comment with 'user schreibt' |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
98 async.waterfall [ |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
99 (callback) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
100 FromESN.search {recipientUser: me}, callback |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
101 (allESN, callback) -> |
22
b90e6df48d2d
eachLimit instead of each
Mathias Gebbe <mgebbe@intevation.de>
parents:
17
diff
changeset
|
102 async.eachLimit allESN, 10, ((fromesn, callback) -> |
0
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
103 async.waterfall [ |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
104 (cb) -> |
31 | 105 if fromesn.sourcePost.indexOf('facebook.com') is -1 |
8
6fd0a307850f
check empty strings and users
Mathias Gebbe <mgebbe@intevation.de>
parents:
7
diff
changeset
|
106 return |
0
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
107 Usermap.search {id: me + '_to_' + me}, cb |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
108 (pumpuser, cb) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
109 Pump.getNote(pumpuser[0], fromesn.pumpPost, cb) |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
110 (note, cb) -> |
8
6fd0a307850f
check empty strings and users
Mathias Gebbe <mgebbe@intevation.de>
parents:
7
diff
changeset
|
111 return if not (note?) |
4
f352c74a6a5b
remove typeof, corrected facebooks toESN entrys
Mathias Gebbe <mgebbe@intevation.de>
parents:
3
diff
changeset
|
112 if note.liked is true |
0
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
113 obj = fromesn.postid.substr(0,fromesn.postid.indexOf('@')) |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
114 postLike(user,obj) |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
115 if (note.replies?) |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
116 reply = JSON.stringify(note.replies) |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
117 rep = JSON.parse(reply) |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
118 if rep.totalItems >= 1 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
119 async.each rep.items, ((r, callback) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
120 if r.author.id is "acct:" + me |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
121 obj = fromesn.postid.substr(0,fromesn.postid.indexOf('@')) |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
122 postComment(user, obj, r.id , r.content) |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
123 callback null, 'done' |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
124 ), (err) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
125 cb null, 'done' |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
126 ], (err, result) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
127 #done |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
128 ), (err) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
129 callback null, 'done' |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
130 ], (err, result) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
131 #done |
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() |
27
f27ddfa42e94
try/catch; From/To/-ESN changes; google probs
Mathias Gebbe <mgebbe@intevation.de>
parents:
24
diff
changeset
|
339 |
f27ddfa42e94
try/catch; From/To/-ESN changes; google probs
Mathias Gebbe <mgebbe@intevation.de>
parents:
24
diff
changeset
|
340 if res.data? |
f27ddfa42e94
try/catch; From/To/-ESN changes; google probs
Mathias Gebbe <mgebbe@intevation.de>
parents:
24
diff
changeset
|
341 async.each res.data, ((post,cb) -> |
f27ddfa42e94
try/catch; From/To/-ESN changes; google probs
Mathias Gebbe <mgebbe@intevation.de>
parents:
24
diff
changeset
|
342 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') |
f27ddfa42e94
try/catch; From/To/-ESN changes; google probs
Mathias Gebbe <mgebbe@intevation.de>
parents:
24
diff
changeset
|
343 newposts.push(post) |
f27ddfa42e94
try/catch; From/To/-ESN changes; google probs
Mathias Gebbe <mgebbe@intevation.de>
parents:
24
diff
changeset
|
344 cb() |
f27ddfa42e94
try/catch; From/To/-ESN changes; google probs
Mathias Gebbe <mgebbe@intevation.de>
parents:
24
diff
changeset
|
345 ), (err) -> |
f27ddfa42e94
try/catch; From/To/-ESN changes; google probs
Mathias Gebbe <mgebbe@intevation.de>
parents:
24
diff
changeset
|
346 callback null, newposts.reverse() |
f27ddfa42e94
try/catch; From/To/-ESN changes; google probs
Mathias Gebbe <mgebbe@intevation.de>
parents:
24
diff
changeset
|
347 else |
f27ddfa42e94
try/catch; From/To/-ESN changes; google probs
Mathias Gebbe <mgebbe@intevation.de>
parents:
24
diff
changeset
|
348 callback null,null |
17
a52b5b244e51
removed unnecessary underscore and replaced it with async
Mathias Gebbe <mgebbe@intevation.de>
parents:
14
diff
changeset
|
349 return |
0
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 ####################################### |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
352 ###### post facebook stream ###### |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
353 ####################################### |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
354 postStream = (user, post) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
355 token = user.oauth_token |
7
2123f355ab68
go back interval or 15 min, delete credentials, layout
Mathias Gebbe <mgebbe@intevation.de>
parents:
4
diff
changeset
|
356 text = "" |
0
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
357 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
358 FB.setAccessToken token |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
359 |
4
f352c74a6a5b
remove typeof, corrected facebooks toESN entrys
Mathias Gebbe <mgebbe@intevation.de>
parents:
3
diff
changeset
|
360 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
|
361 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
|
362 if result.length is 0 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
363 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
|
364 if post.verb is "share" |
24 | 365 text = post.object.author.url + " writes:" |
0
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
366 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
|
367 message: text + body |
0
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
368 , (res) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
369 if not res or res.error |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
370 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
|
371 return |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
372 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
373 async.waterfall [ |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
374 (callback) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
375 savePost = new ToESN() |
4
f352c74a6a5b
remove typeof, corrected facebooks toESN entrys
Mathias Gebbe <mgebbe@intevation.de>
parents:
3
diff
changeset
|
376 savePost.uid = post.object.id + "@facebook" |
0
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
377 savePost.sourceUser = post.actor.id |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
378 savePost.sourcePost = post.object.id |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
379 savePost.targetUser = user.user_ESN |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
380 savePost.targetPost = res.id |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
381 savePost.recipientUser = 'public' |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
382 savePost.updated = Date.now() |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
383 savePost.save callback |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
384 ], (err, result) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
385 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
386 return |
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 return |
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 ################################################## |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
391 ###### post comment to facebook stream ###### |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
392 ################################################## |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
393 postComment = (user, object_id, pumpid, text) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
394 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
395 # 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
|
396 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
397 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
|
398 if result.length is 0 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
399 token = user.oauth_token |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
400 text = text.replace /<(?:.|\n)*?>/g, "" |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
401 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
402 FB.setAccessToken token |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
403 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
404 FB.api "" + object_id + "/comments", "POST", |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
405 message: text |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
406 , (res) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
407 if not res or res.error |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
408 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
|
409 return |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
410 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
411 CommentToESN.create |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
412 ESNPost: "https://facebook.com/" + object_id |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
413 pumpComment: pumpid |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
414 created: Date.now() |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
415 , (err, result) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
416 console.log 'comment saved' |
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 return |
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 ################################################## |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
421 ###### like post on facebook stream ###### |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
422 ################################################## |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
423 postLike = (user, object_id) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
424 token = user.oauth_token |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
425 FB.setAccessToken token |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
426 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
427 FB.api "" + object_id + "/likes", "POST" |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
428 , (res) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
429 if not res or res.error |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
430 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
|
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 console.log 'liked' |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
434 return |
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 return |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
437 |
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 ###################################################################### |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
440 ###### 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
|
441 ###################################################################### |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
442 getUserById = (me,id,token) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
443 data = "" |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
444 token = token |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
445 fields = 'fields=id,name,picture,link' |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
446 options = |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
447 host: 'graph.facebook.com' |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
448 port: 443 |
10
ccf1d9e741bd
corrected google apikey query, removed facebook query language
Mathias Gebbe <mgebbe@intevation.de>
parents:
8
diff
changeset
|
449 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
|
450 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
451 https.get(options, (res) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
452 #console.log "Got response: " + res.statusCode |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
453 res.on "data", (chunk) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
454 data += chunk |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
455 return |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
456 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
457 res.on "end", () -> |
4
f352c74a6a5b
remove typeof, corrected facebooks toESN entrys
Mathias Gebbe <mgebbe@intevation.de>
parents:
3
diff
changeset
|
458 user = JSON.parse(data) if data? |
0
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
459 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
460 #### with app user id ### |
4
f352c74a6a5b
remove typeof, corrected facebooks toESN entrys
Mathias Gebbe <mgebbe@intevation.de>
parents:
3
diff
changeset
|
461 if user? |
f352c74a6a5b
remove typeof, corrected facebooks toESN entrys
Mathias Gebbe <mgebbe@intevation.de>
parents:
3
diff
changeset
|
462 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
|
463 EdgeControl.addEdge(me,user.id+'@facebook') |
f352c74a6a5b
remove typeof, corrected facebooks toESN entrys
Mathias Gebbe <mgebbe@intevation.de>
parents:
3
diff
changeset
|
464 #### with profile url ### |
f352c74a6a5b
remove typeof, corrected facebooks toESN entrys
Mathias Gebbe <mgebbe@intevation.de>
parents:
3
diff
changeset
|
465 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
|
466 EdgeControl.addEdge(me,user.link) |
0
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 return |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
469 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
470 ).on "error", (e) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
471 console.log "Got error: " + e.message |
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 return |
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 |
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 ###### 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
|
478 ###################################################################### |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
479 getPublicUserInfo = (id, callback) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
480 FB.api ""+id, |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
481 (res) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
482 if not res or res.error |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
483 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
|
484 callback null,res |
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 return |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
487 |
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 ###### get facebook long lived token ##### |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
490 ###################################################################### |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
491 getLongLivedToken = (token, callback) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
492 data = "" |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
493 options = |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
494 host: 'graph.facebook.com' |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
495 port: 443 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
496 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
|
497 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
498 https.get(options, (res) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
499 res.on "data", (chunk) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
500 data += chunk |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
501 return |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
502 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
503 res.on "end", () -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
504 # returns --> "access_token=CAAK9efmXh2IBAAm9abitB98TvF6HHF5ducYDkV5PBrooG6MVNoP9eOy06yvyL0hMKQVzh1xvJPM8XMAYe8L0ZARzZCdolahSymrZCDXN2ZAfr0aIFbWocr8K5DMLu64ZD&expires=5183792" |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
505 ltoken = JSON.stringify(data) |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
506 callback ltoken.substring(ltoken.indexOf('=')+1,ltoken.indexOf('&')) |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
507 return |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
508 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
509 ).on "error", (e) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
510 console.log "Got error: " + e.message |
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 return |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
513 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
514 exports.getUser = getUser |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
515 exports.getPages = getPages |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
516 exports.getStream = getStream |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
517 exports.getFriends = getFriends |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
518 exports.postStream = postStream |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
519 exports.getLongLivedToken = getLongLivedToken |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
520 exports.getPublicUserInfo = getPublicUserInfo |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
521 exports.getUserById = getUserById |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
522 exports.sync = sync |