Skip to content
Snippets Groups Projects
Unverified Commit 219570e0 authored by syuilo's avatar syuilo
Browse files

Update job handlers

parent 69df556f
No related branches found
No related tags found
No related merge requests found
......@@ -7,7 +7,7 @@ import instanceChart from '../../services/chart/instance';
let latest: string = null;
export default async (job: Bull.Job, done: any): Promise<void> => {
export default async (job: Bull.Job): Promise<void> => {
const { host } = new URL(job.data.to);
try {
......@@ -29,8 +29,6 @@ export default async (job: Bull.Job, done: any): Promise<void> => {
instanceChart.requestSent(i.host, true);
});
done();
} catch (res) {
// Update stats
registerOrFetchInstanceDoc(host).then(i => {
......@@ -51,13 +49,12 @@ export default async (job: Bull.Job, done: any): Promise<void> => {
if (res.statusCode >= 400 && res.statusCode < 500) {
// HTTPステータスコード4xxはクライアントエラーであり、それはつまり
// 何回再送しても成功することはないということなのでエラーにはしないでおく
done();
} else {
done(res.statusMessage);
return;
}
return res.statusMessage;
} else {
queueLogger.warn(`deliver failed: ${res} to=${job.data.to}`);
done();
}
}
};
......@@ -15,7 +15,7 @@ import instanceChart from '../../services/chart/instance';
const logger = new Logger('inbox');
// ユーザーのinboxにアクティビティが届いた時の処理
export default async (job: Bull.Job, done: any): Promise<void> => {
export default async (job: Bull.Job): Promise<void> => {
const signature = job.data.signature;
const activity = job.data.activity;
......@@ -33,7 +33,6 @@ export default async (job: Bull.Job, done: any): Promise<void> => {
const { username, host } = parseAcct(keyIdLower.slice('acct:'.length));
if (host === null) {
logger.warn(`request was made by local user: @${username}`);
done();
return;
}
......@@ -42,7 +41,6 @@ export default async (job: Bull.Job, done: any): Promise<void> => {
ValidateActivity(activity, host);
} catch (e) {
logger.warn(e.message);
done();
return;
}
......@@ -51,7 +49,6 @@ export default async (job: Bull.Job, done: any): Promise<void> => {
const instance = await Instance.findOne({ host: host.toLowerCase() });
if (instance && instance.isBlocked) {
logger.warn(`Blocked request: ${host}`);
done();
return;
}
......@@ -63,7 +60,6 @@ export default async (job: Bull.Job, done: any): Promise<void> => {
ValidateActivity(activity, host);
} catch (e) {
logger.warn(e.message);
done();
return;
}
......@@ -72,7 +68,6 @@ export default async (job: Bull.Job, done: any): Promise<void> => {
const instance = await Instance.findOne({ host: host.toLowerCase() });
if (instance && instance.isBlocked) {
logger.warn(`Blocked request: ${host}`);
done();
return;
}
......@@ -92,7 +87,6 @@ export default async (job: Bull.Job, done: any): Promise<void> => {
} else {
updatePerson(activity.actor, null, activity.object);
}
done();
return;
}
}
......@@ -103,13 +97,11 @@ export default async (job: Bull.Job, done: any): Promise<void> => {
}
if (user === null) {
done(new Error('failed to resolve user'));
return;
throw new Error('failed to resolve user');
}
if (!httpSignature.verifySignature(signature, user.publicKey.publicKeyPem)) {
logger.error('signature verification failed');
done();
return;
}
......@@ -136,12 +128,7 @@ export default async (job: Bull.Job, done: any): Promise<void> => {
});
// アクティビティを処理
try {
await perform(user, activity);
done();
} catch (e) {
done(e);
}
await perform(user, activity);
};
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment