somod-chat-service 0.7.0 → 0.7.2
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/build/lib/sessionUtil.js +7 -7
- package/build/lib/types.d.ts +1 -1
- package/build/lib/types.js +7 -1
- package/package.json +1 -1
package/build/lib/sessionUtil.js
CHANGED
|
@@ -10,7 +10,7 @@ export var Error = {
|
|
|
10
10
|
invalid: "invalid field: sessionToken"
|
|
11
11
|
};
|
|
12
12
|
export var handleSessionToken = function (userId, threadId, type, action, sessionToken) { return __awaiter(void 0, void 0, void 0, function () {
|
|
13
|
-
var result, isSessionRequiredForThisTypeAction,
|
|
13
|
+
var result, isSessionRequiredForThisTypeAction, oneDay_1, thread_1, sessionRequired, session, now;
|
|
14
14
|
var _a, _b, _c;
|
|
15
15
|
return __generator(this, function (_d) {
|
|
16
16
|
switch (_d.label) {
|
|
@@ -20,29 +20,29 @@ export var handleSessionToken = function (userId, threadId, type, action, sessio
|
|
|
20
20
|
if (!!sessionToken) return [3 /*break*/, 5];
|
|
21
21
|
isSessionRequiredForThisTypeAction = (_a = sessionRequirement[type]) === null || _a === void 0 ? void 0 : _a[action];
|
|
22
22
|
if (!(isSessionRequiredForThisTypeAction !== undefined)) return [3 /*break*/, 4];
|
|
23
|
-
|
|
23
|
+
oneDay_1 = Date.now() + 1000 * 60 * 60 * 24;
|
|
24
24
|
if (!(isSessionRequiredForThisTypeAction === "always")) return [3 /*break*/, 1];
|
|
25
25
|
result.error = Error.required;
|
|
26
|
-
result.sessionRequiredTill =
|
|
26
|
+
result.sessionRequiredTill = oneDay_1;
|
|
27
27
|
return [3 /*break*/, 4];
|
|
28
28
|
case 1:
|
|
29
29
|
if (!(isSessionRequiredForThisTypeAction === "thread")) return [3 /*break*/, 4];
|
|
30
30
|
if (!(sessionForce == "true")) return [3 /*break*/, 2];
|
|
31
31
|
result.error = Error.required;
|
|
32
|
-
result.sessionRequiredTill =
|
|
32
|
+
result.sessionRequiredTill = oneDay_1;
|
|
33
33
|
return [3 /*break*/, 4];
|
|
34
34
|
case 2: return [4 /*yield*/, threadCache.get(threadId, -1)];
|
|
35
35
|
case 3:
|
|
36
36
|
thread_1 = _d.sent();
|
|
37
37
|
sessionRequired = Object.fromEntries((_c = (_b = thread_1 === null || thread_1 === void 0 ? void 0 : thread_1.sessionRequired) === null || _b === void 0 ? void 0 : _b.map(function (userId, index) {
|
|
38
|
-
var _a;
|
|
38
|
+
var _a, _b;
|
|
39
39
|
return [
|
|
40
40
|
userId,
|
|
41
|
-
(_a = thread_1 === null || thread_1 === void 0 ? void 0 : thread_1.sessionRequiredTill) === null || _a === void 0 ? void 0 : _a[index]
|
|
41
|
+
(_b = (_a = thread_1 === null || thread_1 === void 0 ? void 0 : thread_1.sessionRequiredTill) === null || _a === void 0 ? void 0 : _a[index]) !== null && _b !== void 0 ? _b : oneDay_1
|
|
42
42
|
];
|
|
43
43
|
})) !== null && _c !== void 0 ? _c : []);
|
|
44
44
|
if (sessionRequired[userId] !== undefined &&
|
|
45
|
-
|
|
45
|
+
Date.now() < sessionRequired[userId]) {
|
|
46
46
|
result.error = Error.required;
|
|
47
47
|
result.sessionRequiredTill = sessionRequired[userId];
|
|
48
48
|
}
|
package/build/lib/types.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export type Thread = {
|
|
|
11
11
|
export type MessageInput = {
|
|
12
12
|
threadId: string;
|
|
13
13
|
type: "text" | "image" | "control" | "call" | "pooja";
|
|
14
|
-
action: "new" | "edit" | "delete" | "sessionStart" | "sessionExtend" | "sessionEnd" | "initiated" | "declined";
|
|
14
|
+
action: "new" | "edit" | "delete" | "sessionStart" | "sessionExtend" | "sessionEnd" | "sessionRequirementChange" | "initiated" | "declined";
|
|
15
15
|
message: string;
|
|
16
16
|
sessionToken?: string;
|
|
17
17
|
};
|
package/build/lib/types.js
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
export var typeToAllowedActionsMap = {
|
|
2
2
|
text: ["new", "edit"],
|
|
3
3
|
image: ["new", "edit"],
|
|
4
|
-
control: [
|
|
4
|
+
control: [
|
|
5
|
+
"delete",
|
|
6
|
+
"sessionStart",
|
|
7
|
+
"sessionExtend",
|
|
8
|
+
"sessionEnd",
|
|
9
|
+
"sessionRequirementChange"
|
|
10
|
+
],
|
|
5
11
|
call: ["initiated", "declined"],
|
|
6
12
|
pooja: ["new", "edit"]
|
|
7
13
|
};
|
package/package.json
CHANGED