|
|
@@ -75,20 +75,27 @@ module.exports = {
|
|
75
|
75
|
groupings.map(grouping => grouping.grouping_id),
|
|
76
|
76
|
)
|
|
77
|
77
|
|
|
|
78
|
+ // NOTE: Current implementation works okay, it only reveals the targetID's
|
|
|
79
|
+ // hidden info on the page currently, it does NOT reveal OUR OWN information
|
|
|
80
|
+ // to ourselves when revealed
|
|
|
81
|
+
|
|
78
|
82
|
/**
|
|
79
|
83
|
* Heavily process the result by storing just a profile_id
|
|
80
|
84
|
* and attach complete profiles
|
|
81
|
85
|
*/
|
|
|
86
|
+ // NOTE: only returns the pId for the target
|
|
82
|
87
|
let pIds = groupings.reduce((ids, grouping) => {
|
|
83
|
88
|
grouping.profiles.forEach(p => {
|
|
84
|
|
- if (p.profile_id == profileId) return
|
|
|
89
|
+ // you'd think to comment out here, but it still only returns CompleteProfile of target
|
|
|
90
|
+ // pIds would be both currentProfile id and target id though
|
|
|
91
|
+ if (p.profile_id == profileId) return
|
|
85
|
92
|
ids.push(p.profile_id)
|
|
86
|
93
|
grouping.profile = p.profile_id
|
|
87
|
94
|
})
|
|
88
|
95
|
delete grouping.profiles
|
|
89
|
96
|
return ids
|
|
90
|
97
|
}, [])
|
|
91
|
|
-
|
|
|
98
|
+ console.log('pIds :=>', pIds) // only returns single array of target id
|
|
92
|
99
|
/** Assemble complete profiles to reference and pass */
|
|
93
|
100
|
const completedProfiles = await profileService.getProfilesFor(
|
|
94
|
101
|
pIds,
|
|
|
@@ -96,35 +103,48 @@ module.exports = {
|
|
96
|
103
|
false,
|
|
97
|
104
|
)
|
|
98
|
105
|
|
|
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)
|
|
|
106
|
+ // NOTE: Doesn't rely on profile reveal field to get reveal tags
|
|
|
107
|
+ const getGroupingRevealTags = async () => {
|
|
|
108
|
+ const groupingRevealTags = []
|
|
|
109
|
+ for (const grouping of groupings) {
|
|
|
110
|
+ for (const profile of completedProfiles) {
|
|
|
111
|
+ const revealTags = await profileService.getTagsFor(profile.profile_id, grouping.grouping_id, 'reveal')
|
|
|
112
|
+ if (revealTags.length) {
|
|
|
113
|
+ groupingRevealTags.push(revealTags)
|
|
105
|
114
|
}
|
|
106
|
115
|
}
|
|
107
|
|
- })
|
|
108
|
|
- })
|
|
|
116
|
+ }
|
|
|
117
|
+ return groupingRevealTags
|
|
|
118
|
+ }
|
|
109
|
119
|
|
|
|
120
|
+ const revealTags = await getGroupingRevealTags()
|
|
|
121
|
+ // TODO: Refactor, triple for of loop...
|
|
110
|
122
|
const getRevealInfo = async () => {
|
|
111
|
123
|
const profilesWithRevealed = []
|
|
112
|
124
|
for (const profile of completedProfiles) {
|
|
113
|
125
|
const userInfo = await userService.findById(profile.user_id)
|
|
114
|
|
- for (const tag of revealTags) {
|
|
115
|
|
- profile[tag.tag_description] = userInfo[tag.tag_description]
|
|
|
126
|
+ if (userInfo && revealTags.length) {
|
|
|
127
|
+ for (const tags of revealTags) {
|
|
|
128
|
+ for (const tag of tags) {
|
|
|
129
|
+ if (tag.tag.tag_description) {
|
|
|
130
|
+ profile[tag.tag.tag_description] = userInfo[tag.tag.tag_description]
|
|
|
131
|
+ }
|
|
|
132
|
+ }
|
|
|
133
|
+ }
|
|
|
134
|
+ profilesWithRevealed.push(profile)
|
|
116
|
135
|
}
|
|
117
|
|
- profilesWithRevealed.push(profile)
|
|
118
|
136
|
}
|
|
119
|
|
- return profilesWithRevealed
|
|
|
137
|
+ if (profilesWithRevealed.length)
|
|
|
138
|
+ return profilesWithRevealed
|
|
|
139
|
+ else
|
|
|
140
|
+ return completedProfiles
|
|
120
|
141
|
}
|
|
121
|
142
|
|
|
122
|
|
- const revealedInfo = await getRevealInfo()
|
|
123
|
|
- console.log('revealedInfo :=>', revealedInfo)
|
|
124
|
|
- // if revealTags.length, return revealInfo, otherwise return completeProfiles...
|
|
|
143
|
+ const completedProfilesWithRevealedInfo = await getRevealInfo()
|
|
125
|
144
|
|
|
|
145
|
+ // ISSUE: renders target ID but not currentProfileID in ChatView.vue
|
|
126
|
146
|
const reformattedGroupings = groupings.map(g => {
|
|
127
|
|
- completedProfiles.forEach(p => {
|
|
|
147
|
+ completedProfilesWithRevealedInfo.forEach(p => {
|
|
128
|
148
|
g.profile = g.profile == p.profile_id ? p : g.profile
|
|
129
|
149
|
})
|
|
130
|
150
|
g.is_paired = _activeGroupingIds(memberships).includes(
|
|
|
@@ -132,7 +152,7 @@ module.exports = {
|
|
132
|
152
|
)
|
|
133
|
153
|
return g
|
|
134
|
154
|
})
|
|
135
|
|
-
|
|
|
155
|
+ console.log('reformattedGroupings :=>', reformattedGroupings)
|
|
136
|
156
|
try {
|
|
137
|
157
|
return {
|
|
138
|
158
|
ok: true,
|