How to use the m.room.member function in m

To help you get started, we’ve selected a few m examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github matrix-org / matrix-js-sdk / spec / unit / webstorage.spec.js View on Github external
describe("WebStorageStore", function() {
    var store, room;
    var roomId = "!foo:bar";
    var userId = "@alice:bar";
    var mockStorageApi;
    var batchNum = 3;
    // web storage api keys
    var prefix = "room_" + roomId + "_timeline_";
    var stateKeyName = "room_" + roomId + "_state";

    // stored state events
    var stateEventMap = {
        "m.room.member": {},
        "m.room.name": {}
    };
    stateEventMap["m.room.member"][userId] = utils.mkMembership(
        {user: userId, room: roomId, mship: "join"}
    );
    stateEventMap["m.room.name"][""] = utils.mkEvent(
        {user: userId, room: roomId, type: "m.room.name",
        content: {
            name: "foo"
        }}
    );

    beforeEach(function() {
        utils.beforeEach(this); // eslint-disable-line no-invalid-this
        mockStorageApi = new MockStorageApi();
        store = new WebStorageStore(mockStorageApi, batchNum);
        room = new Room(roomId);
    });
github matrix-org / matrix-js-sdk / spec / unit / webstorage.spec.js View on Github external
it("should reconstruct room state", function() {
            setItem(mockStorageApi, stateKeyName, {
                events: stateEventMap,
                pagination_token: "tok"
            });

            var storedRoom = store.getRoom(roomId);
            expect(
                storedRoom.currentState.getStateEvents("m.room.name", "").event
            ).toEqual(stateEventMap["m.room.name"][""]);
            expect(
                storedRoom.currentState.getStateEvents("m.room.member", userId).event
            ).toEqual(stateEventMap["m.room.member"][userId]);
        });
github flackr / lobby / src / lobby.js View on Github external
activeMembers() {
    let members = {};
    for (let key in this.state['m.room.member']) {
      let details = this.state['m.room.member'][key];
      if (details.content.membership == 'join') {
        members[details.user_id] = {
          displayname: details.content.displayname,
        };
      }
    }
    return members;
  }
};
github matrix-construct / construct / share / webapp / js / room / misc.js View on Github external
room.prototype.tab_completion_find = function(term)
{
	let ids = [];
	for(let key in this.state['m.room.member'])
	{
		let sid = client.m.sid(key.toLowerCase());
		if(sid.startsWith(term.toLowerCase()))
			ids.push([sid, key]);
	}

	return ids;
};
github flackr / lobby / src / lobby.js View on Github external
activeMembers() {
    let members = {};
    for (let key in this.state['m.room.member']) {
      let details = this.state['m.room.member'][key];
      if (details.content.membership == 'join') {
        members[details.user_id] = {
          displayname: details.content.displayname,
        };
      }
    }
    return members;
  }
};
github matrix-construct / construct / share / webapp / js / room / state.js View on Github external
room.state.summary = function(state)
{
	let members = state['m.room.member'];
	let is_join = (mxid) => maybe(() => members[mxid].content.membership == "join");

	let aliases = [];
	Object.each(state['m.room.aliases'], (state_key, event) =>
	{
		aliases = aliases.concat(event.content.aliases);
	});

	return {
		room_id: state['m.room.create'][''].room_id,
		name: state['m.room.name'][''].content.name,
		topic: state['m.room.topic'][''].content.topic,
		canonical_alias: state['m.room.canonical_alias'][''].content.alias,
		world_readable: state['m.room.history_visibility'][''].content.history_visibility == "world_readable",
		guest_can_join: state['m.room.guest_access'][''].content.guest_access == "can_join",
		num_joined_members: Array.count(Object.keys(members), is_join),
github matrix-construct / construct / share / webapp / js / room / members.js View on Github external
room.membership.members = function()
{
	return this.content['m.room.member'];
};