@@ -25,6 +25,8 @@ use Bugzilla::Search;
2525use Bugzilla::User;
2626use Bugzilla::User::Setting;
2727use Bugzilla::Util qw( clean_text datetime_from diff_arrays) ;
28+ use Bugzilla::WebService::Util qw( filter_wants) ;
29+ use Scalar::Util qw( blessed) ;
2830
2931use constant UNAVAILABLE_RE => qr /\b (?:unavailable|pto|away)\b / i ;
3032use constant MENTOR_LIMIT => 10;
@@ -1064,4 +1066,51 @@ sub config_modify_panels {
10641066 };
10651067}
10661068
1069+ #
1070+ # hooks
1071+ #
1072+
1073+ sub webservice_user_get {
1074+ my ($self , $args ) = @_ ;
1075+ my ($webservice , $params , $users ) = @$args {qw( webservice params users) };
1076+
1077+ return unless filter_wants($params , ' requests' );
1078+
1079+ my $ids = [
1080+ map { blessed($_ -> {id }) ? $_ -> {id }-> value : $_ -> {id } }
1081+ grep { exists $_ -> {id } }
1082+ @$users
1083+ ];
1084+
1085+ return unless @$ids ;
1086+
1087+ my %user_map = map { $_ -> id => $_ } @{ Bugzilla::User-> new_from_list($ids ) };
1088+
1089+ foreach my $user (@$users ) {
1090+ my $id = blessed($user -> {id }) ? $user -> {id }-> value : $user -> {id };
1091+ my $user_obj = $user_map {$id };
1092+
1093+ $user -> {requests } = {
1094+ review => {
1095+ blocked => $webservice -> type(' boolean' , $user_obj -> reviews_blocked),
1096+ pending => $webservice -> type(' int' , $user_obj -> {review_request_count }),
1097+ },
1098+ feedback => {
1099+ # reviews_blocked includes feedback as well
1100+ blocked => $webservice -> type(' boolean' , $user_obj -> reviews_blocked),
1101+ pending => $webservice -> type(' int' , $user_obj -> {feedback_request_count }),
1102+ },
1103+ needinfo => {
1104+ blocked => $webservice -> type(' boolean' , $user_obj -> needinfo_blocked),
1105+ pending => $webservice -> type(' int' , $user_obj -> {needinfo_request_count }),
1106+ },
1107+ };
1108+ }
1109+ }
1110+
1111+ sub webservice_user_suggest {
1112+ my ($self , $args ) = @_ ;
1113+ $self -> webservice_user_get($args );
1114+ }
1115+
10671116__PACKAGE__ -> NAME;
0 commit comments