Skip to content
Snippets Groups Projects

feat: add ability to convert EF user object to public view from model

Merged Martin Lowe requested to merge malowe/main/auth-drupal-fix into main
1 file
+ 22
6
Compare changes
  • Side-by-side
  • Inline
@@ -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()
Loading