Skip to content

Commit

Permalink
feat: update profile privacy settings to support private, public, and…
Browse files Browse the repository at this point in the history
… friends-only options
  • Loading branch information
Cr1stal423 committed Jan 5, 2025
1 parent b0e5abc commit 289427c
Show file tree
Hide file tree
Showing 12 changed files with 127 additions and 9 deletions.
12 changes: 9 additions & 3 deletions dao/src/main/java/greencity/entity/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
import greencity.dto.friends.UserFriendDto;
import greencity.dto.user.RegistrationStatisticsDtoResponse;
import greencity.entity.event.Event;
import greencity.enums.EcoPlacePrivacyPolicy;
import greencity.enums.EmailNotification;
import greencity.enums.LocationPrivacyPolicy;
import greencity.enums.Role;
import greencity.enums.ToDoListPrivacyPolicy;
import greencity.enums.UserStatus;
import lombok.AllArgsConstructor;
import lombok.Builder;
Expand Down Expand Up @@ -221,13 +224,16 @@ public class User {
private List<SocialNetwork> socialNetworks;

@Column(name = "show_location")
private Boolean showLocation;
@Enumerated(value = EnumType.STRING)
private LocationPrivacyPolicy showLocation = LocationPrivacyPolicy.PUBLIC;

@Column(name = "show_eco_place")
private Boolean showEcoPlace;
@Enumerated(value = EnumType.STRING)
private EcoPlacePrivacyPolicy showEcoPlace = EcoPlacePrivacyPolicy.PUBLIC;

@Column(name = "show_to_do_list")
private Boolean showToDoList;
@Enumerated(value = EnumType.STRING)
private ToDoListPrivacyPolicy showToDoList = ToDoListPrivacyPolicy.PUBLIC;

@Column(name = "last_activity_time")
private LocalDateTime lastActivityTime;
Expand Down
7 changes: 7 additions & 0 deletions dao/src/main/java/greencity/enums/EcoPlacePrivacyPolicy.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package greencity.enums;

public enum EcoPlacePrivacyPolicy {
PRIVATE,
FRIENDS_ONLY,
PUBLIC
}
7 changes: 7 additions & 0 deletions dao/src/main/java/greencity/enums/LocationPrivacyPolicy.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package greencity.enums;

public enum LocationPrivacyPolicy {
PRIVATE,
FRIENDS_ONLY,
PUBLIC
}
7 changes: 7 additions & 0 deletions dao/src/main/java/greencity/enums/ToDoListPrivacyPolicy.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package greencity.enums;

public enum ToDoListPrivacyPolicy {
PRIVATE,
FRIENDS_ONLY,
PUBLIC
}
2 changes: 2 additions & 0 deletions dao/src/main/resources/db/changelog/db.changelog-master.xml
Original file line number Diff line number Diff line change
Expand Up @@ -256,4 +256,6 @@
<include file="db/changelog/logs/сh-update-habit-invitation-statuses.xml"/>
<include file="db/changelog/logs/ch-remove-duplicates-from-habit-invitations.xml"/>
<include file="db/changelog/logs/ch-add-invitee-id-and-inviter-id-to-habit-invite-table.xml"/>
<include file="db/changelog/logs/ch-change-user-profile-columns-type-Haliara.xml"/>
<include file="db/changelog/logs/ch-add-default-value-userprofile-confidentiality-Haliara.xml"/>
</databaseChangeLog>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">

<changeSet id="set-default-values-for-show-location" author="Vladyslav Haliara">
<addDefaultValue tableName="users" columnName="show_location" defaultValue="PUBLIC"/>
</changeSet>

<changeSet id="set-default-values-for-show-eco-place" author="Vladyslav Haliara">
<addDefaultValue tableName="users" columnName="show_eco_place" defaultValue="PUBLIC"/>
</changeSet>

<changeSet id="set-default-values-for-show-to-do-list" author="Vladyslav Haliara">
<addDefaultValue tableName="users" columnName="show_to_do_list" defaultValue="PUBLIC"/>
</changeSet>

</databaseChangeLog>
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">

<changeSet id="change-column-type-show-location" author="Vladyslav Haliara">
<modifyDataType tableName="users" columnName="show_location" newDataType="VARCHAR(255)"/>
<update tableName="users">
<column name="show_location" value="PUBLIC"/>
<where>show_location = 'true'</where>
</update>
<update tableName="users">
<column name="show_location" value="PRIVATE"/>
<where>show_location = 'false'</where>
</update>
</changeSet>

<changeSet id="change-column-type-show-eco-place" author="Vladyslav Haliara">
<modifyDataType tableName="users" columnName="show_eco_place" newDataType="VARCHAR(255)"/>
<update tableName="users">
<column name="show_eco_place" value="PUBLIC"/>
<where>show_eco_place = 'true'</where>
</update>
<update tableName="users">
<column name="show_eco_place" value="PRIVATE"/>
<where>show_eco_place = 'false'</where>
</update>
</changeSet>

<changeSet id="change-column-type-show-to-do-list" author="Vladyslav Haliara">
<modifyDataType tableName="users" columnName="show_to_do_list" newDataType="VARCHAR(255)"/>
<update tableName="users">
<column name="show_to_do_list" value="PUBLIC"/>
<where>show_to_do_list = 'true'</where>
</update>
<update tableName="users">
<column name="show_to_do_list" value="PRIVATE"/>
<where>show_to_do_list = 'false'</where>
</update>
</changeSet>

</databaseChangeLog>
9 changes: 6 additions & 3 deletions service-api/src/main/java/greencity/dto/user/UserVO.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@
import greencity.dto.socialnetwork.SocialNetworkVO;
import greencity.dto.useraction.UserActionVO;
import greencity.dto.verifyemail.VerifyEmailVO;
import greencity.enums.EcoPlacePrivacyPolicy;
import greencity.enums.EmailNotification;
import greencity.enums.LocationPrivacyPolicy;
import greencity.enums.Role;
import greencity.enums.ToDoListPrivacyPolicy;
import greencity.enums.UserStatus;
import lombok.AllArgsConstructor;
import lombok.Builder;
Expand Down Expand Up @@ -70,11 +73,11 @@ public class UserVO {

private String firstName;

private Boolean showLocation;
private LocationPrivacyPolicy showLocation;

private Boolean showEcoPlace;
private EcoPlacePrivacyPolicy showEcoPlace;

private Boolean showToDoList;
private ToDoListPrivacyPolicy showToDoList;

private LocalDateTime lastActivityTime;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package greencity.enums;

public enum EcoPlacePrivacyPolicy {
PRIVATE,
FRIENDS_ONLY,
PUBLIC
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package greencity.enums;

public enum LocationPrivacyPolicy {
PRIVATE,
FRIENDS_ONLY,
PUBLIC
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package greencity.enums;

public enum ToDoListPrivacyPolicy {
PRIVATE,
FRIENDS_ONLY,
PUBLIC
}
9 changes: 6 additions & 3 deletions service/src/test/java/greencity/ModelUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,17 @@
import greencity.entity.localization.TagTranslation;
import greencity.enums.ArticleType;
import greencity.enums.CommentStatus;
import greencity.enums.EcoPlacePrivacyPolicy;
import greencity.enums.EmailNotification;
import greencity.enums.EventType;
import greencity.enums.HabitAssignStatus;
import greencity.enums.HabitRate;
import greencity.enums.LocationPrivacyPolicy;
import greencity.enums.PlaceStatus;
import greencity.enums.Role;
import greencity.enums.ToDoListItemStatus;
import greencity.enums.TagType;
import greencity.enums.ToDoListPrivacyPolicy;
import greencity.enums.UserStatus;
import jakarta.persistence.Tuple;
import jakarta.persistence.TupleElement;
Expand Down Expand Up @@ -605,9 +608,9 @@ public static UserVO getUserVOWithData() {
.userLocationDto(
new UserLocationDto(1L, "Lviv", "Львів", "Lvivska",
"Львівська", "Ukraine", "Україна", 20.000000, 20.000000))
.showToDoList(true)
.showEcoPlace(true)
.showLocation(true)
.showToDoList(ToDoListPrivacyPolicy.PUBLIC)
.showEcoPlace(EcoPlacePrivacyPolicy.PUBLIC)
.showLocation(LocationPrivacyPolicy.PUBLIC)
.socialNetworks(Collections.singletonList(
SocialNetworkVO.builder()
.id(10L)
Expand Down

0 comments on commit 289427c

Please sign in to comment.