File tree Expand file tree Collapse file tree 4 files changed +27
-7
lines changed
Expand file tree Collapse file tree 4 files changed +27
-7
lines changed Original file line number Diff line number Diff line change @@ -102,6 +102,7 @@ export class AppHandler {
102102 apiKey = await this . services . configService . getApiKey ( context ) ;
103103 config = await this . services . configService . getConfig ( context , apiKey ) ;
104104
105+ await this . services . appService . init ( context ) ;
105106 await callback ( apiKey , config ) ;
106107 } catch ( error ) {
107108 if ( 'repository' in context . payload ) {
@@ -129,7 +130,6 @@ export class AppHandler {
129130 ) : Promise < void > {
130131 await this . safeEventHandler ( context , async ( apiKey , config ) => {
131132 await this . handlers . contributorHandler . safeCacheContributors ( context , apiKey ) ;
132- await this . services . appService . init ( context ) ;
133133 await this . handlers . chatHandler . handle ( context , apiKey , config ) ;
134134 } ) ;
135135 }
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import { GitHubService } from './github.service';
77export class AppService {
88 private static instance : AppService ;
99 private appData ?: RestEndpointMethodTypes [ 'apps' ] [ 'getAuthenticated' ] [ 'response' ] [ 'data' ] ;
10+ private user ?: RestEndpointMethodTypes [ 'users' ] [ 'getByUsername' ] [ 'response' ] [ 'data' ] ;
1011
1112 private constructor ( ) { }
1213
@@ -19,11 +20,13 @@ export class AppService {
1920 }
2021
2122 async init ( context : Context ) : Promise < void > {
22- if ( ! this . appData ) {
23+ if ( ! this . appData || ! this . user ) {
2324 try {
2425 const { data } = await GitHubService . getAuthenticated ( context ) ;
2526
2627 this . appData = data ;
28+
29+ this . user = await GitHubService . getByUsername ( this . appData ! . slug + '[bot]' , context ) ;
2730 } catch ( error ) {
2831 throw new SystemError ( 'Failed to get authenticated app data' , Severity . ERROR , error ) ;
2932 }
@@ -42,9 +45,15 @@ export class AppService {
4245 return this . appData ! . slug ;
4346 }
4447
45- getId ( ) : number | undefined {
48+ getLogin ( ) : string {
49+ this . ensureInitialized ( ) ;
50+
51+ return this . user ! . login ;
52+ }
53+
54+ getEmail ( ) : string {
4655 this . ensureInitialized ( ) ;
4756
48- return this . appData ! . id ;
57+ return ` ${ this . user ! . id } + ${ this . user ! . login } @users.noreply.github.com` ;
4958 }
5059}
Original file line number Diff line number Diff line change @@ -70,6 +70,17 @@ export class GitHubService {
7070 return context . octokit . apps . getAuthenticated ( ) ;
7171 }
7272
73+ static getByUsername = async (
74+ username : string ,
75+ context : Context
76+ ) : Promise < RestEndpointMethodTypes [ 'users' ] [ 'getByUsername' ] [ 'response' ] [ 'data' ] > => {
77+ const { data } = await context . octokit . users . getByUsername ( {
78+ username
79+ } ) ;
80+
81+ return data ;
82+ } ;
83+
7384 static paginateListComments (
7485 context : Context
7586 ) : Promise < RestEndpointMethodTypes [ 'issues' ] [ 'listComments' ] [ 'response' ] [ 'data' ] > {
Original file line number Diff line number Diff line change @@ -37,9 +37,9 @@ export class ReviewSkipConditions {
3737 const commitSha = this . context . payload . after ;
3838 const commit = await GitHubService . getCommit ( commitSha , this . context ) ;
3939 const { message } = commit . data . commit ;
40- const slug = this . appService . getAppSlug ( ) ;
41- const id = this . appService . getId ( ) ;
42- const coAuthoredMessage = `${ slug } [bot] <${ id } + ${ slug } [bot]@users.noreply.github.com >` ;
40+ const login = this . appService . getLogin ( ) ;
41+ const email = this . appService . getEmail ( ) ;
42+ const coAuthoredMessage = `${ login } <${ email } >` ;
4343
4444 return message . toLowerCase ( ) . includes ( coAuthoredMessage . toLowerCase ( ) ) ;
4545 }
You can’t perform that action at this time.
0 commit comments