| 1 | package edu.ucsb.cs156.frontiers.models; | |
| 2 | ||
| 3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | |
| 4 | import com.fasterxml.jackson.annotation.JsonProperty; | |
| 5 | import lombok.AllArgsConstructor; | |
| 6 | import lombok.Builder; | |
| 7 | import lombok.Data; | |
| 8 | import lombok.NoArgsConstructor; | |
| 9 | ||
| 10 | /** | |
| 11 | * A member of a Slack workspace, as returned by the Slack <code>users.list</code> method. | |
| 12 | * | |
| 13 | * @see <a href="https://docs.slack.dev/reference/objects/user-object">User object</a> | |
| 14 | */ | |
| 15 | @Data | |
| 16 | @AllArgsConstructor | |
| 17 | @NoArgsConstructor | |
| 18 | @Builder | |
| 19 | @JsonIgnoreProperties(ignoreUnknown = true) | |
| 20 | public class SlackUser { | |
| 21 | ||
| 22 | /** Slack's built in Slackbot user is not flagged as a bot, but is not a person either. */ | |
| 23 | public static final String SLACKBOT_ID = "USLACKBOT"; | |
| 24 | ||
| 25 | private String id; | |
| 26 | private String name; | |
| 27 | ||
| 28 | /** True if the account has been deactivated. */ | |
| 29 | private boolean deleted; | |
| 30 | ||
| 31 | @JsonProperty("real_name") | |
| 32 | private String realName; | |
| 33 | ||
| 34 | @JsonProperty("is_bot") | |
| 35 | private boolean bot; | |
| 36 | ||
| 37 | /** True if the user has been invited to the workspace, but has not yet signed in. */ | |
| 38 | @JsonProperty("is_invited_user") | |
| 39 | private boolean invitedUser; | |
| 40 | ||
| 41 | private Profile profile; | |
| 42 | ||
| 43 | @Data | |
| 44 | @AllArgsConstructor | |
| 45 | @NoArgsConstructor | |
| 46 | @Builder | |
| 47 | @JsonIgnoreProperties(ignoreUnknown = true) | |
| 48 | public static class Profile { | |
| 49 | /** Only present when the token has the <code>users:read.email</code> scope. */ | |
| 50 | private String email; | |
| 51 | ||
| 52 | @JsonProperty("display_name") | |
| 53 | private String displayName; | |
| 54 | ||
| 55 | @JsonProperty("first_name") | |
| 56 | private String firstName; | |
| 57 | ||
| 58 | @JsonProperty("last_name") | |
| 59 | private String lastName; | |
| 60 | } | |
| 61 | ||
| 62 | /** | |
| 63 | * @return the user's email, or null if Slack did not provide one | |
| 64 | */ | |
| 65 | public String email() { | |
| 66 |
2
1. email : negated conditional → KILLED 2. email : replaced return value with "" for edu/ucsb/cs156/frontiers/models/SlackUser::email → KILLED |
return profile == null ? null : profile.getEmail(); |
| 67 | } | |
| 68 | ||
| 69 | /** | |
| 70 | * @return the user's display name, or null if Slack did not provide one | |
| 71 | */ | |
| 72 | public String displayName() { | |
| 73 |
2
1. displayName : replaced return value with "" for edu/ucsb/cs156/frontiers/models/SlackUser::displayName → KILLED 2. displayName : negated conditional → KILLED |
return profile == null ? null : profile.getDisplayName(); |
| 74 | } | |
| 75 | ||
| 76 | /** | |
| 77 | * @return the user's first name, or null if Slack did not provide one | |
| 78 | */ | |
| 79 | public String firstName() { | |
| 80 |
2
1. firstName : negated conditional → KILLED 2. firstName : replaced return value with "" for edu/ucsb/cs156/frontiers/models/SlackUser::firstName → KILLED |
return profile == null ? null : profile.getFirstName(); |
| 81 | } | |
| 82 | ||
| 83 | /** | |
| 84 | * @return the user's last name, or null if Slack did not provide one | |
| 85 | */ | |
| 86 | public String lastName() { | |
| 87 |
2
1. lastName : negated conditional → KILLED 2. lastName : replaced return value with "" for edu/ucsb/cs156/frontiers/models/SlackUser::lastName → KILLED |
return profile == null ? null : profile.getLastName(); |
| 88 | } | |
| 89 | ||
| 90 | /** | |
| 91 | * @return true if this is a person (not a bot, and not Slackbot) | |
| 92 | */ | |
| 93 | public boolean isPerson() { | |
| 94 |
3
1. isPerson : replaced boolean return with true for edu/ucsb/cs156/frontiers/models/SlackUser::isPerson → KILLED 2. isPerson : negated conditional → KILLED 3. isPerson : negated conditional → KILLED |
return !bot && !SLACKBOT_ID.equals(id); |
| 95 | } | |
| 96 | ||
| 97 | /** | |
| 98 | * @return true if this is a person with an account that is neither deactivated nor still waiting | |
| 99 | * for an invitation to be accepted | |
| 100 | */ | |
| 101 | public boolean isActivePerson() { | |
| 102 |
4
1. isActivePerson : replaced boolean return with true for edu/ucsb/cs156/frontiers/models/SlackUser::isActivePerson → KILLED 2. isActivePerson : negated conditional → KILLED 3. isActivePerson : negated conditional → KILLED 4. isActivePerson : negated conditional → KILLED |
return isPerson() && !deleted && !invitedUser; |
| 103 | } | |
| 104 | } | |
Mutations | ||
| 66 |
1.1 2.2 |
|
| 73 |
1.1 2.2 |
|
| 80 |
1.1 2.2 |
|
| 87 |
1.1 2.2 |
|
| 94 |
1.1 2.2 3.3 |
|
| 102 |
1.1 2.2 3.3 4.4 |