backend-manager 3.0.29 → 3.0.30
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/package.json +1 -1
- package/src/manager/functions/core/actions/api/admin/backup.js +11 -11
- package/src/manager/functions/core/actions/api/admin/create-post.js +2 -2
- package/src/manager/functions/core/actions/api/admin/database-write.js +1 -1
- package/src/manager/functions/core/actions/api/admin/firestore-query.js +2 -2
- package/src/manager/functions/core/actions/api/admin/firestore-read.js +2 -2
- package/src/manager/functions/core/actions/api/admin/firestore-write.js +1 -1
- package/src/manager/functions/core/actions/api/admin/payment-processor.js +2 -2
- package/src/manager/functions/core/actions/api/admin/send-notification.js +4 -4
- package/src/manager/functions/core/actions/api/admin/sync-users.js +4 -4
- package/src/manager/functions/core/actions/api/firebase/get-providers.js +2 -2
- package/src/manager/functions/core/actions/api/general/generate-uuid.js +1 -1
- package/src/manager/functions/core/actions/api/general/send-email.js +3 -3
- package/src/manager/functions/core/actions/api/special/setup-electron-manager-client.js +1 -1
- package/src/manager/functions/core/actions/api/user/get-active-sessions.js +1 -1
- package/src/manager/functions/core/actions/api/user/get-subscription-info.js +2 -2
- package/src/manager/functions/core/actions/api/user/oauth2/discord.js +1 -1
- package/src/manager/functions/core/actions/api/user/oauth2.js +13 -13
- package/src/manager/functions/core/actions/api/user/regenerate-api-keys.js +1 -1
- package/src/manager/functions/core/actions/api/user/sign-out-all-sessions.js +9 -9
- package/src/manager/functions/core/actions/api/user/sign-up.js +4 -4
- package/src/manager/functions/core/actions/api/user/submit-feedback.js +3 -3
- package/src/manager/functions/core/actions/api/user/validate-settings.js +3 -3
- package/src/manager/functions/core/actions/api.js +6 -6
- package/src/manager/functions/core/actions/create-post-handler.js +2 -2
- package/src/manager/functions/core/actions/generate-uuid.js +2 -2
- package/src/manager/functions/core/actions/old/api-2.js +6 -6
- package/src/manager/functions/core/actions/sign-up-handler.js +3 -3
- package/src/manager/functions/core/admin/create-post.js +3 -3
- package/src/manager/functions/core/admin/firestore-write.js +2 -2
- package/src/manager/functions/core/admin/get-stats.js +9 -9
- package/src/manager/functions/core/admin/query.js +5 -5
- package/src/manager/functions/core/admin/send-notification.js +5 -5
- package/src/manager/functions/core/cron/daily.js +3 -3
- package/src/manager/functions/core/events/auth/before-signin.js +2 -2
- package/src/manager/functions/core/events/auth/on-create.js +4 -4
- package/src/manager/functions/core/events/auth/on-delete.js +3 -3
- package/src/manager/functions/core/events/firestore/on-subscription.js +8 -8
- package/src/manager/helpers/assistant.js +1 -2
- package/src/manager/index.js +22 -22
|
@@ -31,7 +31,7 @@ Module.prototype.init = function (Manager, data) {
|
|
|
31
31
|
self.assistant.request.data.options = self.assistant.request.data.options || {};
|
|
32
32
|
|
|
33
33
|
if (Manager.options.log) {
|
|
34
|
-
self.assistant.log(`Executing (log): ${resolved.command}`, self.assistant.request, JSON.stringify(self.assistant.request)
|
|
34
|
+
self.assistant.log(`Executing (log): ${resolved.command}`, self.assistant.request, JSON.stringify(self.assistant.request))
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
return self;
|
|
@@ -58,8 +58,8 @@ Module.prototype.main = function() {
|
|
|
58
58
|
// Resolve command
|
|
59
59
|
const resolved = self.resolveCommand(self.payload.data.command);
|
|
60
60
|
|
|
61
|
-
self.assistant.log(`Executing: ${resolved.command}`, self.payload, JSON.stringify(self.payload)
|
|
62
|
-
self.assistant.log(`Resolved URL: ${Manager.project.functionsUrl}?command=${encodeURIComponent(resolved.command)}&payload=${encodeURIComponent(JSON.stringify(self.assistant.request.data.payload))}
|
|
61
|
+
self.assistant.log(`Executing: ${resolved.command}`, self.payload, JSON.stringify(self.payload))
|
|
62
|
+
self.assistant.log(`Resolved URL: ${Manager.project.functionsUrl}?command=${encodeURIComponent(resolved.command)}&payload=${encodeURIComponent(JSON.stringify(self.assistant.request.data.payload))}`)
|
|
63
63
|
|
|
64
64
|
// Set up options
|
|
65
65
|
self.payload.data.options = self.payload.data.options || {};
|
|
@@ -70,7 +70,7 @@ Module.prototype.main = function() {
|
|
|
70
70
|
let delay = Math.floor(self.payload.data.options.delay / 1000);
|
|
71
71
|
|
|
72
72
|
await powertools.poll(() => {
|
|
73
|
-
self.assistant.log(`Delaying for ${delay--} seconds
|
|
73
|
+
self.assistant.log(`Delaying for ${delay--} seconds...`);
|
|
74
74
|
}, {interval: 1000, timeout: self.payload.data.options.delay})
|
|
75
75
|
.catch(e => e);
|
|
76
76
|
}
|
|
@@ -113,7 +113,7 @@ Module.prototype.main = function() {
|
|
|
113
113
|
res.status(self.payload.response.status)
|
|
114
114
|
|
|
115
115
|
if (self.payload.response.status >= 200 && self.payload.response.status < 300) {
|
|
116
|
-
self.assistant.log(`Finished ${resolved.command} (status=${self.payload.response.status})`, self.payload, JSON.stringify(self.payload)
|
|
116
|
+
self.assistant.log(`Finished ${resolved.command} (status=${self.payload.response.status})`, self.payload, JSON.stringify(self.payload))
|
|
117
117
|
|
|
118
118
|
if (self.payload.response.redirect) {
|
|
119
119
|
res.redirect(self.payload.response.redirect);
|
|
@@ -248,7 +248,7 @@ Module.prototype.resolveCommand = function (command) {
|
|
|
248
248
|
|
|
249
249
|
// if (!command || command === 'error:error') {
|
|
250
250
|
if (!resolvedPath) {
|
|
251
|
-
self.assistant.log(`This command does not exist: ${originalCommand} => ${command} @ ${resolvedPath}
|
|
251
|
+
self.assistant.log(`This command does not exist: ${originalCommand} => ${command} @ ${resolvedPath}`)
|
|
252
252
|
}
|
|
253
253
|
|
|
254
254
|
return {
|
|
@@ -49,7 +49,7 @@ let Module = {
|
|
|
49
49
|
if (!user.roles.admin) {
|
|
50
50
|
response.status = 401;
|
|
51
51
|
response.error = new Error('Unauthenticated, admin required.');
|
|
52
|
-
assistant.error(response.error
|
|
52
|
+
assistant.error(response.error)
|
|
53
53
|
} else {
|
|
54
54
|
mailchimp = new Mailchimp(get(self.Manager.config, 'mailchimp.key', ''));
|
|
55
55
|
await fetch(`https://us-central1-${self.Manager.project.projectId}.cloudfunctions.net/bm_sendNotification`, {
|
|
@@ -124,7 +124,7 @@ let Module = {
|
|
|
124
124
|
})
|
|
125
125
|
.then(async (content) => {
|
|
126
126
|
await mailchimp.post(`/campaigns/${campaign.id}/actions/send`)
|
|
127
|
-
assistant.log('Mailchimp campaign created and sent', campaign
|
|
127
|
+
assistant.log('Mailchimp campaign created and sent', campaign);
|
|
128
128
|
})
|
|
129
129
|
} else {
|
|
130
130
|
throw new Error('Failed to fetch.');
|
|
@@ -35,7 +35,7 @@ let Module = {
|
|
|
35
35
|
action: 'generate-uuid',
|
|
36
36
|
// label: '',
|
|
37
37
|
});
|
|
38
|
-
|
|
38
|
+
|
|
39
39
|
const namespace = assistant.request.data.namespace || self.Manager.config.backend_manager.namespace;
|
|
40
40
|
assistant.request.data.version = `${assistant.request.data.version || '5'}`.replace('v', '');
|
|
41
41
|
assistant.request.data.name = assistant.request.data.name || assistant.request.data.input;
|
|
@@ -49,7 +49,7 @@ let Module = {
|
|
|
49
49
|
response.data.uuid = uuid.v4();
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
assistant.log('UUID Generated', assistant.request.data, response
|
|
52
|
+
assistant.log('UUID Generated', assistant.request.data, response);
|
|
53
53
|
|
|
54
54
|
if (response.status === 200) {
|
|
55
55
|
return res.status(response.status).json(response.data);
|
|
@@ -33,10 +33,10 @@ let Module = {
|
|
|
33
33
|
user: user,
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
self.assistant.log('Executing', command
|
|
36
|
+
self.assistant.log('Executing', command)
|
|
37
37
|
|
|
38
38
|
function _errorLog(e) {
|
|
39
|
-
self.assistant.error(e
|
|
39
|
+
self.assistant.error(e)
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
// Actions
|
|
@@ -85,7 +85,7 @@ let Module = {
|
|
|
85
85
|
response.error = new Error(`Improper command supplied: ${command}`);
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
self.assistant.log('Api payload', {object: payload, string: JSON.stringify(payload)}
|
|
88
|
+
self.assistant.log('Api payload', {object: payload, string: JSON.stringify(payload)})
|
|
89
89
|
|
|
90
90
|
if (response.status === 200) {
|
|
91
91
|
return res.status(response.status).json(response.data);
|
|
@@ -111,7 +111,7 @@ let Module = {
|
|
|
111
111
|
processor = new (require(processorPath));
|
|
112
112
|
processor.Manager = self.Manager;
|
|
113
113
|
} catch (e) {
|
|
114
|
-
self.assistant.error('Error loading processor', processorPath, e
|
|
114
|
+
self.assistant.error('Error loading processor', processorPath, e)
|
|
115
115
|
return resolve()
|
|
116
116
|
}
|
|
117
117
|
|
|
@@ -208,7 +208,7 @@ let Module = {
|
|
|
208
208
|
const keys = Object.keys(data || {});
|
|
209
209
|
for (var i = 0; i < keys.length; i++) {
|
|
210
210
|
const key = keys[i];
|
|
211
|
-
self.assistant.log(`Signing out: ${key}
|
|
211
|
+
self.assistant.log(`Signing out: ${key}`);
|
|
212
212
|
await self.libraries.admin.database().ref(`gatherings/online/${key}/command`).set('signout').catch(e => self.assistant.error(`Failed to signout ${key}`, e))
|
|
213
213
|
await powertools.wait(3000);
|
|
214
214
|
await self.libraries.admin.database().ref(`gatherings/online/${key}`).remove().catch(e => self.assistant.error(`Failed to delete ${key}`, e))
|
|
@@ -222,7 +222,7 @@ let Module = {
|
|
|
222
222
|
.auth()
|
|
223
223
|
.revokeRefreshTokens(uid)
|
|
224
224
|
.then(() => {
|
|
225
|
-
self.assistant.log('Signed user out of all sessions', payload.user.auth.uid
|
|
225
|
+
self.assistant.log('Signed user out of all sessions', payload.user.auth.uid)
|
|
226
226
|
payload.data = {message: `Successfully signed ${payload.user.auth.uid} out of all sessions`}
|
|
227
227
|
return resolve(payload.data);
|
|
228
228
|
})
|
|
@@ -26,7 +26,7 @@ let Module = {
|
|
|
26
26
|
|
|
27
27
|
return libraries.cors(req, res, async () => {
|
|
28
28
|
let user = await assistant.authenticate();
|
|
29
|
-
|
|
29
|
+
|
|
30
30
|
if (!user.authenticated) {
|
|
31
31
|
response.status = 401;
|
|
32
32
|
response.error = new Error('Account does not exist in Auth.');
|
|
@@ -63,12 +63,12 @@ let Module = {
|
|
|
63
63
|
})
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
assistant.log('Signup handler:', assistant.request.data, response
|
|
66
|
+
assistant.log('Signup handler:', assistant.request.data, response);
|
|
67
67
|
|
|
68
68
|
if (response.status === 200) {
|
|
69
69
|
return res.status(response.status).json(response.data);
|
|
70
70
|
} else {
|
|
71
|
-
assistant.error('Failed to signup:', assistant.request.data, user
|
|
71
|
+
assistant.error('Failed to signup:', assistant.request.data, user);
|
|
72
72
|
return res.status(response.status).send(response.error.message);
|
|
73
73
|
}
|
|
74
74
|
});
|
|
@@ -44,7 +44,7 @@ let Module = {
|
|
|
44
44
|
if (!user.roles.admin) {
|
|
45
45
|
response.status = 401;
|
|
46
46
|
response.error = new Error('Unauthenticated, admin required.');
|
|
47
|
-
assistant.error(response.error
|
|
47
|
+
assistant.error(response.error)
|
|
48
48
|
} else {
|
|
49
49
|
// Poster = Poster || require('/Users/ianwiedenman/Documents/GitHub/ITW-Creative-Works/ultimate-jekyll-poster');
|
|
50
50
|
Poster = Poster || require('ultimate-jekyll-poster');
|
|
@@ -71,11 +71,11 @@ let Module = {
|
|
|
71
71
|
.catch((e) => {
|
|
72
72
|
response.status = 400;
|
|
73
73
|
response.error = new Error('Failed to post: ' + e);
|
|
74
|
-
assistant.error(response.error
|
|
74
|
+
assistant.error(response.error)
|
|
75
75
|
})
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
assistant.log('Post', assistant.request.data, response
|
|
78
|
+
assistant.log('Post', assistant.request.data, response);
|
|
79
79
|
|
|
80
80
|
if (response.status === 200) {
|
|
81
81
|
return res.status(response.status).json(response.data);
|
|
@@ -51,7 +51,7 @@ let Module = {
|
|
|
51
51
|
await admin.firestore().doc(options.path)
|
|
52
52
|
.set(options.document, options.options)
|
|
53
53
|
.then(r => {
|
|
54
|
-
assistant.log(`Wrote to ${options.path}:`, options.document, options.options
|
|
54
|
+
assistant.log(`Wrote to ${options.path}:`, options.document, options.options)
|
|
55
55
|
})
|
|
56
56
|
.catch(e => {
|
|
57
57
|
response.status = 500;
|
|
@@ -62,7 +62,7 @@ let Module = {
|
|
|
62
62
|
if (response.status === 200) {
|
|
63
63
|
return res.status(response.status).json(response.data);
|
|
64
64
|
} else {
|
|
65
|
-
assistant.error(response.error
|
|
65
|
+
assistant.error(response.error)
|
|
66
66
|
return res.status(response.status).send(response.error.message);
|
|
67
67
|
}
|
|
68
68
|
});
|
|
@@ -35,11 +35,11 @@ let Module = {
|
|
|
35
35
|
action: 'get-stats',
|
|
36
36
|
// label: '',
|
|
37
37
|
});
|
|
38
|
-
|
|
38
|
+
|
|
39
39
|
if (!user.roles.admin) {
|
|
40
40
|
response.status = 401;
|
|
41
41
|
response.error = new Error('Unauthenticated, admin required.');
|
|
42
|
-
assistant.error(response.error
|
|
42
|
+
assistant.error(response.error)
|
|
43
43
|
} else {
|
|
44
44
|
let stats = libraries.admin.firestore().doc(`meta/stats`)
|
|
45
45
|
|
|
@@ -51,14 +51,14 @@ let Module = {
|
|
|
51
51
|
.catch(e => {
|
|
52
52
|
response.status = 500;
|
|
53
53
|
response.error = new Error(`Failed fixing stats: ${e.message}`);
|
|
54
|
-
assistant.error(response.error
|
|
54
|
+
assistant.error(response.error)
|
|
55
55
|
})
|
|
56
56
|
|
|
57
57
|
await self.updateStats()
|
|
58
58
|
.catch(e => {
|
|
59
59
|
response.status = 500;
|
|
60
60
|
response.error = new Error(`Failed updating stats: ${e.message}`);
|
|
61
|
-
assistant.error(response.error
|
|
61
|
+
assistant.error(response.error)
|
|
62
62
|
})
|
|
63
63
|
|
|
64
64
|
await stats
|
|
@@ -69,19 +69,19 @@ let Module = {
|
|
|
69
69
|
.catch(function (e) {
|
|
70
70
|
response.status = 500;
|
|
71
71
|
response.error = e;
|
|
72
|
-
assistant.error(response.error
|
|
72
|
+
assistant.error(response.error)
|
|
73
73
|
})
|
|
74
74
|
})
|
|
75
75
|
.catch(function (e) {
|
|
76
76
|
response.status = 500;
|
|
77
77
|
response.error = e;
|
|
78
|
-
assistant.error(response.error
|
|
78
|
+
assistant.error(response.error)
|
|
79
79
|
})
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
// response.data = data;
|
|
83
83
|
|
|
84
|
-
assistant.log('Stats', assistant.request.data, response
|
|
84
|
+
assistant.log('Stats', assistant.request.data, response);
|
|
85
85
|
|
|
86
86
|
if (response.status === 200) {
|
|
87
87
|
return res.status(response.status).json(response.data);
|
|
@@ -105,7 +105,7 @@ let Module = {
|
|
|
105
105
|
.catch(e => {
|
|
106
106
|
response.status = 500;
|
|
107
107
|
response.error = new Error(`Failed fixing stats: ${e.message}`);
|
|
108
|
-
self.assistant.error(response.error
|
|
108
|
+
self.assistant.error(response.error);
|
|
109
109
|
})
|
|
110
110
|
await self.getAllSubscriptions()
|
|
111
111
|
.then(r => {
|
|
@@ -114,7 +114,7 @@ let Module = {
|
|
|
114
114
|
.catch(e => {
|
|
115
115
|
response.status = 500;
|
|
116
116
|
response.error = new Error(`Failed fixing stats: ${e.message}`);
|
|
117
|
-
self.assistant.error(response.error
|
|
117
|
+
self.assistant.error(response.error);
|
|
118
118
|
})
|
|
119
119
|
await stats
|
|
120
120
|
.set({
|
|
@@ -38,11 +38,11 @@ let Module = {
|
|
|
38
38
|
action: 'query',
|
|
39
39
|
// label: '',
|
|
40
40
|
});
|
|
41
|
-
|
|
41
|
+
|
|
42
42
|
if (!user.roles.admin) {
|
|
43
43
|
response.status = 401;
|
|
44
44
|
response.error = new Error('Unauthenticated, admin required.');
|
|
45
|
-
assistant.error(response.error
|
|
45
|
+
assistant.error(response.error)
|
|
46
46
|
} else {
|
|
47
47
|
self.docs = [];
|
|
48
48
|
// assistant.log('Queries', assistant.request.data.queries);
|
|
@@ -62,11 +62,11 @@ let Module = {
|
|
|
62
62
|
.catch((e) => {
|
|
63
63
|
response.error = e;
|
|
64
64
|
response.status = 400;
|
|
65
|
-
assistant.error(response.error
|
|
65
|
+
assistant.error(response.error)
|
|
66
66
|
})
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
assistant.log('Query', assistant.request.data, response
|
|
69
|
+
assistant.log('Query', assistant.request.data, response);
|
|
70
70
|
|
|
71
71
|
if (response.status === 200) {
|
|
72
72
|
return res.status(response.status).json(response.data);
|
|
@@ -152,7 +152,7 @@ async function runQuery(payload) {
|
|
|
152
152
|
return resolve(self.docs);
|
|
153
153
|
})
|
|
154
154
|
.catch(function (error) {
|
|
155
|
-
self.assistant.error(error
|
|
155
|
+
self.assistant.error(error)
|
|
156
156
|
return reject(error);
|
|
157
157
|
});
|
|
158
158
|
});
|
|
@@ -37,7 +37,7 @@ let Module = {
|
|
|
37
37
|
});
|
|
38
38
|
|
|
39
39
|
let payload = self.assistant.request.data.payload || {};
|
|
40
|
-
|
|
40
|
+
|
|
41
41
|
if (!payload.title || !payload.body) {
|
|
42
42
|
response.status = 400;
|
|
43
43
|
response.error = new Error('Not enough notification parameters supplied.');
|
|
@@ -54,7 +54,7 @@ let Module = {
|
|
|
54
54
|
await self.getTokens({tags: false});
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
assistant.log('Notification', assistant.request.data, response
|
|
57
|
+
assistant.log('Notification', assistant.request.data, response);
|
|
58
58
|
|
|
59
59
|
if (response.status === 200) {
|
|
60
60
|
return res.status(response.status).json(response.data);
|
|
@@ -104,7 +104,7 @@ function sendBatch(batch, id) {
|
|
|
104
104
|
resolve();
|
|
105
105
|
})
|
|
106
106
|
.catch(function (e) {
|
|
107
|
-
self.assistant.error('Error sending batch #' + id, e
|
|
107
|
+
self.assistant.error('Error sending batch #' + id, e);
|
|
108
108
|
// self.result.status = 'fail';
|
|
109
109
|
reject(e);
|
|
110
110
|
})
|
|
@@ -150,7 +150,7 @@ function getTokens(options) {
|
|
|
150
150
|
});
|
|
151
151
|
})
|
|
152
152
|
.catch(function(e) {
|
|
153
|
-
self.assistant.error('Error querying tokens: ', e
|
|
153
|
+
self.assistant.error('Error querying tokens: ', e)
|
|
154
154
|
reject(error);
|
|
155
155
|
});
|
|
156
156
|
|
|
@@ -159,7 +159,7 @@ function getTokens(options) {
|
|
|
159
159
|
self.assistant.log('Finished all batches.');
|
|
160
160
|
})
|
|
161
161
|
.catch(function(e) {
|
|
162
|
-
self.assistant.error('Error sending batches: ', e
|
|
162
|
+
self.assistant.error('Error sending batches: ', e)
|
|
163
163
|
});
|
|
164
164
|
resolve();
|
|
165
165
|
|
|
@@ -35,7 +35,7 @@ Module.prototype.main = function() {
|
|
|
35
35
|
// }
|
|
36
36
|
// })
|
|
37
37
|
// .then(response => {
|
|
38
|
-
// assistant.log(`Successfully executed backup:`, response
|
|
38
|
+
// assistant.log(`Successfully executed backup:`, response)
|
|
39
39
|
// }),
|
|
40
40
|
|
|
41
41
|
// Sync Firestore users to the database
|
|
@@ -49,14 +49,14 @@ Module.prototype.main = function() {
|
|
|
49
49
|
// }
|
|
50
50
|
// })
|
|
51
51
|
// .then(response => {
|
|
52
|
-
// assistant.log(`Successfully executed sync-users:`, response
|
|
52
|
+
// assistant.log(`Successfully executed sync-users:`, response)
|
|
53
53
|
// }),
|
|
54
54
|
|
|
55
55
|
// More daily processes
|
|
56
56
|
// ...
|
|
57
57
|
])
|
|
58
58
|
.then(() => {
|
|
59
|
-
assistant.log(`Successfully executed all daily processes
|
|
59
|
+
assistant.log(`Successfully executed all daily processes:`)
|
|
60
60
|
return resolve();
|
|
61
61
|
})
|
|
62
62
|
.catch(e => {
|
|
@@ -26,7 +26,7 @@ Module.prototype.main = function () {
|
|
|
26
26
|
const functions = self.libraries.functions;
|
|
27
27
|
const admin = self.libraries.admin;
|
|
28
28
|
|
|
29
|
-
assistant.log(`Request: ${user.uid}`, user, context
|
|
29
|
+
assistant.log(`Request: ${user.uid}`, user, context);
|
|
30
30
|
|
|
31
31
|
const now = new Date();
|
|
32
32
|
|
|
@@ -54,7 +54,7 @@ Module.prototype.main = function () {
|
|
|
54
54
|
throw new functions.auth.HttpsError('internal', `Failed to update user: ${update}`);
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
assistant.log(`Updated user activity
|
|
57
|
+
assistant.log(`Updated user activity`);
|
|
58
58
|
|
|
59
59
|
return resolve(self);
|
|
60
60
|
});
|
|
@@ -41,7 +41,7 @@ Module.prototype.main = function () {
|
|
|
41
41
|
get(existingUser, 'auth.uid', null)
|
|
42
42
|
|| get(existingUser, 'auth.email', null)
|
|
43
43
|
) {
|
|
44
|
-
assistant.log(`Skipping handler because user already exists ${user.uid}:`, existingUser
|
|
44
|
+
assistant.log(`Skipping handler because user already exists ${user.uid}:`, existingUser);
|
|
45
45
|
|
|
46
46
|
return resolve(self);
|
|
47
47
|
}
|
|
@@ -81,7 +81,7 @@ Module.prototype.main = function () {
|
|
|
81
81
|
await libraries.admin.firestore().doc(`users/${newUser.auth.uid}`)
|
|
82
82
|
.set(newUser, {merge: true})
|
|
83
83
|
.catch((e) => {
|
|
84
|
-
assistant.error(`Failed save user record`, e
|
|
84
|
+
assistant.error(`Failed save user record`, e);
|
|
85
85
|
})
|
|
86
86
|
|
|
87
87
|
// Update user count
|
|
@@ -90,10 +90,10 @@ Module.prototype.main = function () {
|
|
|
90
90
|
'users.total': libraries.admin.firestore.FieldValue.increment(1),
|
|
91
91
|
})
|
|
92
92
|
.catch((e) => {
|
|
93
|
-
assistant.error(`Failed to increment user`, e
|
|
93
|
+
assistant.error(`Failed to increment user`, e);
|
|
94
94
|
})
|
|
95
95
|
|
|
96
|
-
assistant.log(`User created ${user.uid}:`, newUser, user, context
|
|
96
|
+
assistant.log(`User created ${user.uid}:`, newUser, user, context);
|
|
97
97
|
|
|
98
98
|
return resolve(self);
|
|
99
99
|
});
|
|
@@ -38,7 +38,7 @@ Module.prototype.main = function () {
|
|
|
38
38
|
await libraries.admin.firestore().doc(`users/${user.uid}`)
|
|
39
39
|
.delete()
|
|
40
40
|
.catch((e) => {
|
|
41
|
-
assistant.error(`Delete user failed`, e
|
|
41
|
+
assistant.error(`Delete user failed`, e);
|
|
42
42
|
})
|
|
43
43
|
|
|
44
44
|
// Update user count
|
|
@@ -47,10 +47,10 @@ Module.prototype.main = function () {
|
|
|
47
47
|
'users.total': libraries.admin.firestore.FieldValue.increment(-1),
|
|
48
48
|
})
|
|
49
49
|
.catch((e) => {
|
|
50
|
-
assistant.error(`Failed to decrement user`, e
|
|
50
|
+
assistant.error(`Failed to decrement user`, e);
|
|
51
51
|
})
|
|
52
52
|
|
|
53
|
-
assistant.log(`User deleted ${user.uid}:`, user, context
|
|
53
|
+
assistant.log(`User deleted ${user.uid}:`, user, context);
|
|
54
54
|
|
|
55
55
|
return resolve(self);
|
|
56
56
|
});
|
|
@@ -10,7 +10,7 @@ Module.prototype.init = function (Manager, payload) {
|
|
|
10
10
|
self.change = payload.change
|
|
11
11
|
self.context = payload.context
|
|
12
12
|
|
|
13
|
-
return self;
|
|
13
|
+
return self;
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
Module.prototype.main = function () {
|
|
@@ -18,8 +18,8 @@ Module.prototype.main = function () {
|
|
|
18
18
|
const libraries = self.libraries;
|
|
19
19
|
const assistant = self.assistant;
|
|
20
20
|
const change = self.change;
|
|
21
|
-
const context = self.context;
|
|
22
|
-
|
|
21
|
+
const context = self.context;
|
|
22
|
+
|
|
23
23
|
return new Promise(async function(resolve, reject) {
|
|
24
24
|
const _ = self.Manager.require('lodash');
|
|
25
25
|
|
|
@@ -43,7 +43,7 @@ Module.prototype.main = function () {
|
|
|
43
43
|
eventType: eventType,
|
|
44
44
|
resource: context.resource,
|
|
45
45
|
params: context.params,
|
|
46
|
-
}
|
|
46
|
+
});
|
|
47
47
|
|
|
48
48
|
// Delete event
|
|
49
49
|
if (eventType === 'delete') {
|
|
@@ -62,12 +62,12 @@ Module.prototype.main = function () {
|
|
|
62
62
|
// label: 'regular',
|
|
63
63
|
});
|
|
64
64
|
|
|
65
|
-
assistant.log('Notification subscription deleted:', dataBefore
|
|
65
|
+
assistant.log('Notification subscription deleted:', dataBefore);
|
|
66
66
|
|
|
67
67
|
return resolve(dataBefore);
|
|
68
68
|
})
|
|
69
69
|
.catch(e => {
|
|
70
|
-
assistant.error(e
|
|
70
|
+
assistant.error(e);
|
|
71
71
|
return reject(e);
|
|
72
72
|
})
|
|
73
73
|
|
|
@@ -92,12 +92,12 @@ Module.prototype.main = function () {
|
|
|
92
92
|
// label: 'regular',
|
|
93
93
|
});
|
|
94
94
|
|
|
95
|
-
assistant.log('Notification subscription created:', dataAfter
|
|
95
|
+
assistant.log('Notification subscription created:', dataAfter);
|
|
96
96
|
|
|
97
97
|
return resolve(dataAfter);
|
|
98
98
|
})
|
|
99
99
|
.catch(e => {
|
|
100
|
-
assistant.error(e
|
|
100
|
+
assistant.error(e);
|
|
101
101
|
return reject(e);
|
|
102
102
|
})
|
|
103
103
|
}
|
|
@@ -137,8 +137,7 @@ BackendAssistant.prototype.init = function (ref, options) {
|
|
|
137
137
|
// if (Object.keys(self.request.data).length > 0) {
|
|
138
138
|
// self.log('Request:', self.request.data, {
|
|
139
139
|
// ip: self.request.ip,
|
|
140
|
-
|
|
141
|
-
// }, {environment: 'production'});
|
|
140
|
+
// });
|
|
142
141
|
// }
|
|
143
142
|
|
|
144
143
|
// Constants
|