Skip to content

Commit bf16c9f

Browse files
committed
Properly handle case for implicitly getting the currently-logged-in user
1 parent 784f89d commit bf16c9f

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

package/main.tcl

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,22 @@ namespace eval ::jira {
493493
}
494494
}
495495

496+
#
497+
# Get info on the currenty-logged-in user. User data will be stored in _result.
498+
#
499+
proc getCurrentUser {_result} {
500+
upvar 1 $_result result
501+
unset -nocomplain result
502+
503+
set url "[::jira::baseurl]/rest/api/2/myself"
504+
if {[::jira::raw $url GET json]} {
505+
array set result [::yajl::json2dict $json(data)]
506+
return 1
507+
} else {
508+
return 0
509+
}
510+
}
511+
496512
#
497513
# Given an email address, try to find a user with that address. This proc only
498514
# returns true if one and only one user is found. In that case, the user data
@@ -763,7 +779,7 @@ namespace eval ::jira {
763779
#
764780
# Parse user JSON and generate basic BasicUser JSON.
765781
#
766-
proc parseBasicUser {key _result args} {
782+
proc parseBasicUser {email _result args} {
767783
::jira::parse_args args argarray
768784

769785
upvar 1 $_result result
@@ -773,8 +789,12 @@ namespace eval ::jira {
773789
array set result $argarray(userDefinition)
774790
return
775791
}
776-
777-
::jira::getUserByEmail $key getUserResult
792+
793+
if {$email eq ""} {
794+
::jira::getCurrentUser getUserResult
795+
} else {
796+
::jira::getUserByEmail $email getUserResult
797+
}
778798

779799
set keyMap [list self displayName active]
780800

0 commit comments

Comments
 (0)