Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Remove quotes
.replace(/['"]+/g, '')
// Separate by comma into an array
.split(',')
// Reject any non-numeric values
.filter((id) => /^[0-9]+$/.test(id));
if (excapedIds.length === 0 || excapedIds.length > 10) {
this.peersModule.remove(req.ip, parseInt(req.headers.port as string, 10));
throw new APIError('Invalid block id sequence', 200);
}
const common = await this.BlocksModel.findOne({
limit: 1,
order: [['height', 'DESC']],
raw : true,
where: { id: { [Op.in]: excapedIds } },
});
const tmpPB = this.pblocksFactory({data: {block: common}});
const bytesBlock = common !== null ? tmpPB.generateBytesBlock(common) : null;
return this.getResponse({ common: bytesBlock }, 'transportBlocks', 'commonBlock');
}
console.log('Could not find any matching tiers.');
process.exit(1);
}
const tierIds = tiers.map(tier => tier.id);
const allOrders = await models.Order.findAll({
where: {
status: status.ACTIVE,
SubscriptionId: { [Op.ne]: null },
deletedAt: null,
},
include: [
{
model: models.Tier,
where: { id: { [Op.in]: tierIds } },
},
{ model: models.Collective, as: 'fromCollective' },
{ model: models.User, as: 'createdByUser' },
{ model: models.Collective, as: 'collective' },
{
model: models.Subscription,
where: {
isActive: true,
deletedAt: null,
deactivatedAt: null,
},
},
],
});
return filter(allOrders, order => {
.then(([hdsrPubIds]) => {
console.log('hi', hdsrPubIds);
const findBranches = v6_Branch.findAll({
where: {
pubId: { [Op.in]: hdsrPubIds },
},
});
const findBranchPermissions = v6_BranchPermission.findAll({
where: {
pubId: { [Op.in]: hdsrPubIds },
},
});
const findMerges = v6_Merge.findAll({
where: {
pubId: { [Op.in]: hdsrPubIds },
},
});
return Promise.all([findBranches, findBranchPermissions, findMerges]);
})
.then(([branches, branchPermissions, merges]) => {
public async signTermsMatching(user: IMSCUser, urls: string[]): Promise {
const terms = await TermsTextRecord.findAll({where: {url: {[Op.in]: urls}}});
const signed = await TermsSignedRecord.findAll({where: {userId: user.userId}});
const toAdd = terms.filter(t => !signed.find(s => s.termsId === t.termsId));
for (const termsToSign of toAdd) {
await TermsSignedRecord.create({termsId: termsToSign.id, userId: user.userId});
}
}
import { Sequelize, Op } from 'sequelize';
import { logger } from './logger';
import * as sqlFormatter from 'sql-formatter';
import { config } from './config';
const bd = config.getBd();
const operatorsAliases = {
$eq: Op.eq,
$ne: Op.ne,
$gte: Op.gte,
$gt: Op.gt,
$lte: Op.lte,
$lt: Op.lt,
$not: Op.not,
$in: Op.in,
$notIn: Op.notIn,
$is: Op.is,
$like: Op.like,
$notLike: Op.notLike,
$iLike: Op.iLike,
$notILike: Op.notILike,
$regexp: Op.regexp,
$notRegexp: Op.notRegexp,
$iRegexp: Op.iRegexp,
$notIRegexp: Op.notIRegexp,
$between: Op.between,
$notBetween: Op.notBetween,
$overlap: Op.overlap,
$contains: Op.contains,
$contained: Op.contained,
$adjacent: Op.adjacent,
if (body.senderId) {
whereClause.senderId[Op.in].push(body.senderId.toUpperCase());
}
}
if (Array.isArray(body.recipientIds)) {
whereClause.recipientId = { [Op.in]: body.recipientIds.map((item) => item.toUpperCase()) };
if (body.recipientId) {
whereClause.recipientId[Op.in].push(body.recipientId.toUpperCase());
}
}
if (Array.isArray(body.senderPublicKeys)) {
whereClause.senderPublicKey = { [Op.in]: body.senderPublicKeys.map((pk) => Buffer.from(pk, 'hex')) };
if (body.senderPublicKey) {
whereClause.senderPublicKey[Op.in].push(Buffer.from(body.senderPublicKey, 'hex'));
}
}
removeEmptyObjKeys(whereClause, true);
for (const k in whereClause) {
if (Object.keys(whereClause[k]).length === 0 && Object.getOwnPropertySymbols(whereClause[k]).length === 0) {
delete whereClause[k];
}
}
return whereClause;
}
async getArticleAuthor(articleId, options = {}) {
const result = await ArticleAuthor.findAll({
where: {
article_id: articleId
}
})
let ids = result.map(v => v.author_id)
return await Author.findAll({
where: {
id: {
[Op.in]: ids
}
},
...options
})
}
function validateGeneratorNames(seq, generatorNames) {
if (!generatorNames || !generatorNames.length) {
return Promise.resolve([]);
}
if (common.checkDuplicatesInStringArray(generatorNames)) {
throw new dbErrors.DuplicateGeneratorError({
resourceType: 'Generator',
resourceKey: generatorNames,
});
}
if (!generatorNames || !generatorNames.length) return [];
return seq.models.Generator.findAll({
where: { name: { [Op.in]: generatorNames } },
})
.then((generators) => {
if (generators.length === generatorNames.length) {
return generators;
} else {
throw new dbErrors.ResourceNotFoundError({
resourceType: 'Generator',
resourceKey: generatorNames,
});
}
});
}
const getUsers = memberships => {
if (!memberships || memberships.length === 0) return [];
return models.User.findAll({
where: {
CollectiveId: { [Op.in]: memberships.map(m => m.MemberCollectiveId) },
},
});
};
Tier.appendTier = (collective, backerCollectives) => {
const backerCollectivesIds = backerCollectives.map(b => b.id);
debug('appendTier', collective.name, 'backers: ', backerCollectives.length);
return models.Member.findAll({
where: {
MemberCollectiveId: { [Op.in]: backerCollectivesIds },
CollectiveId: collective.id,
},
include: [{ model: models.Tier }],
}).then(memberships => {
const membershipsForBackerCollective = {};
memberships.map(m => {
membershipsForBackerCollective[m.MemberCollectiveId] = m.Tier;
});
return backerCollectives.map(backerCollective => {
backerCollective.tier = membershipsForBackerCollective[backerCollective.id];
debug('appendTier for', backerCollective.name, ':', backerCollective.tier && backerCollective.tier.slug);
return backerCollective;
});
});
};