Mercurial > prosody-modules
comparison mod_http_roster_admin/mod_http_roster_admin.lua @ 2441:68ebc52222dc
Log URL called by http_roster_admin
author | JC Brand <jc@opkode.com> |
---|---|
date | Thu, 12 Jan 2017 09:49:32 +0000 |
parents | 126d79bf079b |
children | 7c3a1688e385 |
comparison
equal
deleted
inserted
replaced
2440:7814a5c7fee8 | 2441:68ebc52222dc |
---|---|
125 -- Fetch the named user's roster from the API, call callback (cb) | 125 -- Fetch the named user's roster from the API, call callback (cb) |
126 -- with status and result (friends list) when received. | 126 -- with status and result (friends list) when received. |
127 function fetch_roster(username, cb) | 127 function fetch_roster(username, cb) |
128 local x = {headers = {}}; | 128 local x = {headers = {}}; |
129 x["headers"]["ACCEPT"] = "application/json, text/plain, */*"; | 129 x["headers"]["ACCEPT"] = "application/json, text/plain, */*"; |
130 module:log("debug", "Fetching roster at URL: %s", roster_url:format(username)); | |
130 local ok, err = http.request( | 131 local ok, err = http.request( |
131 roster_url:format(username), | 132 roster_url:format(username), |
132 x, | 133 x, |
133 function (roster_data, code) | 134 function (roster_data, code) |
134 if code ~= 200 then | 135 if code ~= 200 then |
141 module:log("debug", "Successfully fetched roster for %s", username); | 142 module:log("debug", "Successfully fetched roster for %s", username); |
142 module:log("debug", "The roster data is %s", roster_data); | 143 module:log("debug", "The roster data is %s", roster_data); |
143 cb(true, code, json.decode(roster_data)); | 144 cb(true, code, json.decode(roster_data)); |
144 end | 145 end |
145 ); | 146 ); |
146 module:log("debug", "fetch_roster: ok is %s", ok); | |
147 if not ok then | 147 if not ok then |
148 module:log("error", "Failed to connect to roster API at %s: %s", roster_url:format(username), err); | 148 module:log("error", "Failed to connect to roster API at %s: %s", roster_url:format(username), err); |
149 cb(false, 0, err); | 149 cb(false, 0, err); |
150 end | 150 end |
151 end | 151 end |