You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-07-31 15:24:23 +03:00
check power levels without relying on membership
as this might not be known for the syncing user. instead, add a method to room which always knows the syncing user's membership
This commit is contained in:
@ -447,13 +447,6 @@ describe("RoomState", function() {
|
||||
});
|
||||
|
||||
describe("maySendStateEvent", function() {
|
||||
it("should say non-joined members may not send state",
|
||||
function() {
|
||||
expect(state.maySendStateEvent(
|
||||
'm.room.name', "@nobody:nowhere",
|
||||
)).toEqual(false);
|
||||
});
|
||||
|
||||
it("should say any member may send state with no power level event",
|
||||
function() {
|
||||
expect(state.maySendStateEvent('m.room.name', userA)).toEqual(true);
|
||||
@ -640,14 +633,6 @@ describe("RoomState", function() {
|
||||
});
|
||||
|
||||
describe("maySendEvent", function() {
|
||||
it("should say non-joined members may not send events",
|
||||
function() {
|
||||
expect(state.maySendEvent(
|
||||
'm.room.message', "@nobody:nowhere",
|
||||
)).toEqual(false);
|
||||
expect(state.maySendMessage("@nobody:nowhere")).toEqual(false);
|
||||
});
|
||||
|
||||
it("should say any member may send events with no power level event",
|
||||
function() {
|
||||
expect(state.maySendEvent('m.room.message', userA)).toEqual(true);
|
||||
|
@ -1400,7 +1400,7 @@ describe("Room", function() {
|
||||
|
||||
describe("getMyMembership", function() {
|
||||
it("should return synced membership if membership isn't available yet",
|
||||
async function() {
|
||||
function() {
|
||||
const room = new Room(roomId, null, userA);
|
||||
room.setSyncedMembership("invite");
|
||||
expect(room.getMyMembership()).toEqual("invite");
|
||||
@ -1434,4 +1434,17 @@ describe("Room", function() {
|
||||
expect(room.guessDMUserId()).toEqual(userA);
|
||||
});
|
||||
});
|
||||
|
||||
describe("maySendMessage", function() {
|
||||
it("should return false if synced membership not join",
|
||||
function() {
|
||||
const room = new Room(roomId, null, userA);
|
||||
room.setSyncedMembership("invite");
|
||||
expect(room.maySendMessage()).toEqual(false);
|
||||
room.setSyncedMembership("leave");
|
||||
expect(room.maySendMessage()).toEqual(false);
|
||||
room.setSyncedMembership("join");
|
||||
expect(room.maySendMessage()).toEqual(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user