fix(api): issue #1124
This commit is contained in:
parent
7a5f08cf83
commit
0821d179df
@ -32,10 +32,10 @@ export default (server: FastifyInstance, _options: RouteShorthandOptions, done:
|
|||||||
const ua = new UAParser(userAgent ?? '').getResult();
|
const ua = new UAParser(userAgent ?? '').getResult();
|
||||||
const hostname = new URL(url).hostname.split('.').slice(-3).join('.').replace('www.', '');
|
const hostname = new URL(url).hostname.split('.').slice(-3).join('.').replace('www.', '');
|
||||||
const existingIssues = await octokit.request('GET /search/issues', {
|
const existingIssues = await octokit.request('GET /search/issues', {
|
||||||
per_page: 1,
|
per_page: 50,
|
||||||
q: `in:title+is:issue+repo:${environment.github.owner}/${environment.github.repo}+${hostname}`,
|
q: `in:title+is:issue+repo:${environment.github.owner}/${environment.github.repo}+${hostname}`,
|
||||||
});
|
});
|
||||||
const existingIssue = existingIssues.data.items[0];
|
const existingIssue = existingIssues.data.items.find((issue) => hostname === issue.title);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (existingIssue) {
|
if (existingIssue) {
|
||||||
|
@ -23,17 +23,17 @@ export default (server: FastifyInstance, _options: RouteShorthandOptions, done:
|
|||||||
try {
|
try {
|
||||||
const { hostname } = request.params;
|
const { hostname } = request.params;
|
||||||
const existingIssues = await octokit.request('GET /search/issues', {
|
const existingIssues = await octokit.request('GET /search/issues', {
|
||||||
per_page: 1,
|
per_page: 50,
|
||||||
q: `in:title+is:issue+repo:${environment.github.owner}/${environment.github.repo}+${hostname}`,
|
q: `in:title+is:issue+repo:${environment.github.owner}/${environment.github.repo}+${hostname}`,
|
||||||
});
|
});
|
||||||
const existingIssue = existingIssues.data.items[0];
|
const existingIssue = existingIssues.data.items.find(
|
||||||
|
(issue) =>
|
||||||
|
hostname === issue.title &&
|
||||||
|
(issue.state === 'open' ||
|
||||||
|
(issue.state === 'closed' && issue.labels.some((label) => label.name === 'wontfix')))
|
||||||
|
);
|
||||||
|
|
||||||
if (
|
if (existingIssue) {
|
||||||
existingIssue &&
|
|
||||||
(existingIssue.state === 'open' ||
|
|
||||||
(existingIssue.state === 'closed' &&
|
|
||||||
existingIssue.labels.some((label) => label.name === 'wontfix')))
|
|
||||||
) {
|
|
||||||
reply.send({
|
reply.send({
|
||||||
data: {
|
data: {
|
||||||
flags: existingIssue.labels.map((label) => label.name),
|
flags: existingIssue.labels.map((label) => label.name),
|
||||||
|
Loading…
Reference in New Issue
Block a user