Skip to content

Commit 66e5af1

Browse files
authored
Merge pull request #1635 from matrix-org/travis/media-customization
Add a function to get a room's MXC URI
2 parents c18ef05 + 0ff611e commit 66e5af1

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/models/room.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,7 @@ Room.prototype.getBlacklistUnverifiedDevices = function() {
818818
*/
819819
Room.prototype.getAvatarUrl = function(baseUrl, width, height, resizeMethod,
820820
allowDefault) {
821-
const roomAvatarEvent = this.currentState.getStateEvents("m.room.avatar", "");
821+
const roomAvatarEvent = this.currentState.getStateEvents(EventType.RoomAvatar, "");
822822
if (allowDefault === undefined) {
823823
allowDefault = true;
824824
}
@@ -836,6 +836,15 @@ Room.prototype.getAvatarUrl = function(baseUrl, width, height, resizeMethod,
836836
return null;
837837
};
838838

839+
/**
840+
* Get the mxc avatar url for the room, if one was set.
841+
* @return {string} the mxc avatar url or falsy
842+
*/
843+
Room.prototype.getMxcAvatarUrl = function() {
844+
const roomAvatarEvent = this.currentState.getStateEvents(EventType.RoomAvatar, "");
845+
return roomAvatarEvent ? roomAvatarEvent.getContent().url : null;
846+
};
847+
839848
/**
840849
* Get the aliases this room has according to the room's state
841850
* The aliases returned by this function may not necessarily

0 commit comments

Comments
 (0)