|
|
@@ -51,19 +51,29 @@ module.exports = {
|
|
51
|
51
|
membership => membership.profile_id,
|
|
52
|
52
|
)
|
|
53
|
53
|
|
|
54
|
|
- // Grab User Info from Users Table and prepare revealed info for
|
|
55
|
|
- // notification based off of tag_id
|
|
|
54
|
+ // Grab User Info from Users Table
|
|
56
|
55
|
const completeProfile = await profileService.getProfilesFor([profile_id], 'participant')
|
|
57
|
|
- let revealInfo
|
|
58
|
|
- let tag_description
|
|
59
|
|
- if (tag_id == 7) {
|
|
60
|
|
- revealInfo = completeProfile[0].user_name
|
|
61
|
|
- tag_description = 'name'
|
|
62
|
|
- } else if (tag_id == 8) {
|
|
63
|
|
- revealInfo = completeProfile[0].user_email
|
|
64
|
|
- tag_description = 'email'
|
|
|
56
|
+
|
|
|
57
|
+ // Grab the TagAssociation that matches the revealed profile
|
|
|
58
|
+ // TODO: Check if there are multiple matching tags(?)(there shouldn't be)
|
|
|
59
|
+ const returnedTag = () => {
|
|
|
60
|
+ let matchingTag
|
|
|
61
|
+ tags.forEach(async (tagAssoc) => {
|
|
|
62
|
+ if (tagAssoc.grouping_id === grouping_id &&
|
|
|
63
|
+ tagAssoc.profile_id === profile_id &&
|
|
|
64
|
+ tagAssoc.tag_id === tag_id) {
|
|
|
65
|
+ matchingTag = tagAssoc
|
|
|
66
|
+ }
|
|
|
67
|
+ })
|
|
|
68
|
+ if (matchingTag)
|
|
|
69
|
+ return matchingTag
|
|
|
70
|
+ return console.error('ERROR: No matching tagAssociation')
|
|
65
|
71
|
}
|
|
66
|
72
|
|
|
|
73
|
+ const tag_description = returnedTag().tag.tag_description
|
|
|
74
|
+ // TODO: Refactor completeProfile[0]... code smell
|
|
|
75
|
+ const revealInfo = completeProfile[0][tag_description]
|
|
|
76
|
+
|
|
67
|
77
|
idsInGroup.forEach(profile_id => {
|
|
68
|
78
|
request.server.methods.notify(
|
|
69
|
79
|
`${profile_id}.stonk`,
|