Perform processing that does not use the database before connecting to the database (#7168)
This commit is contained in:
parent
3c722fe687
commit
609bf93029
1 changed files with 45 additions and 44 deletions
|
@ -329,10 +329,8 @@ const startWorker = (workerId) => {
|
|||
|
||||
// Only messages that may require filtering are statuses, since notifications
|
||||
// are already personalized and deletes do not matter
|
||||
if (needsFiltering && event === 'update') {
|
||||
pgPool.connect((err, client, done) => {
|
||||
if (err) {
|
||||
log.error(err);
|
||||
if (!needsFiltering || event !== 'update') {
|
||||
transmit();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -342,11 +340,21 @@ const startWorker = (workerId) => {
|
|||
|
||||
if (Array.isArray(req.filteredLanguages) && req.filteredLanguages.indexOf(unpackedPayload.language) !== -1) {
|
||||
log.silly(req.requestId, `Message ${unpackedPayload.id} filtered by language (${unpackedPayload.language})`);
|
||||
done();
|
||||
return;
|
||||
}
|
||||
|
||||
if (req.accountId) {
|
||||
// When the account is not logged in, it is not necessary to confirm the block or mute
|
||||
if (!req.accountId) {
|
||||
transmit();
|
||||
return;
|
||||
}
|
||||
|
||||
pgPool.connect((err, client, done) => {
|
||||
if (err) {
|
||||
log.error(err);
|
||||
return;
|
||||
}
|
||||
|
||||
const queries = [
|
||||
client.query(`SELECT 1 FROM blocks WHERE (account_id = $1 AND target_account_id IN (${placeholders(targetAccountIds, 2)})) OR (account_id = $2 AND target_account_id = $1) UNION SELECT 1 FROM mutes WHERE account_id = $1 AND target_account_id IN (${placeholders(targetAccountIds, 2)})`, [req.accountId, unpackedPayload.account.id].concat(targetAccountIds)),
|
||||
];
|
||||
|
@ -367,14 +375,7 @@ const startWorker = (workerId) => {
|
|||
done();
|
||||
log.error(err);
|
||||
});
|
||||
} else {
|
||||
done();
|
||||
transmit();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
transmit();
|
||||
}
|
||||
};
|
||||
|
||||
subscribe(`${redisPrefix}${id}`, listener);
|
||||
|
|
Loading…
Reference in a new issue