jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/367636 )
Change subject: Fix: Use groups, not implicitgroups, to determine user rights. ...................................................................... Fix: Use groups, not implicitgroups, to determine user rights. The groups associated with a user account determine the user's rights to perform actions such as editing a semi-protected or protected article. These can be obtained from the 'groups' property for a user via the MW API. 'Implicitgroups' is a subset of 'groups' consisting of only those groups that a user is added to automatically, such as 'autoconfirmed.' For many users 'groups' will be identical to 'implicitgroups' but this is not always the case. For instance, for my staff account, which has sysop rights on testwiki: https://phabricator.wikimedia.org/P5792 We should look to 'groups' and not 'implicitgroups' to determine the correct set of groups assigned to the user account. Change-Id: Ib815d4b8de7c34ea4c27045d9297aba6981936a7 --- M app/src/main/java/org/wikipedia/dataclient/mwapi/MwQueryResult.java M app/src/main/java/org/wikipedia/login/UserExtendedInfoClient.java 2 files changed, 9 insertions(+), 12 deletions(-) Approvals: Dbrant: Looks good to me, approved jenkins-bot: Verified diff --git a/app/src/main/java/org/wikipedia/dataclient/mwapi/MwQueryResult.java b/app/src/main/java/org/wikipedia/dataclient/mwapi/MwQueryResult.java index 70e977a..ead48be 100644 --- a/app/src/main/java/org/wikipedia/dataclient/mwapi/MwQueryResult.java +++ b/app/src/main/java/org/wikipedia/dataclient/mwapi/MwQueryResult.java @@ -16,7 +16,6 @@ import org.wikipedia.useroption.dataclient.UserInfo; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.List; @@ -169,17 +168,15 @@ private static class ListUsersResponse { @SuppressWarnings("unused") @SerializedName("name") @Nullable private String name; - @SuppressWarnings("unused") @SerializedName("implicitgroups") - @Nullable private String[] implicitGroups; + @SuppressWarnings("unused") @Nullable private List<String> groups; @Nullable Set<String> getGroupsFor(@NonNull String userName) { - if (userName.equals(name) && implicitGroups != null) { - Set<String> groups = new ArraySet<>(); - groups.addAll(Arrays.asList(implicitGroups)); - return Collections.unmodifiableSet(groups); - } else { - return null; + if (userName.equals(name) && groups != null) { + Set<String> groupNames = new ArraySet<>(); + groupNames.addAll(groups); + return Collections.unmodifiableSet(groupNames); } + return null; } } diff --git a/app/src/main/java/org/wikipedia/login/UserExtendedInfoClient.java b/app/src/main/java/org/wikipedia/login/UserExtendedInfoClient.java index be65ada..836997a 100644 --- a/app/src/main/java/org/wikipedia/login/UserExtendedInfoClient.java +++ b/app/src/main/java/org/wikipedia/login/UserExtendedInfoClient.java @@ -17,7 +17,7 @@ import retrofit2.http.Query; /** - * Retrofit DataClient to retrieve implicit user info and group membership information for a specific user. + * Retrofit DataClient to retrieve user info and group membership information for a specific user. */ class UserExtendedInfoClient { @NonNull private final WikiCachedService<Service> cachedService = new MwCachedService<>(Service.class); @@ -81,8 +81,8 @@ } @VisibleForTesting interface Service { - /** Request the implicit groups a user belongs to. */ - @POST("w/api.php?action=query&format=json&formatversion=2&meta=userinfo&list=users&usprop=implicitgroups") + /** Request the groups a user belongs to. */ + @POST("w/api.php?action=query&format=json&formatversion=2&meta=userinfo&list=users&usprop=groups") Call<MwQueryResponse> request(@Query("ususers") @NonNull String userName); } } -- To view, visit https://gerrit.wikimedia.org/r/367636 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ib815d4b8de7c34ea4c27045d9297aba6981936a7 Gerrit-PatchSet: 2 Gerrit-Project: apps/android/wikipedia Gerrit-Branch: master Gerrit-Owner: Mholloway <[email protected]> Gerrit-Reviewer: Brion VIBBER <[email protected]> Gerrit-Reviewer: Dbrant <[email protected]> Gerrit-Reviewer: Mholloway <[email protected]> Gerrit-Reviewer: Niedzielski <[email protected]> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
