|
|
@@ -9,8 +9,8 @@ const pluginConfig = {
|
|
9
|
9
|
}
|
|
10
|
10
|
|
|
11
|
11
|
const validators = {
|
|
|
12
|
+ params: Joi.object({ profile_id: Joi.number() }),
|
|
12
|
13
|
payload: Joi.object({
|
|
13
|
|
- profile_id: Joi.number().required(),
|
|
14
|
14
|
target_id: Joi.number().required(),
|
|
15
|
15
|
grouping_id: Joi.number().allow(null),
|
|
16
|
16
|
grouping_name: Joi.string().allow(null),
|
|
|
@@ -31,7 +31,7 @@ const responseSchemas = {
|
|
31
|
31
|
|
|
32
|
32
|
module.exports = {
|
|
33
|
33
|
method: 'POST',
|
|
34
|
|
- path: '/join',
|
|
|
34
|
+ path: '/{profile_id}/join',
|
|
35
|
35
|
options: {
|
|
36
|
36
|
...pluginConfig.docs,
|
|
37
|
37
|
tags: ['api'],
|
|
|
@@ -49,6 +49,7 @@ module.exports = {
|
|
49
|
49
|
const { membershipService } = request.server.services()
|
|
50
|
50
|
|
|
51
|
51
|
/** Grab payload info */
|
|
|
52
|
+ const profileId = request.params.profile_id
|
|
52
|
53
|
const res = request.payload
|
|
53
|
54
|
const groupingToWrite = {
|
|
54
|
55
|
grouping_id: res.grouping_id,
|
|
|
@@ -59,10 +60,14 @@ module.exports = {
|
|
59
|
60
|
/** Default to participant role */
|
|
60
|
61
|
const role = res.role ? res.role : 'participant'
|
|
61
|
62
|
|
|
|
63
|
+ // TODO: LIMIT the amount of groupings by checking type
|
|
|
64
|
+ // !: You should only be able to match with the target_id ONCE
|
|
|
65
|
+ // !: You should only be associated with a single company too
|
|
62
|
66
|
console.log('---')
|
|
|
67
|
+
|
|
63
|
68
|
/** User membership service method to create membership */
|
|
64
|
69
|
const memberships = await membershipService.joinGrouping(
|
|
65
|
|
- res.profile_id,
|
|
|
70
|
+ profileId,
|
|
66
|
71
|
res.target_id,
|
|
67
|
72
|
groupingToWrite,
|
|
68
|
73
|
role,
|