Просмотр исходного кода

reverting to always notify

tags/0.0.1^2
J 3 лет назад
Родитель
Сommit
0f8563783f

+ 21
- 29
backend/lib/routes/membership/join.js Просмотреть файл

31
     error: errorSchema.single,
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
 module.exports = {
34
 module.exports = {
54
     method: 'POST',
35
     method: 'POST',
55
     path: '/{profile_id}/join',
36
     path: '/{profile_id}/join',
92
                     groupingToWrite,
73
                     groupingToWrite,
93
                     role,
74
                     role,
94
                 )
75
                 )
95
-
76
+                // console.log(memberships)
96
                 const hasMatch = memberships.every(
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
                 return h
99
                 return h
108
                     .response({
100
                     .response({
109
                         ok: true,
101
                         ok: true,

+ 2
- 1
backend/lib/routes/profile/patch-queue.js Просмотреть файл

16
 
16
 
17
 const responseSchemas = {
17
 const responseSchemas = {
18
     response: Joi.array().items(
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
     error: errorSchema.single,
21
     error: errorSchema.single,
22
 }
22
 }
55
             if (include_profile) {
55
             if (include_profile) {
56
                 res.data = await profileService.getProfilesFor(queueIds)
56
                 res.data = await profileService.getProfilesFor(queueIds)
57
             }
57
             }
58
+
58
             try {
59
             try {
59
                 return h.response(res).code(200)
60
                 return h.response(res).code(200)
60
             } catch (err) {
61
             } catch (err) {

+ 4
- 2
backend/lib/schemas/responses.js Просмотреть файл

18
 
18
 
19
 module.exports = {
19
 module.exports = {
20
     single: singleResponse,
20
     single: singleResponse,
21
-    list: Joi.array().items(singleResponse).label('response_list'),
21
+    list: Joi.array().items(singleResponse.optional()).label('response_list'),
22
     key: singleResponseKey,
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
 }

Загрузка…
Отмена
Сохранить