diff --git a/efservices/src/main/java/org/eclipsefoundation/efservices/api/models/EfUser.java b/efservices/src/main/java/org/eclipsefoundation/efservices/api/models/EfUser.java index f1e21522431f5b06df46fe9035f459d3ae19b880..6c4a91bc80611a7133eeaaafd67d40591f216fa1 100644 --- a/efservices/src/main/java/org/eclipsefoundation/efservices/api/models/EfUser.java +++ b/efservices/src/main/java/org/eclipsefoundation/efservices/api/models/EfUser.java @@ -27,18 +27,18 @@ import io.soabase.recordbuilder.core.RecordBuilder; @RecordBuilder public record EfUser(String uid, String name, String picture, String mail, Eca eca, Boolean isCommitter, String firstName, String lastName, String fullName, Map<String, PublisherAgreement> publisherAgreements, String githubHandle, String twitterHandle, String org, - Integer orgId, String jobTitle, String website, String mxid, Country country, String bio, List<String> interests, List<Email> mailHistory, - List<String> mailAlternate, String ecaUrl, String projectsUrl, String gerritUrl, String mailinglistUrl, String mpcFavoritesUrl, - @JsonIgnore Boolean isBot) { + Integer orgId, String jobTitle, String website, String mxid, Country country, String bio, List<String> interests, + List<Email> mailHistory, List<String> mailAlternate, String ecaUrl, String projectsUrl, String gerritUrl, String mailinglistUrl, + String mpcFavoritesUrl, @JsonIgnore Boolean isBot) { /** * */ public EfUser(String uid, String name, String picture, String mail, Eca eca, Boolean isCommitter, String firstName, String lastName, String fullName, Map<String, PublisherAgreement> publisherAgreements, String githubHandle, String twitterHandle, String org, - Integer orgId, String jobTitle, String website, String mxid, Country country, String bio, List<String> interests, List<Email> mailHistory, - List<String> mailAlternate, String ecaUrl, String projectsUrl, String gerritUrl, String mailinglistUrl, String mpcFavoritesUrl, - Boolean isBot) { + Integer orgId, String jobTitle, String website, String mxid, Country country, String bio, List<String> interests, + List<Email> mailHistory, List<String> mailAlternate, String ecaUrl, String projectsUrl, String gerritUrl, String mailinglistUrl, + String mpcFavoritesUrl, Boolean isBot) { this.uid = Objects.requireNonNull(uid); this.name = Objects.requireNonNull(name); this.picture = Objects.requireNonNull(picture); @@ -69,6 +69,22 @@ public record EfUser(String uid, String name, String picture, String mail, Eca e this.isBot = isBot; } + /** + * Converts the user profile to the restricted public view. + * + * @return current user profile, with the private data blanked out. + */ + public EfUser getPublicProfile() { + return EfUserBuilder + .builder(this) + .mail("") + .mxid("") + .country(EfUserCountryBuilder.builder().code(null).name(null).build()) + .mailAlternate(Collections.emptyList()) + .mailHistory(Collections.emptyList()) + .build(); + } + public static EfUser createBotStub(String name, String mail) { return EfUserBuilder .builder()