Bläddra i källkod

:recycle: Addressing bug - reveal does not cause global reveal

tags/0.0.3^2
tomit4 3 år sedan
förälder
incheckning
3d453b3b52

+ 22
- 1
backend/lib/routes/membership/active.js Visa fil

@@ -102,9 +102,30 @@ module.exports = {
102 102
                 g.is_paired = _activeGroupingIds(memberships).includes(
103 103
                     g.grouping_id,
104 104
                 )
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
105 126
                 return g
106 127
             })
107
-
128
+            console.log('reformattedGroupings :=>', reformattedGroupings[0].profile.user_name)
108 129
             try {
109 130
                 return {
110 131
                     ok: true,

+ 1
- 0
backend/lib/schemas/profiles.js Visa fil

@@ -10,6 +10,7 @@ const singleProfile = Joi.object({
10 10
     user_id: Joi.number(),
11 11
     user_name: Joi.string(),
12 12
     user_email: Joi.string(),
13
+    user_info: Joi.any(),
13 14
     responses: surveyResponseSchema.list,
14 15
     reveal: Joi.array().items(),
15 16
     tags: tagSchema.list,

+ 3
- 17
backend/lib/services/profile/profiler.js Visa fil

@@ -9,17 +9,17 @@ class CompleteProfile {
9 9
     constructor(profile, includeResponses = false, type) {
10 10
         this.user_id = profile.user_id // int user_id
11 11
         this.profile_id = profile.profile_id // int profile_id
12
-        this.user_name = profile.user.user_name // string user_name
13
-        this.user_email = profile.user.user_email
12
+        this.user_name = 'hidden_name'// string user_name
13
+        this.user_email = 'hidden@email.com'
14 14
         this.responses = []
15 15
         this.user_type = type
16 16
         this.tags = profile.tags.filter(t => t.tag_category != 'reveal')
17
-
18 17
         // TODO: generalize this for multiple images, and languages
19 18
         this.profile_description = ''
20 19
         this.profile_media = []
21 20
         this.profile_languages = []
22 21
         this.profile_prefs = {}
22
+        this.user_info = profile.user
23 23
 
24 24
         // TODO: Use reveal tags to add or remove information from profile!
25 25
         // TODO: ---
@@ -27,20 +27,6 @@ class CompleteProfile {
27 27
         // TODO: and include for certain profiles
28 28
 
29 29
         this.reveal = profile.tags.filter(t => t.tag_category == 'reveal')
30
-        // Hides values until revealed
31
-        const defaultValues = {
32
-            user_name: 'hidden_name',
33
-            user_email: 'hidden@email.com',
34
-        }
35
-        // BUG: If user reveals EITHER name or email, BOTH get revealed together...
36
-        if (!this.reveal.length) {
37
-            for (let [attribute, defaultVal] of Object.entries(defaultValues)) {
38
-                const typeOfReveal = typeof this.reveal.find(tag => tag.tag_description === attribute)
39
-                if (typeOfReveal == 'undefined') {
40
-                    this[attribute] = defaultVal
41
-                }
42
-            }
43
-        }
44 30
         // TODO: filter these correctly
45 31
         if (profile?.responses?.length && includeResponses) {
46 32
             // [] of all "profile" responses

+ 1
- 0
frontend/src/entities/profile/profile.schema.js Visa fil

@@ -27,6 +27,7 @@ const profileSchema = {
27 27
         user_name: Joi.string(),
28 28
         user_id: Joi.number(),
29 29
         user_email: Joi.string(),
30
+        user_info: Joi.any(),
30 31
         profile_id: Joi.number(),
31 32
         profile_description: Joi.string().allow(null, ''),
32 33
         profile_media: Joi.array().items(Joi.string()),

Laddar…
Avbryt
Spara