diff --git a/spec/unit/content-repo.spec.js b/spec/unit/content-repo.spec.js index b55055684..377aedd52 100644 --- a/spec/unit/content-repo.spec.js +++ b/spec/unit/content-repo.spec.js @@ -1,4 +1,4 @@ -import {getHttpUriForMxc, getIdenticonUri} from "../../src/content-repo"; +import {getHttpUriForMxc} from "../../src/content-repo"; describe("ContentRepo", function() { const baseUrl = "https://my.home.server"; @@ -56,31 +56,4 @@ describe("ContentRepo", function() { ); }); }); - - describe("getIdenticonUri", function() { - it("should do nothing for null input", function() { - expect(getIdenticonUri(null)).toEqual(null); - }); - - it("should set w/h by default to 96", function() { - expect(getIdenticonUri(baseUrl, "foobar")).toEqual( - baseUrl + "/_matrix/media/unstable/identicon/foobar" + - "?width=96&height=96", - ); - }); - - it("should be able to set custom w/h", function() { - expect(getIdenticonUri(baseUrl, "foobar", 32, 64)).toEqual( - baseUrl + "/_matrix/media/unstable/identicon/foobar" + - "?width=32&height=64", - ); - }); - - it("should URL encode the identicon string", function() { - expect(getIdenticonUri(baseUrl, "foo#bar", 32, 64)).toEqual( - baseUrl + "/_matrix/media/unstable/identicon/foo%23bar" + - "?width=32&height=64", - ); - }); - }); }); diff --git a/src/content-repo.js b/src/content-repo.js index 4bc4ca688..0d1ae1ea0 100644 --- a/src/content-repo.js +++ b/src/content-repo.js @@ -75,35 +75,3 @@ export function getHttpUriForMxc(baseUrl, mxc, width, height, (utils.keys(params).length === 0 ? "" : ("?" + utils.encodeParams(params))) + fragment; } - -/** - * Get an identicon URL from an arbitrary string. - * @param {string} baseUrl The base homeserver url which has a content repo. - * @param {string} identiconString The string to create an identicon for. - * @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. - */ -export function getIdenticonUri(baseUrl, identiconString, width, height) { - if (!identiconString) { - return null; - } - if (!width) { - width = 96; - } - if (!height) { - height = 96; - } - const params = { - width: width, - height: height, - }; - - const path = utils.encodeUri("/_matrix/media/unstable/identicon/$ident", { - $ident: identiconString, - }); - return baseUrl + path + - (utils.keys(params).length === 0 ? "" : - ("?" + utils.encodeParams(params))); -} diff --git a/src/models/room-member.js b/src/models/room-member.js index 4dc973c79..b6173f4af 100644 --- a/src/models/room-member.js +++ b/src/models/room-member.js @@ -20,7 +20,7 @@ limitations under the License. */ import {EventEmitter} from "events"; -import {getHttpUriForMxc, getIdenticonUri} from "../content-repo"; +import {getHttpUriForMxc} from "../content-repo"; import * as utils from "../utils"; /** @@ -274,10 +274,6 @@ RoomMember.prototype.getAvatarUrl = ); if (httpUrl) { return httpUrl; - } else if (allowDefault) { - return getIdenticonUri( - baseUrl, this.userId, width, height, - ); } return null; }; diff --git a/src/models/room.js b/src/models/room.js index 4a656712f..82405eb1c 100644 --- a/src/models/room.js +++ b/src/models/room.js @@ -23,7 +23,7 @@ limitations under the License. import {EventEmitter} from "events"; import {EventTimelineSet} from "./event-timeline-set"; import {EventTimeline} from "./event-timeline"; -import {getHttpUriForMxc, getIdenticonUri} from "../content-repo"; +import {getHttpUriForMxc} from "../content-repo"; import * as utils from "../utils"; import {EventStatus, MatrixEvent} from "./event"; import {RoomMember} from "./room-member"; @@ -818,10 +818,6 @@ Room.prototype.getAvatarUrl = function(baseUrl, width, height, resizeMethod, return getHttpUriForMxc( baseUrl, mainUrl, width, height, resizeMethod, ); - } else if (allowDefault) { - return getIdenticonUri( - baseUrl, this.roomId, width, height, - ); } return null;