1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-28 05:03:59 +03:00

WIP url previewing

This commit is contained in:
Matthew Hodgson
2016-03-31 18:38:34 +01:00
parent 458cc55dec
commit 415251dd70
2 changed files with 22 additions and 0 deletions

View File

@@ -1448,6 +1448,23 @@ MatrixClient.prototype.getCurrentUploads = function() {
return this._http.getCurrentUploads(); return this._http.getCurrentUploads();
}; };
/**
* Get a preview of the given URL as OpenGraph metadata
* @param {module:client.callback} callback Optional.
* @return {module:client.Promise} Resolves: Object of OG metadata.
* @return {module:http-api.MatrixError} Rejects: with an error response.
* May return synthesized attributes if the URL lacked OG meta.
*/
MatrixClient.prototype.getUrlPreview = function(url, callback) {
// FIXME: maintain a clientside cache to stop hammering synapse
// especially as synapse doesn't cache yet
return this._http.authedRequestWithPrefix(
callback, "GET", "/preview_url", {
url: url
}, undefined, httpApi.PREFIX_MEDIA_R0
);
};
/** /**
* @param {string} roomId * @param {string} roomId
* @param {boolean} isTyping * @param {boolean} isTyping

View File

@@ -47,6 +47,11 @@ module.exports.PREFIX_UNSTABLE = "/_matrix/client/unstable";
*/ */
module.exports.PREFIX_IDENTITY_V1 = "/_matrix/identity/api/v1"; module.exports.PREFIX_IDENTITY_V1 = "/_matrix/identity/api/v1";
/**
* URI path for the media repo API
*/
module.exports.PREFIX_MEDIA_R0 = "/_matrix/media/r0";
/** /**
* Construct a MatrixHttpApi. * Construct a MatrixHttpApi.
* @constructor * @constructor