@live-change/email-service 0.2.8 → 0.2.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/auth.js +44 -0
- package/package.json +2 -2
package/auth.js
CHANGED
|
@@ -53,6 +53,20 @@ definition.event({
|
|
|
53
53
|
}
|
|
54
54
|
})
|
|
55
55
|
|
|
56
|
+
definition.event({
|
|
57
|
+
name: "userDeleted",
|
|
58
|
+
properties: {
|
|
59
|
+
user: {
|
|
60
|
+
type: User,
|
|
61
|
+
validation: ['nonEmpty']
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
async execute({ user }) {
|
|
65
|
+
const emails = await Email.indexRangeGet('byUser', user)
|
|
66
|
+
await Promise.all(emails.map(email => Email.delete(email)))
|
|
67
|
+
}
|
|
68
|
+
})
|
|
69
|
+
|
|
56
70
|
definition.trigger({
|
|
57
71
|
name: "checkNewEmail",
|
|
58
72
|
properties: {
|
|
@@ -136,6 +150,7 @@ definition.trigger({
|
|
|
136
150
|
async execute({ user, email }, { client, service }, emit) {
|
|
137
151
|
const emailData = await Email.get(email)
|
|
138
152
|
if(!emailData) throw { properties: { email: 'notFound' } }
|
|
153
|
+
if(emailData.user != user) throw { properties: { email: 'notFound' } }
|
|
139
154
|
emit({
|
|
140
155
|
type: 'emailDisconnected',
|
|
141
156
|
user, email
|
|
@@ -162,4 +177,33 @@ definition.trigger({
|
|
|
162
177
|
}
|
|
163
178
|
})
|
|
164
179
|
|
|
180
|
+
definition.trigger({
|
|
181
|
+
name: "getConnectedContacts",
|
|
182
|
+
properties: {
|
|
183
|
+
user: {
|
|
184
|
+
type: User,
|
|
185
|
+
validation: ['nonEmpty', 'email']
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
async execute({ user }, context, emit) {
|
|
189
|
+
const emails = await Email.indexRangeGet('byUser', user)
|
|
190
|
+
return emails.map(email => ({ ...email, type: 'email', contact: email.email }))
|
|
191
|
+
}
|
|
192
|
+
})
|
|
193
|
+
|
|
194
|
+
definition.trigger({
|
|
195
|
+
name: 'userDeleted',
|
|
196
|
+
properties: {
|
|
197
|
+
user: {
|
|
198
|
+
type: User
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
async execute({ user }, { service }, emit) {
|
|
202
|
+
emit([{
|
|
203
|
+
type: "userDeleted",
|
|
204
|
+
user
|
|
205
|
+
}])
|
|
206
|
+
}
|
|
207
|
+
})
|
|
208
|
+
|
|
165
209
|
module.exports = { Email }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@live-change/email-service",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.16",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -28,5 +28,5 @@
|
|
|
28
28
|
"jsdom": "^18.1.1",
|
|
29
29
|
"nodemailer": "^6.7.2"
|
|
30
30
|
},
|
|
31
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "98a41ae61218a0ec58d4861b6409d8d9facde37f"
|
|
32
32
|
}
|