1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-26 17:03:12 +03:00

Add a method to the js sdk to look up 3pids on the ID server.

This commit is contained in:
David Baker
2016-03-18 15:15:10 +00:00
parent fdbc7a3112
commit f4fd8d9ba6
2 changed files with 27 additions and 7 deletions

View File

@@ -3233,12 +3233,27 @@ MatrixClient.prototype.requestEmailToken = function(email, clientSecret,
return this._http.idServerRequest(
callback, "POST", "/validate/email/requestToken",
params, httpApi.PREFIX_IDENTITY_V1
).then(function(res) {
if (typeof res === "string") {
return JSON.parse(res);
}
return res;
});
);
};
/**
* Looks up the public Matrix ID mapping for a given 3rd party
* identifier from the Identity Server
* @param {string} medium The medium of the threepid, eg. 'email'
* @param {string} address The textual address of the threepid
* @param {module:client.callback} callback Optional.
* @return {module:client.Promise} Resolves: TODO
* @return {module:http-api.MatrixError} Rejects: with an error response.
*/
MatrixClient.prototype.lookupThreePid = function(medium, address, callback) {
var params = {
medium: medium,
address: address,
};
return this._http.idServerRequest(
callback, "GET", "/lookup",
params, httpApi.PREFIX_IDENTITY_V1
);
};
/**

View File

@@ -245,7 +245,12 @@ module.exports.MatrixHttpApi.prototype = {
opts,
requestCallback(defer, callback, this.opts.onlyData)
);
return defer.promise;
// ID server does not always take JSON, so we can't use requests' 'json'
// option as we do with the home server, but it does return JSON, so
// parse it manually
return defer.promise.then(function(response) {
return JSON.parse(response);
});
},
/**