Skip to content

Commit

Permalink
Merge pull request #410 from vimeo/Is-Staff-Fix
Browse files Browse the repository at this point in the history
Fixed isStaff in User Object
  • Loading branch information
WhosNickDoglio authored Feb 7, 2020
2 parents 6792934 + 3f30862 commit f9aeb4d
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions vimeo-networking/src/main/java/com/vimeo/networking/model/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import com.google.gson.annotations.SerializedName;
import com.vimeo.networking.Vimeo;
import com.vimeo.networking.model.UserBadge.UserBadgeType;
import com.vimeo.networking.model.live.LiveQuota;
import com.vimeo.networking.model.notifications.NotificationConnection;
import com.vimeo.networking.model.uploadquota.UploadQuota;
Expand Down Expand Up @@ -122,10 +123,6 @@ public enum AccountType {
@SerializedName("id")
private String mId;

@Nullable
@SerializedName("is_staff")
private Boolean mIsStaff;

@Nullable
@SerializedName("is_creator")
private Boolean mIsVideoCreator;
Expand All @@ -138,6 +135,13 @@ public enum AccountType {
@SerializedName("membership")
private Membership mMembership;

/**
* Do not use this method to check if {@link AccountType} is {@link AccountType#STAFF} as you will get inconsistent results.
* This method can only return a single {@link AccountType} at a time so if a user happens to be a
* staff member with a Pro account, it will only return the {@link AccountType#PRO}.
* <p>
* Please use {@link #getIsStaff()} instead.
*/
public AccountType getAccountType() {
if (this.mMembership == null || this.mMembership.getType() == null) {
//We should assume the account object could be null; also, a User object could
Expand Down Expand Up @@ -441,9 +445,8 @@ public String getId() {
/**
* @return whether the user is an active staff member of Vimeo
*/
@Nullable
public Boolean getIsStaff() {
return mIsStaff;
public boolean getIsStaff() {
return getBadge() != null && getBadge().getBadgeType() == UserBadgeType.STAFF;
}

/**
Expand Down Expand Up @@ -500,10 +503,6 @@ void setIsVideoCreator(@Nullable Boolean videoCreator) {
mIsVideoCreator = videoCreator;
}

void setIsStaff(@Nullable Boolean staff) {
mIsStaff = staff;
}

void setMembership(@Nullable Membership membership) {
mMembership = membership;
}
Expand Down

0 comments on commit f9aeb4d

Please sign in to comment.