Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ID-755] Fix privacy format #756

Merged
merged 4 commits into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased
### Fixed
- Fix privacy format [#755](https://github.com/rokwire/core-building-block/issues/755)

## [1.48.0] - 2025-18-02
### Changed
- Default privacy for new accounts [#752](https://github.com/rokwire/core-building-block/issues/752)
Expand Down
25 changes: 16 additions & 9 deletions driver/web/conversions_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ func privacyToDef(item *model.Privacy) *Def.Privacy {

func privacyFromDef(item *Def.Privacy) model.Privacy {
if item == nil {
return model.Privacy{}
return defaultPrivacy()
}

var public bool
Expand All @@ -396,14 +396,7 @@ func privacyFromDef(item *Def.Privacy) model.Privacy {

func privacyFromDefNullable(item *Def.PrivacyNullable) model.Privacy {
if item == nil { //default privacy
public := true
fieldVisibility := map[string]interface{}{
"first_name": "public",
"last_name": "public",
"middle_name": "public",
"email": "public",
}
return model.Privacy{Public: public, FieldVisibility: fieldVisibility}
return defaultPrivacy()
}

var public bool
Expand All @@ -418,6 +411,20 @@ func privacyFromDefNullable(item *Def.PrivacyNullable) model.Privacy {
return model.Privacy{Public: public, FieldVisibility: fieldVisibility}
}

func defaultPrivacy() model.Privacy {
return model.Privacy{
Public: true,
FieldVisibility: map[string]interface{}{
"profile": map[string]interface{}{
"first_name": "public",
"last_name": "public",
"middle_name": "public",
"email": "public",
},
},
}
}

// MFA
func mfaDataListToDef(items []model.MFAType) []Def.SharedResMfa {
out := make([]Def.SharedResMfa, len(items))
Expand Down