|
|
@@ -62,7 +62,7 @@ module.exports = {
|
|
62
|
62
|
auth: false,
|
|
63
|
63
|
cors: true,
|
|
64
|
64
|
handler: async function (request, h) {
|
|
65
|
|
- const { membershipService, profileService } =
|
|
|
65
|
+ const { membershipService, profileService, userService } =
|
|
66
|
66
|
request.server.services()
|
|
67
|
67
|
const membershipType = request.query.type
|
|
68
|
68
|
|
|
|
@@ -95,6 +95,34 @@ module.exports = {
|
|
95
|
95
|
'participant',
|
|
96
|
96
|
false,
|
|
97
|
97
|
)
|
|
|
98
|
+
|
|
|
99
|
+ const revealTags = []
|
|
|
100
|
+ completedProfiles.forEach(p => {
|
|
|
101
|
+ p.tags.forEach(t => {
|
|
|
102
|
+ if (t.tag_category === 'reveal') {
|
|
|
103
|
+ if (t.tag_description === 'user_email' || t.tag_description === 'user_name') {
|
|
|
104
|
+ revealTags.push(t)
|
|
|
105
|
+ }
|
|
|
106
|
+ }
|
|
|
107
|
+ })
|
|
|
108
|
+ })
|
|
|
109
|
+
|
|
|
110
|
+ const getRevealInfo = async () => {
|
|
|
111
|
+ const profilesWithRevealed = []
|
|
|
112
|
+ for (const profile of completedProfiles) {
|
|
|
113
|
+ const userInfo = await userService.findById(profile.user_id)
|
|
|
114
|
+ for (const tag of revealTags) {
|
|
|
115
|
+ profile[tag.tag_description] = userInfo[tag.tag_description]
|
|
|
116
|
+ }
|
|
|
117
|
+ profilesWithRevealed.push(profile)
|
|
|
118
|
+ }
|
|
|
119
|
+ return profilesWithRevealed
|
|
|
120
|
+ }
|
|
|
121
|
+
|
|
|
122
|
+ const revealedInfo = await getRevealInfo()
|
|
|
123
|
+ console.log('revealedInfo :=>', revealedInfo)
|
|
|
124
|
+ // if revealTags.length, return revealInfo, otherwise return completeProfiles...
|
|
|
125
|
+
|
|
98
|
126
|
const reformattedGroupings = groupings.map(g => {
|
|
99
|
127
|
completedProfiles.forEach(p => {
|
|
100
|
128
|
g.profile = g.profile == p.profile_id ? p : g.profile
|
|
|
@@ -102,30 +130,9 @@ module.exports = {
|
|
102
|
130
|
g.is_paired = _activeGroupingIds(memberships).includes(
|
|
103
|
131
|
g.grouping_id,
|
|
104
|
132
|
)
|
|
105
|
|
-
|
|
106
|
|
- const defaultValues = {
|
|
107
|
|
- user_name: g.profile.user_info.user_name,
|
|
108
|
|
- user_email: g.profile.user_info.user_email
|
|
109
|
|
- }
|
|
110
|
|
-
|
|
111
|
|
- // NOTE: better...at least it's not globally shown on the home page...
|
|
112
|
|
- // but we can't rely on reveal for this, it has to be in this grouping in particular
|
|
113
|
|
- if (g.profile.reveal.length) {
|
|
114
|
|
- console.log('g.profile.reveal :=>', g.profile.reveal)
|
|
115
|
|
- for (let [attribute, defaultVal] of Object.entries(defaultValues)) {
|
|
116
|
|
- const typeOfReveal = typeof g.profile.reveal.find(tag =>
|
|
117
|
|
- tag.tag_description === attribute)
|
|
118
|
|
- if (typeOfReveal !== 'undefined') {
|
|
119
|
|
- g.profile[attribute] = defaultVal
|
|
120
|
|
- }
|
|
121
|
|
- }
|
|
122
|
|
- }
|
|
123
|
|
-
|
|
124
|
|
- // NOTE: delete profile.user_info for privacy
|
|
125
|
|
- delete g.profile.user_info
|
|
126
|
133
|
return g
|
|
127
|
134
|
})
|
|
128
|
|
- console.log('reformattedGroupings :=>', reformattedGroupings[0].profile.user_name)
|
|
|
135
|
+
|
|
129
|
136
|
try {
|
|
130
|
137
|
return {
|
|
131
|
138
|
ok: true,
|