Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let rs = map(name, (one, index) => {
let parent: any = ''
if (index === 2) {
// 可能存在区名一样的情况,比如南山区
parent = find(list, item => {
return item.name === name[1]
}) || { value: '__' }
if (specialMap[name[0]]) {
parent = {
value: specialMap[name[0]]
}
}
return find(list, item => {
return item.name === one && item.parent === parent.value
})
} else {
if (index === 1 && specialMap[name[0]]) {
return {
value: specialMap[name[0]]
}
return tokenize(message).map(token => {
switch (token.type) {
case 'italic':
return { type: 'italic', content: parse(token.text, opts) };
case 'bold':
return { type: 'bold', content: parse(token.text, opts) };
case 'code':
return { type: 'code', content: [ token.text ] };
case 'strike':
return { type: 'strike', content: parse(token.text, opts) };
case 'mention':
const mention = users && find(users, user => user.username.toLowerCase() === token.text.toLowerCase());
return mention
? { type: 'mention', user: mention }
: token.raw;
case 'link':
return { type: 'link', text: token.text, href: token.text };
default:
return token.text;
}
});
}
groupsIds.forEach(groupId => {
const resultFromCache = find(cacheResults, result => utils.equalArray(result.groupId, groupId));
if (!resultFromCache) {
missingGroupIds.push(groupId);
}
});
return {
export function assertExpectedGroups(groups: Array, expectedGroupIds: Array) {
const missingGroupIds = [];
for (const groupId of expectedGroupIds) {
const fetchedGroup = find(groups, group => utils.equalArray(group.groupId, groupId));
if (!fetchedGroup) {
missingGroupIds.push(utils.toBase64(groupId));
}
}
if (missingGroupIds.length > 0) {
const message = `The following groups do not exist on the trustchain: "${missingGroupIds.join('", "')}"`;
throw new InvalidArgument(message);
}
}
let rs = map(value, (one, index) => {
if (list.length && Object.prototype.toString.call(list[0]) === '[object Array]') {
return find(list[index], item => {
return item.value === one
})
} else {
return find(list, item => {
return item.value === one
})
}
})
rs = rs.filter(one => {
const PanelGroup = ({ children, className, selected }) => {
const view = find(children, child => child.props.name === selected);
return (
<div>
{view}
</div>
);
};
return (dispatch, getState) => {
const settings = settingsSelector(getState());
const currentUser = currentUserSelector(getState());
const users = userListSelector(getState());
const sender = find(users, user => user._id === message.userID);
const mentions = [
...users.map(user => user.username),
...getAvailableGroupMentions(sender)
];
if (isMuted(getState(), message.userID)) {
return;
}
const parsed = parseChatMarkup(message.text, { mentions });
resolveMentions(parsed, getState());
const isMention = currentUser ? hasMention(parsed, currentUser._id) : false;
dispatch({
type: RECEIVE_MESSAGE,
export function verifyDeviceRevocation(entry: DeviceRevocationEntry, authorUser: User) {
const authorDevice: Device = find(authorUser.devices, d => utils.equalArray(d.deviceId, entry.author));
if (!tcrypto.verifySignature(entry.hash, entry.signature, authorDevice.devicePublicSignatureKey))
throw new InvalidBlockError('invalid_signature', 'signature is invalid', { entry, authorUser });
const revokedDevice = find(authorUser.devices, d => utils.equalArray(d.deviceId, entry.device_id));
if (!revokedDevice)
throw new InvalidBlockError('invalid_revoked_device', 'can\'t find target of device revocation block', { entry });
if (revokedDevice.revoked)
throw new InvalidBlockError('device_already_revoked', 'target of device_revocation block is already revoked', { entry, revokedDevice });
if (entry.nature === NATURE.device_revocation_v1) {
if (authorUser.userPublicKeys.length !== 0)
throw new InvalidBlockError('invalid_revocation_version', 'cannot use a device revocation v1 if the target has a user key', { entry, authorUser });
} else {
const newKeys = entry.user_keys;
if (!newKeys)
if (specialMap[name[0]]) {
parent = {
value: specialMap[name[0]]
}
}
return find(list, item => {
return item.name === one && item.parent === parent.value
})
} else {
if (index === 1 && specialMap[name[0]]) {
return {
value: specialMap[name[0]]
}
}
return find(list, item => {
return item.name === one
})
}
})
let rs = map(value, (one, index) => {
if (list.length && Object.prototype.toString.call(list[0]) === '[object Array]') {
return find(list[index], item => {
return item.value === one
})
} else {
return find(list, item => {
return item.value === one
})
}
})
rs = rs.filter(one => {