Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'+': Pill.TYPE_GROUP_MENTION,
}[prefix];
let member;
let group;
let room;
switch (pillType) {
case Pill.TYPE_AT_ROOM_MENTION: {
room = nextProps.room;
}
break;
case Pill.TYPE_USER_MENTION: {
const localMember = nextProps.room.getMember(resourceId);
member = localMember;
if (!localMember) {
member = new RoomMember(null, resourceId);
this.doProfileLookup(resourceId, member);
}
}
break;
case Pill.TYPE_ROOM_MENTION: {
const localRoom = resourceId[0] === '#' ?
MatrixClientPeg.get().getRooms().find((r) => {
return r.getAliases().includes(resourceId);
}) : MatrixClientPeg.get().getRoom(resourceId);
room = localRoom;
if (!localRoom) {
// TODO: This would require a new API to resolve a room alias to
// a room avatar and name.
// this.doRoomProfileLookup(resourceId, member);
}
}
room_id: roomId,
user_id: "",
event_id: "_",
state_key: "",
type: "m.room.power_levels"
}
var powerLevelEvent = new MatrixEvent(event);
// What level do we need for this event type?
var defaultLevel = event.content.events_default;
if (STATE_EVENT_TYPES.indexOf(eventType) !== -1) {
defaultLevel = event.content.state_default;
}
var requiredLevel = event.content.events[eventType] || defaultLevel;
// Parse out what level the client has by abusing the JS SDK
var roomMember = new RoomMember(roomId, userId);
roomMember.setPowerLevelEvent(powerLevelEvent);
if (requiredLevel > roomMember.powerLevel) {
// can the bot update our power level?
var bot = new RoomMember(roomId, self.botClient.credentials.userId);
bot.setPowerLevelEvent(powerLevelEvent);
var levelRequiredToModifyPowerLevels = event.content.events[
"m.room.power_levels"
] || event.content.state_default;
if (levelRequiredToModifyPowerLevels > bot.powerLevel) {
// even the bot has no power here.. give up.
throw new Error(
"Cannot ensure client has power level for event " + eventType +
" : client has " + roomMember.powerLevel + " and we require " +
requiredLevel + " and the bot doesn't have permission to " +
"edit the client's power level."
}
var powerLevelEvent = new MatrixEvent(event);
// What level do we need for this event type?
var defaultLevel = event.content.events_default;
if (STATE_EVENT_TYPES.indexOf(eventType) !== -1) {
defaultLevel = event.content.state_default;
}
var requiredLevel = event.content.events[eventType] || defaultLevel;
// Parse out what level the client has by abusing the JS SDK
var roomMember = new RoomMember(roomId, userId);
roomMember.setPowerLevelEvent(powerLevelEvent);
if (requiredLevel > roomMember.powerLevel) {
// can the bot update our power level?
var bot = new RoomMember(roomId, self.botClient.credentials.userId);
bot.setPowerLevelEvent(powerLevelEvent);
var levelRequiredToModifyPowerLevels = event.content.events[
"m.room.power_levels"
] || event.content.state_default;
if (levelRequiredToModifyPowerLevels > bot.powerLevel) {
// even the bot has no power here.. give up.
throw new Error(
"Cannot ensure client has power level for event " + eventType +
" : client has " + roomMember.powerLevel + " and we require " +
requiredLevel + " and the bot doesn't have permission to " +
"edit the client's power level."
);
}
// update the client's power level first
return self.botClient.setPowerLevel(
roomId, userId, requiredLevel, powerLevelEvent
const cli = MatrixClientPeg.get();
this.setState({loading: true});
let profileInfo;
try {
profileInfo = await cli.getProfileInfo(this.props.userId);
} catch (err) {
const ErrorDialog = sdk.getComponent('dialogs.ErrorDialog');
Modal.createTrackedDialog(_t('Could not load user profile'), '', ErrorDialog, {
title: _t('Could not load user profile'),
description: ((err && err.message) ? err.message : _t("Operation failed")),
});
this.setState({loading: false});
return;
}
const fakeEvent = new Matrix.MatrixEvent({type: "m.room.member", content: profileInfo});
const member = new Matrix.RoomMember(null, this.props.userId);
member.setMembershipEvent(fakeEvent);
this.setState({member, loading: false});
}
onUserClick: function(event, userId) {
event.preventDefault();
const member = new Matrix.RoomMember(null, userId);
if (!member) { return; }
dis.dispatch({
action: 'view_user',
member: member,
});
},
onUserClick: function(event, userId) {
event.preventDefault();
var MemberInfo = sdk.getComponent('rooms.MemberInfo');
var member = new Matrix.RoomMember(null, userId);
ContextualMenu.createMenu(MemberInfo, {
member: member,
right: window.innerWidth - event.pageX,
top: event.pageY
});
},
getInitialState: function() {
if (this.props.userId) {
var member = new Matrix.RoomMember(null, this.props.userId);
return {
phase: this.Phase.MemberInfo,
member: member,
}
}
else {
return {
phase: this.Phase.MemberList
}
}
},
waitFor.then(() => {
if (params.action === 'chat') {
this._chatCreateOrReuse(userId);
return;
}
this._setPage(PageTypes.UserView);
this.notifyNewScreen('user/' + userId);
const member = new Matrix.RoomMember(null, userId);
dis.dispatch({
action: 'view_user',
member: member,
});
});
} else if (screen.indexOf('group/') == 0) {