mirror of
https://github.com/wassname/talk.git
synced 2026-09-12 13:01:11 +08:00
Wrap Slack call in process.nextTick() to avoid blocking comment creation.
This commit is contained in:
@@ -19,24 +19,26 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
} = result;
|
} = result;
|
||||||
const username = context.user.username;
|
const username = context.user.username;
|
||||||
const response = await fetch(SLACK_WEBHOOK_URL, {
|
process.nextTick(async () => {
|
||||||
method: 'POST',
|
const response = await fetch(SLACK_WEBHOOK_URL, {
|
||||||
headers: {
|
method: 'POST',
|
||||||
'Content-Type': 'application/json',
|
headers: {
|
||||||
},
|
'Content-Type': 'application/json',
|
||||||
timeout: SLACK_WEBHOOK_TIMEOUT,
|
},
|
||||||
body: JSON.stringify({
|
timeout: SLACK_WEBHOOK_TIMEOUT,
|
||||||
attachments: [{
|
body: JSON.stringify({
|
||||||
text: text,
|
attachments: [{
|
||||||
footer: `Comment by ${username}`,
|
text: text,
|
||||||
ts: Math.floor(Date.parse(createdAt) / 1000),
|
footer: `Comment by ${username}`,
|
||||||
}]
|
ts: Math.floor(Date.parse(createdAt) / 1000),
|
||||||
}),
|
}]
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
if (!response.ok) {
|
||||||
|
const responseText = await response.text();
|
||||||
|
console.trace(`Posting to Slack failed with HTTP code ${response.status} and body '${responseText}'`);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
if (!response.ok) {
|
|
||||||
const responseText = await response.text();
|
|
||||||
console.trace(`Posting to Slack failed with HTTP code ${response.status} and body '${responseText}'`);
|
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user