You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-28 05:03:59 +03:00
Merge pull request #693 from matrix-org/dbkr/room_upgrades
Support for room upgrades
This commit is contained in:
@@ -446,6 +446,20 @@ function(roomId, includeMembership, excludeMembership, atEventId, callback) {
|
||||
return this._http.authedRequest(callback, "GET", path);
|
||||
};
|
||||
|
||||
/**
|
||||
* Upgrades a room to a new protocol version
|
||||
* @param {string} roomId
|
||||
* @param {string} newVersion The target version to upgrade to
|
||||
* @return {module:client.Promise} Resolves: Object with key 'replacement_room'
|
||||
* @return {module:http-api.MatrixError} Rejects: with an error response.
|
||||
*/
|
||||
MatrixBaseApis.prototype.upgradeRoom = function(roomId, newVersion) {
|
||||
const path = utils.encodeUri("/rooms/$roomId/upgrade", {$roomId: roomId});
|
||||
return this._http.authedRequest(
|
||||
undefined, "POST", path, undefined, {new_version: newVersion},
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {string} groupId
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
Copyright 2015, 2016 OpenMarket Ltd
|
||||
Copyright 2018 New Vector Ltd
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@@ -29,6 +30,8 @@ const EventTimelineSet = require("./event-timeline-set");
|
||||
|
||||
import ReEmitter from '../ReEmitter';
|
||||
|
||||
const LATEST_ROOM_VERSION = '1';
|
||||
|
||||
function synthesizeReceipt(userId, event, receiptType) {
|
||||
// console.log("synthesizing receipt for "+event.getId());
|
||||
// This is really ugly because JS has no way to express an object literal
|
||||
@@ -200,6 +203,27 @@ Room.prototype.getVersion = function() {
|
||||
return ver;
|
||||
};
|
||||
|
||||
/**
|
||||
* Determines whether this room needs to be upgraded to a new version
|
||||
* @returns {string?} What version the room should be upgraded to, or null if
|
||||
* the room does not require upgrading at this time.
|
||||
*/
|
||||
Room.prototype.shouldUpgradeToVersion = function() {
|
||||
// This almost certainly won't be the way this actually works - this
|
||||
// is essentially a stub method.
|
||||
if (this.getVersion() === LATEST_ROOM_VERSION) return null;
|
||||
return LATEST_ROOM_VERSION;
|
||||
};
|
||||
|
||||
/**
|
||||
* Determines whether the given user is permitted to perform a room upgrade
|
||||
* @param {String} userId The ID of the user to test against
|
||||
* @returns {bool} True if the given user is permitted to upgrade the room
|
||||
*/
|
||||
Room.prototype.userMayUpgradeRoom = function(userId) {
|
||||
return this.currentState.maySendStateEvent("m.room.tombstone", userId);
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the list of pending sent events for this room
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user