@plusscommunities/pluss-maintenance-aws 2.1.18-beta.0 → 2.1.18
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/createJob.js +4 -38
- package/package-lock.json +4 -4
- package/package.json +2 -2
package/createJob.js
CHANGED
|
@@ -8,7 +8,6 @@ const validateSiteAccess = require("@plusscommunities/pluss-core-aws/helper/auth
|
|
|
8
8
|
const getUserPreviewFromReq = require("@plusscommunities/pluss-core-aws/helper/getUserPreviewFromReq");
|
|
9
9
|
const validateMasterAuth = require("@plusscommunities/pluss-core-aws/helper/auth/validateMasterAuth");
|
|
10
10
|
const getUserPreview = require("@plusscommunities/pluss-core-aws/helper/getUserPreview");
|
|
11
|
-
const getUser = require("@plusscommunities/pluss-core-aws/db/users/getUser");
|
|
12
11
|
const publishActivity = require("@plusscommunities/pluss-core-aws/db/activity/publishActivity");
|
|
13
12
|
const sendJobEmail = require("./sendJobEmail");
|
|
14
13
|
const logAnalyticsActivity = require("@plusscommunities/pluss-core-aws/db/analytics/logAnalyticsActivity");
|
|
@@ -39,8 +38,6 @@ module.exports.createJob = (event, context, callback) => {
|
|
|
39
38
|
);
|
|
40
39
|
}
|
|
41
40
|
let user = await getUserPreviewFromReq(event);
|
|
42
|
-
const requestingUser = user; // Store reference to the requesting user
|
|
43
|
-
|
|
44
41
|
if (data.userID !== "undefined" && user.id !== data.userID) {
|
|
45
42
|
const canRequest = await validateMasterAuth(
|
|
46
43
|
event,
|
|
@@ -60,43 +57,12 @@ module.exports.createJob = (event, context, callback) => {
|
|
|
60
57
|
user = await getUserPreview(data.userID);
|
|
61
58
|
}
|
|
62
59
|
|
|
63
|
-
// Auto-populate contact details based on permissions
|
|
64
|
-
let phone = data.phone || "";
|
|
65
|
-
let room = data.room || "";
|
|
66
|
-
|
|
67
|
-
try {
|
|
68
|
-
// Determine if we should auto-populate contact details
|
|
69
|
-
const isOwnRequest = user.id === requestingUser.id;
|
|
70
|
-
const hasUserPermission = await validateMasterAuth(
|
|
71
|
-
event,
|
|
72
|
-
"userManagement", // Check for user management permission
|
|
73
|
-
data.location
|
|
74
|
-
);
|
|
75
|
-
const hasUserManagementPermission = isOwnRequest || hasUserPermission;
|
|
76
|
-
|
|
77
|
-
if (hasUserManagementPermission) {
|
|
78
|
-
// Fetch full user details including contact info
|
|
79
|
-
const fullUser = await getUser(user.id);
|
|
80
|
-
|
|
81
|
-
// Auto-populate if not already provided and data exists
|
|
82
|
-
if (!phone && fullUser.phoneNumber) {
|
|
83
|
-
phone = fullUser.phoneNumber;
|
|
84
|
-
}
|
|
85
|
-
if (!room && fullUser.unit) {
|
|
86
|
-
room = fullUser.unit;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
} catch (error) {
|
|
90
|
-
// Log error but continue with original values - graceful fallback
|
|
91
|
-
console.log("Error fetching user contact details:", error);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
60
|
addMaintenanceJob(
|
|
95
61
|
user.id,
|
|
96
62
|
user.displayName,
|
|
97
63
|
user,
|
|
98
|
-
phone,
|
|
99
|
-
room,
|
|
64
|
+
data.phone,
|
|
65
|
+
data.room,
|
|
100
66
|
data.title,
|
|
101
67
|
data.description,
|
|
102
68
|
data.type,
|
|
@@ -110,8 +76,8 @@ module.exports.createJob = (event, context, callback) => {
|
|
|
110
76
|
sendJobEmail({
|
|
111
77
|
userID: user.id,
|
|
112
78
|
userName: user.displayName,
|
|
113
|
-
phone: phone,
|
|
114
|
-
room: room,
|
|
79
|
+
phone: data.phone,
|
|
80
|
+
room: data.room,
|
|
115
81
|
title: data.title,
|
|
116
82
|
description: data.description,
|
|
117
83
|
type: data.type,
|
package/package-lock.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plusscommunities/pluss-maintenance-aws",
|
|
3
|
-
"version": "2.1.18
|
|
3
|
+
"version": "2.1.18",
|
|
4
4
|
"lockfileVersion": 1,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"dependencies": {
|
|
@@ -1468,9 +1468,9 @@
|
|
|
1468
1468
|
}
|
|
1469
1469
|
},
|
|
1470
1470
|
"@plusscommunities/pluss-core-aws": {
|
|
1471
|
-
"version": "2.0.
|
|
1472
|
-
"resolved": "https://registry.npmjs.org/@plusscommunities/pluss-core-aws/-/pluss-core-aws-2.0.
|
|
1473
|
-
"integrity": "sha512-
|
|
1471
|
+
"version": "2.0.23",
|
|
1472
|
+
"resolved": "https://registry.npmjs.org/@plusscommunities/pluss-core-aws/-/pluss-core-aws-2.0.23.tgz",
|
|
1473
|
+
"integrity": "sha512-pqZvjIvhkrMS37oazUmkXsItI4h1OcEQTikCBp4/zkzlsOY4GYJT91MGgROVficIeFKzlEI97PqswD2UiR+8Hg==",
|
|
1474
1474
|
"requires": {
|
|
1475
1475
|
"@aws/dynamodb-auto-marshaller": "^0.7.1",
|
|
1476
1476
|
"amazon-cognito-identity-js": "^2.0.19",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plusscommunities/pluss-maintenance-aws",
|
|
3
|
-
"version": "2.1.18
|
|
3
|
+
"version": "2.1.18",
|
|
4
4
|
"description": "Extension package to enable maintenance on Pluss Communities Platform",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"gc": "node ../../tools/gc ./",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"license": "ISC",
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@aws/dynamodb-auto-marshaller": "^0.7.1",
|
|
27
|
-
"@plusscommunities/pluss-core-aws": "2.0.
|
|
27
|
+
"@plusscommunities/pluss-core-aws": "2.0.23",
|
|
28
28
|
"amazon-cognito-identity-js": "^2.0.19",
|
|
29
29
|
"aws-sdk": "^2.1591.0",
|
|
30
30
|
"axios": "^1.6.8",
|