Browse Source

reverting to always notify

tags/0.0.1^2
J 3 years ago
parent
commit
0f8563783f

+ 21
- 29
backend/lib/routes/membership/join.js View File

@@ -31,25 +31,6 @@ const responseSchemas = {
31 31
     error: errorSchema.single,
32 32
 }
33 33
 
34
-const notifyMembers = (profileId, targetId, noticationCb, h) => {
35
-    noticationCb(
36
-        `${profileId}.stonk`,
37
-        {
38
-            name: `${targetId} Match Fffound`,
39
-            type: 'info',
40
-        },
41
-        h,
42
-    )
43
-    noticationCb(
44
-        `${targetId}.stonk`,
45
-        {
46
-            name: `${profileId} Match Fffound`,
47
-            type: 'info',
48
-        },
49
-        h,
50
-    )
51
-}
52
-
53 34
 module.exports = {
54 35
     method: 'POST',
55 36
     path: '/{profile_id}/join',
@@ -92,18 +73,29 @@ module.exports = {
92 73
                     groupingToWrite,
93 74
                     role,
94 75
                 )
95
-
76
+                // console.log(memberships)
96 77
                 const hasMatch = memberships.every(
97
-                    membership => membership.is_active == true,
78
+                    membership => membership && membership.is_active == true,
98 79
                 )
99
-                if (hasMatch) {
100
-                    notifyMembers(
101
-                        profileId,
102
-                        res.target_id,
103
-                        request.server.notify,
104
-                        h,
105
-                    )
106
-                }
80
+                request.server.methods.notify(
81
+                    `${profileId}.stonk`,
82
+                    {
83
+                        name: `${res.target_id} Match Fffound`,
84
+                        type: 'info',
85
+                    },
86
+                    h,
87
+                )
88
+                request.server.methods.notify(
89
+                    `${res.target_id}.stonk`,
90
+                    {
91
+                        name: `${profileId} Match Fffound`,
92
+                        type: 'info',
93
+                    },
94
+                    h,
95
+                )
96
+                console.log('hasMatch :>> ', hasMatch)
97
+                console.log('memberships :>> ', memberships)
98
+
107 99
                 return h
108 100
                     .response({
109 101
                         ok: true,

+ 2
- 1
backend/lib/routes/profile/patch-queue.js View File

@@ -16,7 +16,7 @@ const pluginConfig = {
16 16
 
17 17
 const responseSchemas = {
18 18
     response: Joi.array().items(
19
-        Joi.alternatives().try(Joi.number(), profileSchema.single),
19
+        Joi.alternatives().try(Joi.number().optional(), profileSchema.single),
20 20
     ),
21 21
     error: errorSchema.single,
22 22
 }
@@ -55,6 +55,7 @@ module.exports = {
55 55
             if (include_profile) {
56 56
                 res.data = await profileService.getProfilesFor(queueIds)
57 57
             }
58
+
58 59
             try {
59 60
                 return h.response(res).code(200)
60 61
             } catch (err) {

+ 4
- 2
backend/lib/schemas/responses.js View File

@@ -18,7 +18,9 @@ const singleResponseKey = Joi.object({
18 18
 
19 19
 module.exports = {
20 20
     single: singleResponse,
21
-    list: Joi.array().items(singleResponse).label('response_list'),
21
+    list: Joi.array().items(singleResponse.optional()).label('response_list'),
22 22
     key: singleResponseKey,
23
-    keys: Joi.array().items(singleResponseKey).label('question_list')
23
+    keys: Joi.array()
24
+        .items(singleResponseKey.optional())
25
+        .label('question_list'),
24 26
 }

Loading…
Cancel
Save