From: Kohei Yoshino Date: Wed, 14 Nov 2018 22:50:26 +0000 (-0500) Subject: Bug 1505831 - Add nick field to all user objects including *_detail returned by ... X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c2c9471998b9f332e27a5a1c9b7197c759f35dbc;p=thirdparty%2Fbugzilla.git Bug 1505831 - Add nick field to all user objects including *_detail returned by /rest/bug --- diff --git a/Bugzilla/WebService/Bug.pm b/Bugzilla/WebService/Bug.pm index f13998e43..5d60885c9 100644 --- a/Bugzilla/WebService/Bug.pm +++ b/Bugzilla/WebService/Bug.pm @@ -1548,6 +1548,7 @@ sub _user_to_hash { my $item = filter $filters, { id => $self->type('int', $user->id), real_name => $self->type('string', $user->name), + nick => $self->type('string', $user->nick), name => $self->type('email', $user->login), email => $self->type('email', $user->email), }, $types, $prefix; @@ -2849,6 +2850,11 @@ C The user id for this user. C The 'real' name for this user, if any. +=item C + +C The user's nickname. Currently this is extracted from the real_name, +name or email field. + =item C C The user's Bugzilla login. diff --git a/Bugzilla/WebService/Group.pm b/Bugzilla/WebService/Group.pm index b13003e08..88e7a1ed4 100644 --- a/Bugzilla/WebService/Group.pm +++ b/Bugzilla/WebService/Group.pm @@ -210,6 +210,7 @@ sub _get_group_membership { map {{ id => $self->type('int', $_->id), real_name => $self->type('string', $_->name), + nick => $self->type('string', $_->nick), name => $self->type('string', $_->login), email => $self->type('string', $_->email), can_login => $self->type('boolean', $_->is_enabled), @@ -547,6 +548,11 @@ C The id of the user. C The actual name of the user. +=item nick + +C The user's nickname. Currently this is extracted from the real_name, +name or email field. + =item email C The email address of the user. diff --git a/Bugzilla/WebService/User.pm b/Bugzilla/WebService/User.pm index c569cf9d8..758baf0f9 100644 --- a/Bugzilla/WebService/User.pm +++ b/Bugzilla/WebService/User.pm @@ -192,6 +192,7 @@ sub suggest { { id => $self->type(int => $_->{id}), real_name => $self->type(string => $_->{real_name}), + nick => $self->type(string => $_->{nick}), name => $self->type(email => $_->{name}), } } @$results; @@ -240,6 +241,7 @@ sub get { @users = map { filter $params, { id => $self->type('int', $_->id), real_name => $self->type('string', $_->name), + nick => $self->type('string', $_->nick), name => $self->type('email', $_->login), } } @$in_group; @@ -290,6 +292,7 @@ sub get { my $user_info = filter $params, { id => $self->type('int', $user->id), real_name => $self->type('string', $user->name), + nick => $self->type('string', $user->nick), name => $self->type('email', $user->login), email => $self->type('email', $user->email), can_login => $self->type('boolean', $user->is_enabled ? 1 : 0), @@ -496,6 +499,7 @@ sub whoami { { id => $self->type( 'int', $user->id ), real_name => $self->type( 'string', $user->name ), + nick => $self->type( 'string', $user->nick ), name => $self->type( 'email', $user->login ), mfa_status => $self->type( 'boolean', !!$user->mfa ), } @@ -1026,6 +1030,11 @@ Even if the user's login name changes, this will not change. C The actual name of the user. May be blank. +=item nick + +C The user's nickname. Currently this is extracted from the real_name, +name or email field. + =item email C The email address of the user. @@ -1100,10 +1109,10 @@ name of each saved search. =back B: If you are not logged in to Bugzilla when you call this function, you -will only be returned the C, C, and C items. If you are -logged in and not in editusers group, you will only be returned the C, C, -C, C, and C items. The groups returned are filtered -based on your permission to bless each group. +will only be returned the C, C, C and C items. If you +are logged in and not in editusers group, you will only be returned the C, +C, C, C, C and C items. The groups +returned are filtered based on your permission to bless each group. =back @@ -1151,6 +1160,8 @@ for C has changed to only returning enabled accounts. =item Error 804 has been added in Bugzilla 4.0.9 and 4.2.4. It's now illegal to pass a group name you don't belong to. +=item C Added in Bugzilla B<6.0>. + =back =item REST API call added in Bugzilla B<5.0>. @@ -1184,6 +1195,11 @@ Even if the user's login name changes, this will not change. C The actual name of the user. May be blank. +=item nick + +C The user's nickname. Currently this is extracted from the real_name, +name or email field. + =item name C The login name of the user. diff --git a/docs/en/rst/api/core/v1/bug.rst b/docs/en/rst/api/core/v1/bug.rst index 9ce7fc454..4b77c9864 100644 --- a/docs/en/rst/api/core/v1/bug.rst +++ b/docs/en/rst/api/core/v1/bug.rst @@ -45,6 +45,7 @@ name type description "assigned_to_detail": { "id": 2, "real_name": "Test User", + "nick": "user", "name": "user@bugzilla.org", "email": "user@bugzilla.org" }, @@ -76,6 +77,7 @@ name type description { "id": 786, "real_name": "Foo Bar", + "nick": "foo", "name": "foo@bar.com", "email": "foo@bar.com" }, @@ -113,6 +115,7 @@ name type description "creator_detail": { "id": 28, "real_name": "hello", + "nick": "namachi", "name": "user@bugzilla.org", "email": "namachi@netscape.com" }, @@ -260,6 +263,8 @@ name type description ========= ====== ============================================================== id int The user ID for this user. real_name string The 'real' name for this user, if any. +nick string The user's nickname. Currently this is extracted from the + real_name, name or email field. name string The user's Bugzilla login. email string The user's email address. Currently this is the same value as the name. diff --git a/docs/en/rst/api/core/v1/flag-activity.rst b/docs/en/rst/api/core/v1/flag-activity.rst index 4ce08173a..4a8a2cb7f 100644 --- a/docs/en/rst/api/core/v1/flag-activity.rst +++ b/docs/en/rst/api/core/v1/flag-activity.rst @@ -83,11 +83,13 @@ For example, to get the first 100 flag-activity entries that occurred on or afte "requestee": { "id": 123, "name": "user@mozilla.com", + "nick": "user", "real_name": "J. Random User" }, "setter": { "id": 123, "name": "user@mozilla.com", + "nick": "user", "real_name": "J. Random User" }, "status": "?", @@ -127,6 +129,8 @@ name type description id int The unique ID of the user. name string The login of the user (typically an email address). real_name string The real name of the user, if set. +nick string The user's nickname. Currently this is extracted + the real_name, name or email field. ========= ====== ==================================================== The type object has the following fields: diff --git a/docs/en/rst/api/core/v1/group.rst b/docs/en/rst/api/core/v1/group.rst index 13367e392..e5b24b8c9 100644 --- a/docs/en/rst/api/core/v1/group.rst +++ b/docs/en/rst/api/core/v1/group.rst @@ -223,6 +223,7 @@ membership boolean Set to 1 then a list of members of the passed groups names "membership": [ { "real_name": "Bugzilla User", + "nick": "user", "can_login": true, "name": "user@bugzilla.org", "login_denied_text": "", @@ -280,6 +281,8 @@ name type description ============= ======= ========================================================= id int The ID of the user. real_name string The actual name of the user. +nick string The user's nickname. Currently this is extracted from + the real_name, name or email field. email string The email address of the user. name string The login name of the user. Note that in some situations this is different than their email. diff --git a/docs/en/rst/api/core/v1/user.rst b/docs/en/rst/api/core/v1/user.rst index bc5459892..1565425e5 100644 --- a/docs/en/rst/api/core/v1/user.rst +++ b/docs/en/rst/api/core/v1/user.rst @@ -352,6 +352,8 @@ id int The unique integer ID that Bugzilla uses to represen this user. Even if the user's login name changes, this will not change. real_name string The actual name of the user. May be blank. +nick string The user's nickname. Currently this is extracted from + the real_name, name or email field. email string The email address of the user. name string The login name of the user. Note that in some situations this is different than their email. @@ -398,11 +400,11 @@ query string The CGI parameters for the saved report. ===== ====== ================================================================== If you are not authenticated when you call this function, you will only be -returned the ``id``, ``name``, and ``real_name`` items. If you are authenticated -and not in 'editusers' group, you will only be returned the ``id``, ``name``, -``real_name``, ``email``, ``can_login``, and ``groups`` items. The groups -returned are filtered based on your permission to bless each group. The -``saved_searches`` and ``saved_reports`` items are only returned if you are +returned the ``id``, ``name``, ``real_name`` and ``nick`` items. If you are +authenticated and not in 'editusers' group, you will only be returned the ``id``, +``name``, ``real_name``, ``nick``, ``email``, ``can_login`` and ``groups`` items. +The groups returned are filtered based on your permission to bless each group. +The ``saved_searches`` and ``saved_reports`` items are only returned if you are querying your own account, even if you are in the editusers group. **Errors** @@ -445,6 +447,7 @@ logged in user. "id" : "1234", "name" : "user@bugzulla.org", "real_name" : "Test User", + "nick" : "user" } ========== ====== ===================================================== @@ -454,5 +457,7 @@ id int The unique integer ID that Bugzilla uses to represent this user. Even if the user's login name changes, this will not change. real_name string The actual name of the user. May be blank. +nick string The user's nickname. Currently this is extracted from + the real_name, name or email field. name string string The login name of the user. ========== ====== ===================================================== diff --git a/extensions/Review/lib/WebService.pm b/extensions/Review/lib/WebService.pm index fe3e52663..a8dfb2b43 100644 --- a/extensions/Review/lib/WebService.pm +++ b/extensions/Review/lib/WebService.pm @@ -71,6 +71,7 @@ sub suggestions { id => $self->type('int', $reviewer->id), email => $self->type('email', $reviewer->login), name => $self->type('string', $reviewer->name), + nick => $self->type('string', $reviewer->nick), review_count => $self->type('int', $reviewer->review_count), }; } @@ -289,6 +290,7 @@ sub _user_to_hash { return { id => $self->type('int', $user->id), real_name => $self->type('string', $user->name), + nick => $self->type('string', $user->nick), name => $self->type('email', $user->login), }; } @@ -489,6 +491,11 @@ The id of the bugzilla user. A unique integer value. The real name of the bugzilla user. +=item C (string) + +The user's nickname. Currently this is extracted from the real_name, name or +email field. + =item C (string) The bugzilla login of the bugzilla user (typically an email address). diff --git a/qa/t/webservice_user_get.t b/qa/t/webservice_user_get.t index 4a7f74f78..32f25f256 100644 --- a/qa/t/webservice_user_get.t +++ b/qa/t/webservice_user_get.t @@ -141,8 +141,8 @@ sub post_success { } else { my @item_keys = sort keys %$item; - is_deeply(\@item_keys, ['id', 'name', 'real_name'], - 'Only id, name, and real_name are returned to logged-out users'); + is_deeply(\@item_keys, ['id', 'name', 'nick', 'real_name'], + 'Only id, name, nick and real_name are returned to logged-out users'); return; } @@ -198,14 +198,14 @@ foreach my $rpc (@clients) { my $exclude_none = $rpc->bz_call_success('User.get', { names => [$get_user], exclude_fields => ['asdfasdfsdf'], }, 'User.get excluding only invalid fields'); - is(scalar keys %{ $exclude_none->result->{users}->[0] }, 3, + is(scalar keys %{ $exclude_none->result->{users}->[0] }, 4, 'All fields returned for user'); my $exclude_one = $rpc->bz_call_success('User.get', { names => [$get_user], exclude_fields => ['id'], }, 'User.get excluding id'); - is(scalar keys %{ $exclude_one->result->{users}->[0] }, 2, - 'Only two fields returned for user'); + is(scalar keys %{ $exclude_one->result->{users}->[0] }, 3, + 'Only three fields returned for user'); my $override = $rpc->bz_call_success('User.get', { names => [$get_user], include_fields => ['id', 'name'],