diff --git a/spec/integ/matrix-client-methods.spec.js b/spec/integ/matrix-client-methods.spec.js index b4531fca7..55bf119f6 100644 --- a/spec/integ/matrix-client-methods.spec.js +++ b/spec/integ/matrix-client-methods.spec.js @@ -48,7 +48,7 @@ describe("MatrixClient", function() { const buf = new Buffer('hello world'); it("should upload the file", function(done) { httpBackend.when( - "POST", "/_matrix/media/v1/upload", + "POST", "/_matrix/media/r0/upload", ).check(function(req) { expect(req.rawData).toEqual(buf); expect(req.queryParams.filename).toEqual("hi.txt"); @@ -87,7 +87,7 @@ describe("MatrixClient", function() { it("should parse the response if rawResponse=false", function(done) { httpBackend.when( - "POST", "/_matrix/media/v1/upload", + "POST", "/_matrix/media/r0/upload", ).check(function(req) { expect(req.opts.json).toBeFalsy(); }).respond(200, { "content_uri": "uri" }); @@ -107,7 +107,7 @@ describe("MatrixClient", function() { it("should parse errors into a MatrixError", function(done) { httpBackend.when( - "POST", "/_matrix/media/v1/upload", + "POST", "/_matrix/media/r0/upload", ).check(function(req) { expect(req.rawData).toEqual(buf); expect(req.opts.json).toBeFalsy(); diff --git a/spec/unit/content-repo.spec.js b/spec/unit/content-repo.spec.js index b1a97f681..61b6fceb1 100644 --- a/spec/unit/content-repo.spec.js +++ b/spec/unit/content-repo.spec.js @@ -31,7 +31,7 @@ describe("ContentRepo", function() { function() { const mxcUri = "mxc://server.name/resourceid"; expect(ContentRepo.getHttpUriForMxc(baseUrl, mxcUri)).toEqual( - baseUrl + "/_matrix/media/v1/download/server.name/resourceid", + baseUrl + "/_matrix/media/r0/download/server.name/resourceid", ); }); @@ -43,7 +43,7 @@ describe("ContentRepo", function() { function() { const mxcUri = "mxc://server.name/resourceid"; expect(ContentRepo.getHttpUriForMxc(baseUrl, mxcUri, 32, 64, "crop")).toEqual( - baseUrl + "/_matrix/media/v1/thumbnail/server.name/resourceid" + + baseUrl + "/_matrix/media/r0/thumbnail/server.name/resourceid" + "?width=32&height=64&method=crop", ); }); @@ -52,7 +52,7 @@ describe("ContentRepo", function() { function() { const mxcUri = "mxc://server.name/resourceid#automade"; expect(ContentRepo.getHttpUriForMxc(baseUrl, mxcUri, 32)).toEqual( - baseUrl + "/_matrix/media/v1/thumbnail/server.name/resourceid" + + baseUrl + "/_matrix/media/r0/thumbnail/server.name/resourceid" + "?width=32#automade", ); }); @@ -61,7 +61,7 @@ describe("ContentRepo", function() { function() { const mxcUri = "mxc://server.name/resourceid#automade"; expect(ContentRepo.getHttpUriForMxc(baseUrl, mxcUri)).toEqual( - baseUrl + "/_matrix/media/v1/download/server.name/resourceid#automade", + baseUrl + "/_matrix/media/r0/download/server.name/resourceid#automade", ); }); }); @@ -73,21 +73,21 @@ describe("ContentRepo", function() { it("should set w/h by default to 96", function() { expect(ContentRepo.getIdenticonUri(baseUrl, "foobar")).toEqual( - baseUrl + "/_matrix/media/v1/identicon/foobar" + + baseUrl + "/_matrix/media/unstable/identicon/foobar" + "?width=96&height=96", ); }); it("should be able to set custom w/h", function() { expect(ContentRepo.getIdenticonUri(baseUrl, "foobar", 32, 64)).toEqual( - baseUrl + "/_matrix/media/v1/identicon/foobar" + + baseUrl + "/_matrix/media/unstable/identicon/foobar" + "?width=32&height=64", ); }); it("should URL encode the identicon string", function() { expect(ContentRepo.getIdenticonUri(baseUrl, "foo#bar", 32, 64)).toEqual( - baseUrl + "/_matrix/media/v1/identicon/foo%23bar" + + baseUrl + "/_matrix/media/unstable/identicon/foo%23bar" + "?width=32&height=64", ); }); diff --git a/src/content-repo.js b/src/content-repo.js index 8a5f9f06b..9c0a3306b 100644 --- a/src/content-repo.js +++ b/src/content-repo.js @@ -47,7 +47,7 @@ module.exports = { } } let serverAndMediaId = mxc.slice(6); // strips mxc:// - let prefix = "/_matrix/media/v1/download/"; + let prefix = "/_matrix/media/r0/download/"; const params = {}; if (width) { @@ -62,7 +62,7 @@ module.exports = { if (utils.keys(params).length > 0) { // these are thumbnailing params so they probably want the // thumbnailing API... - prefix = "/_matrix/media/v1/thumbnail/"; + prefix = "/_matrix/media/r0/thumbnail/"; } const fragmentOffset = serverAndMediaId.indexOf("#"); @@ -83,6 +83,7 @@ module.exports = { * @param {Number} width The desired width of the image in pixels. Default: 96. * @param {Number} height The desired height of the image in pixels. Default: 96. * @return {string} The complete URL to the identicon. + * @deprecated This is no longer in the specification. */ getIdenticonUri: function(baseUrl, identiconString, width, height) { if (!identiconString) { @@ -99,7 +100,7 @@ module.exports = { height: height, }; - const path = utils.encodeUri("/_matrix/media/v1/identicon/$ident", { + const path = utils.encodeUri("/_matrix/media/unstable/identicon/$ident", { $ident: identiconString, }); return baseUrl + path + diff --git a/src/http-api.js b/src/http-api.js index 16171151a..5731a3e34 100644 --- a/src/http-api.js +++ b/src/http-api.js @@ -102,7 +102,7 @@ module.exports.MatrixHttpApi.prototype = { }; return { base: this.opts.baseUrl, - path: "/_matrix/media/v1/upload", + path: "/_matrix/media/r0/upload", params: params, }; }, @@ -291,7 +291,7 @@ module.exports.MatrixHttpApi.prototype = { }); } }); - let url = this.opts.baseUrl + "/_matrix/media/v1/upload"; + let url = this.opts.baseUrl + "/_matrix/media/r0/upload"; const queryArgs = []; @@ -327,7 +327,7 @@ module.exports.MatrixHttpApi.prototype = { promise = this.authedRequest( opts.callback, "POST", "/upload", queryParams, body, { - prefix: "/_matrix/media/v1", + prefix: "/_matrix/media/r0", headers: {"Content-Type": contentType}, json: false, bodyParser: bodyParser, diff --git a/src/models/room-member.js b/src/models/room-member.js index bbc7b5e23..d92267720 100644 --- a/src/models/room-member.js +++ b/src/models/room-member.js @@ -249,7 +249,7 @@ RoomMember.prototype.getDMInviter = function() { * "crop" or "scale". * @param {Boolean} allowDefault (optional) Passing false causes this method to * return null if the user has no avatar image. Otherwise, a default image URL - * will be returned. Default: true. + * will be returned. Default: true. (Deprecated) * @param {Boolean} allowDirectLinks (optional) If true, the avatar URL will be * returned even if it is a direct hyperlink rather than a matrix content URL. * If false, any non-matrix content URLs will be ignored. Setting this option to diff --git a/src/models/room.js b/src/models/room.js index ef7c34c8d..bd0ef3fd8 100644 --- a/src/models/room.js +++ b/src/models/room.js @@ -781,7 +781,7 @@ Room.prototype.getBlacklistUnverifiedDevices = function() { * @param {string} resizeMethod The thumbnail resize method to use, either * "crop" or "scale". * @param {boolean} allowDefault True to allow an identicon for this room if an - * avatar URL wasn't explicitly set. Default: true. + * avatar URL wasn't explicitly set. Default: true. (Deprecated) * @return {?string} the avatar URL or null. */ Room.prototype.getAvatarUrl = function(baseUrl, width, height, resizeMethod,