diff options
Diffstat (limited to 'extensions/Review')
-rw-r--r-- | extensions/Review/Extension.pm | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/extensions/Review/Extension.pm b/extensions/Review/Extension.pm index 47edd69a6..406c29c7c 100644 --- a/extensions/Review/Extension.pm +++ b/extensions/Review/Extension.pm @@ -25,6 +25,8 @@ use Bugzilla::Search; use Bugzilla::User; use Bugzilla::User::Setting; use Bugzilla::Util qw(clean_text datetime_from diff_arrays); +use Bugzilla::WebService::Util qw(filter_wants); +use Scalar::Util qw(blessed); use constant UNAVAILABLE_RE => qr/\b(?:unavailable|pto|away)\b/i; use constant MENTOR_LIMIT => 10; @@ -1064,4 +1066,51 @@ sub config_modify_panels { }; } +# +# hooks +# + +sub webservice_user_get { + my ($self, $args) = @_; + my ($webservice, $params, $users) = @$args{qw(webservice params users)}; + + return unless filter_wants($params, 'requests'); + + my $ids = [ + map { blessed($_->{id}) ? $_->{id}->value : $_->{id} } + grep { exists $_->{id} } + @$users + ]; + + return unless @$ids; + + my %user_map = map { $_->id => $_ } @{ Bugzilla::User->new_from_list($ids) }; + + foreach my $user (@$users) { + my $id = blessed($user->{id}) ? $user->{id}->value : $user->{id}; + my $user_obj = $user_map{$id}; + + $user->{requests} = { + review => { + blocked => $webservice->type('boolean', $user_obj->reviews_blocked), + pending => $webservice->type('int', $user_obj->{review_request_count}), + }, + feedback => { + # reviews_blocked includes feedback as well + blocked => $webservice->type('boolean', $user_obj->reviews_blocked), + pending => $webservice->type('int', $user_obj->{feedback_request_count}), + }, + needinfo => { + blocked => $webservice->type('boolean', $user_obj->needinfo_blocked), + pending => $webservice->type('int', $user_obj->{needinfo_request_count}), + }, + }; + } +} + +sub webservice_user_suggest { + my ($self, $args) = @_; + $self->webservice_user_get($args); +} + __PACKAGE__->NAME; |