feat(api): add new comment if issue exists with the new details
This commit is contained in:
parent
8d3b289418
commit
034993fbb6
@ -58,6 +58,13 @@ export default (server: FastifyInstance, _options: RouteShorthandOptions, done:
|
|||||||
state: 'open',
|
state: 'open',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
await octokit.request('POST /repos/{owner}/{repo}/issues/{issue_number}/comments', {
|
||||||
|
owner: environment.github.owner,
|
||||||
|
repo: environment.github.repo,
|
||||||
|
issue_number: existingIssue.number,
|
||||||
|
body: generateText(request.body, ua),
|
||||||
|
});
|
||||||
|
|
||||||
reply.send({
|
reply.send({
|
||||||
data: existingIssue.html_url,
|
data: existingIssue.html_url,
|
||||||
success: true,
|
success: true,
|
||||||
@ -67,21 +74,7 @@ export default (server: FastifyInstance, _options: RouteShorthandOptions, done:
|
|||||||
|
|
||||||
const response = await octokit.request('POST /repos/{owner}/{repo}/issues', {
|
const response = await octokit.request('POST /repos/{owner}/{repo}/issues', {
|
||||||
assignees: [environment.github.owner],
|
assignees: [environment.github.owner],
|
||||||
body: [
|
body: generateText(request.body, ua),
|
||||||
'## Specifications',
|
|
||||||
...(ua.browser.name && ua.browser.version
|
|
||||||
? ['#### Browser', `${ua.browser.name} (${ua.browser.version})`]
|
|
||||||
: []),
|
|
||||||
...(ua.device.type && ua.device.vendor
|
|
||||||
? ['#### Device', `${ua.device.vendor} (${ua.device.type})`]
|
|
||||||
: []),
|
|
||||||
'#### Reason',
|
|
||||||
request.body.reason ?? '-',
|
|
||||||
'#### URL',
|
|
||||||
request.body.url,
|
|
||||||
'#### Version',
|
|
||||||
request.body.version,
|
|
||||||
].join('\n'),
|
|
||||||
labels: ['bug'],
|
labels: ['bug'],
|
||||||
owner: environment.github.owner,
|
owner: environment.github.owner,
|
||||||
repo: environment.github.repo,
|
repo: environment.github.repo,
|
||||||
@ -103,3 +96,21 @@ export default (server: FastifyInstance, _options: RouteShorthandOptions, done:
|
|||||||
|
|
||||||
done();
|
done();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function generateText(body: PostReportBody, ua: UAParser.IResult): string {
|
||||||
|
return [
|
||||||
|
'## Issue information',
|
||||||
|
...(ua.browser.name && ua.browser.version
|
||||||
|
? ['#### 🖥️ Browser', `${ua.browser.name} (${ua.browser.version})`]
|
||||||
|
: []),
|
||||||
|
...(ua.device.type && ua.device.vendor
|
||||||
|
? ['#### 📱 Device', `${ua.device.vendor} (${ua.device.type})`]
|
||||||
|
: []),
|
||||||
|
'#### 📝 Reason',
|
||||||
|
body.reason ?? '-',
|
||||||
|
'#### 🔗 URL',
|
||||||
|
body.url,
|
||||||
|
'#### 🏷️ Version',
|
||||||
|
body.version,
|
||||||
|
].join('\n');
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user