@@ -67,25 +67,33 @@ let jira;
6767 } ) ;
6868
6969 // A bit of a hack, but the endpoint isn't available in the SDK
70- jira . fetchUsers = function ( list ) {
71- const names = Array . from ( list )
72- . map ( ( n ) => {
73- return `&key=${ n } ` ;
74- } )
75- . join ( "" ) ;
76- return this . doRequest (
77- this . makeRequestHeader (
78- this . makeUri ( {
79- pathname : "/user/bulk/migration?maxResults=1000" + names ,
80- } ) ,
81- {
82- method : "GET" ,
83- followAllRedirects : true ,
84- }
85- )
86- ) ;
70+ jira . fetchUsers = async function ( list ) {
71+ const users = { } ;
72+
73+ for ( let user of list ) {
74+ const results = await this . doRequest (
75+ this . makeRequestHeader (
76+ this . makeUri ( {
77+ pathname : "/user/search?query=" + user ,
78+ } ) ,
79+ {
80+ method : "GET" ,
81+ followAllRedirects : true ,
82+ }
83+ )
84+ ) ;
85+
86+ if ( results . length != 1 ) {
87+ throw new Error ( "Could not identify a single user for " + user ) ;
88+ }
89+
90+ users [ user ] = results [ 0 ] . accountId ;
91+ }
92+
93+ return users ;
8794 } ;
8895
96+
8997 let content = "" ;
9098
9199 // Is there a filename? If so read the content from there
@@ -119,14 +127,7 @@ let jira;
119127 }
120128
121129 // Map assignee name to IDs
122- const userIds = { } ;
123- const users = await jira . fetchUsers ( userNames ) ;
124- for ( const u of users ) {
125- if ( u . accountId == "unknown" ) {
126- continue ;
127- }
128- userIds [ u . key ] = u . accountId ;
129- }
130+ const userIds = await jira . fetchUsers ( userNames ) ;
130131
131132 // Validate that all usernames provided were valid
132133 // Parent tickets
0 commit comments