Skip to content

Commit 176922a

Browse files
committed
fix(discussion): set correct author type
1 parent ec7b143 commit 176922a

File tree

4 files changed

+31
-25
lines changed

4 files changed

+31
-25
lines changed

src/__mocks__/mockedData.ts

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,8 @@ export const mockedGraphQLResponse: GraphQLSearch<Discussion> = {
300300
author: {
301301
login: 'comment-user',
302302
url: 'https://github.com/comment-user',
303-
type: 'User',
304303
},
304+
bot: {},
305305
replies: {
306306
nodes: [],
307307
},
@@ -312,8 +312,8 @@ export const mockedGraphQLResponse: GraphQLSearch<Discussion> = {
312312
author: {
313313
login: 'comment-user',
314314
url: 'https://github.com/comment-user',
315-
type: 'User',
316315
},
316+
bot: {},
317317
replies: {
318318
nodes: [],
319319
},
@@ -324,8 +324,8 @@ export const mockedGraphQLResponse: GraphQLSearch<Discussion> = {
324324
author: {
325325
login: 'comment-user',
326326
url: 'https://github.com/comment-user',
327-
type: 'User',
328327
},
328+
bot: {},
329329
replies: {
330330
nodes: [
331331
{
@@ -334,8 +334,8 @@ export const mockedGraphQLResponse: GraphQLSearch<Discussion> = {
334334
author: {
335335
login: 'reply-user',
336336
url: 'https://github.com/reply-user',
337-
type: 'User',
338337
},
338+
bot: {},
339339
},
340340
],
341341
},
@@ -346,8 +346,8 @@ export const mockedGraphQLResponse: GraphQLSearch<Discussion> = {
346346
author: {
347347
login: 'comment-user',
348348
url: 'https://github.com/comment-user',
349-
type: 'User',
350349
},
350+
bot: {},
351351
replies: {
352352
nodes: [],
353353
},
@@ -358,8 +358,8 @@ export const mockedGraphQLResponse: GraphQLSearch<Discussion> = {
358358
author: {
359359
login: 'comment-user',
360360
url: 'https://github.com/comment-user',
361-
type: 'User',
362361
},
362+
bot: {},
363363
replies: {
364364
nodes: [
365365
{
@@ -368,8 +368,8 @@ export const mockedGraphQLResponse: GraphQLSearch<Discussion> = {
368368
author: {
369369
login: 'reply-user',
370370
url: 'https://github.com/reply-user',
371-
type: 'User',
372371
},
372+
bot: {},
373373
},
374374
],
375375
},
@@ -380,8 +380,8 @@ export const mockedGraphQLResponse: GraphQLSearch<Discussion> = {
380380
author: {
381381
login: 'comment-user',
382382
url: 'https://github.com/comment-user',
383-
type: 'User',
384383
},
384+
bot: {},
385385
replies: {
386386
nodes: [
387387
{
@@ -390,8 +390,8 @@ export const mockedGraphQLResponse: GraphQLSearch<Discussion> = {
390390
author: {
391391
login: 'reply-user',
392392
url: 'https://github.com/reply-user',
393-
type: 'User',
394393
},
394+
bot: {},
395395
},
396396
],
397397
},
@@ -402,8 +402,8 @@ export const mockedGraphQLResponse: GraphQLSearch<Discussion> = {
402402
author: {
403403
login: 'comment-user',
404404
url: 'https://github.com/comment-user',
405-
type: 'User',
406405
},
406+
bot: {},
407407
replies: {
408408
nodes: [
409409
{
@@ -412,8 +412,8 @@ export const mockedGraphQLResponse: GraphQLSearch<Discussion> = {
412412
author: {
413413
login: 'reply-user',
414414
url: 'https://github.com/reply-user',
415-
type: 'User',
416415
},
416+
bot: {},
417417
},
418418
],
419419
},
@@ -435,8 +435,8 @@ export const mockedGraphQLResponse: GraphQLSearch<Discussion> = {
435435
author: {
436436
login: 'comment-user',
437437
url: 'https://github.com/comment-user',
438-
type: 'User',
439438
},
439+
bot: {},
440440
replies: {
441441
nodes: [],
442442
},
@@ -447,8 +447,8 @@ export const mockedGraphQLResponse: GraphQLSearch<Discussion> = {
447447
author: {
448448
login: 'comment-user',
449449
url: 'https://github.com/comment-user',
450-
type: 'User',
451450
},
451+
bot: {},
452452
replies: {
453453
nodes: [],
454454
},
@@ -459,8 +459,8 @@ export const mockedGraphQLResponse: GraphQLSearch<Discussion> = {
459459
author: {
460460
login: 'comment-user',
461461
url: 'https://github.com/comment-user',
462-
type: 'User',
463462
},
463+
bot: {},
464464
replies: {
465465
nodes: [
466466
{
@@ -469,8 +469,8 @@ export const mockedGraphQLResponse: GraphQLSearch<Discussion> = {
469469
author: {
470470
login: 'reply-user',
471471
url: 'https://github.com/reply-user',
472-
type: 'User',
473472
},
473+
bot: {},
474474
},
475475
],
476476
},
@@ -481,8 +481,8 @@ export const mockedGraphQLResponse: GraphQLSearch<Discussion> = {
481481
author: {
482482
login: 'comment-user',
483483
url: 'https://github.com/comment-user',
484-
type: 'User',
485484
},
485+
bot: {},
486486
replies: {
487487
nodes: [],
488488
},
@@ -493,8 +493,8 @@ export const mockedGraphQLResponse: GraphQLSearch<Discussion> = {
493493
author: {
494494
login: 'comment-user',
495495
url: 'https://github.com/comment-user',
496-
type: 'User',
497496
},
497+
bot: {},
498498
replies: {
499499
nodes: [
500500
{
@@ -503,8 +503,8 @@ export const mockedGraphQLResponse: GraphQLSearch<Discussion> = {
503503
author: {
504504
login: 'reply-user',
505505
url: 'https://github.com/reply-user',
506-
type: 'User',
507506
},
507+
bot: {},
508508
},
509509
],
510510
},
@@ -515,8 +515,8 @@ export const mockedGraphQLResponse: GraphQLSearch<Discussion> = {
515515
author: {
516516
login: 'comment-user',
517517
url: 'https://github.com/comment-user',
518-
type: 'User',
519518
},
519+
bot: {},
520520
replies: {
521521
nodes: [
522522
{
@@ -525,8 +525,8 @@ export const mockedGraphQLResponse: GraphQLSearch<Discussion> = {
525525
author: {
526526
login: 'reply-user',
527527
url: 'https://github.com/reply-user',
528-
type: 'User',
529528
},
529+
bot: {},
530530
},
531531
],
532532
},
@@ -537,8 +537,8 @@ export const mockedGraphQLResponse: GraphQLSearch<Discussion> = {
537537
author: {
538538
login: 'comment-user',
539539
url: 'https://github.com/comment-user',
540-
type: 'User',
541540
},
541+
bot: {},
542542
replies: {
543543
nodes: [
544544
{
@@ -547,8 +547,8 @@ export const mockedGraphQLResponse: GraphQLSearch<Discussion> = {
547547
author: {
548548
login: 'reply-user',
549549
url: 'https://github.com/reply-user',
550-
type: 'User',
551550
},
551+
bot: {},
552552
},
553553
],
554554
},

src/typesGithub.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ export interface SubjectUser {
144144
export interface DiscussionAuthor {
145145
login: string;
146146
url: string;
147-
type: string;
148147
}
149148

150149
export interface Repository {
@@ -346,6 +345,9 @@ export interface DiscussionComment {
346345
databaseId: string | number;
347346
createdAt: string;
348347
author: DiscussionAuthor;
348+
bot: {
349+
login?: string;
350+
};
349351
replies?: {
350352
nodes: DiscussionComment[];
351353
};

src/utils/helpers.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,11 @@ export async function fetchDiscussion(
161161
author {
162162
login
163163
url
164-
type
164+
}
165+
bot: author {
166+
... on Bot {
167+
login
168+
}
165169
}
166170
}
167171

src/utils/subject.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ async function getGitifySubjectForDiscussion(
116116
discussionUser = {
117117
login: latestDiscussionComment.author.login,
118118
html_url: latestDiscussionComment.author.url,
119-
type: latestDiscussionComment.author.type,
119+
type: latestDiscussionComment.bot?.login ? 'Bot' : 'User',
120120
};
121121
}
122122

0 commit comments

Comments
 (0)