@burgan-tech/morph-touch-runtime 0.0.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/LICENSE +21 -0
- package/burgan-tech-morph-touch-runtime-0.0.2.tgz +0 -0
- package/package.json +21 -0
- package/touch/Extensions/.gitkeep +0 -0
- package/touch/Functions/.gitkeep +0 -0
- package/touch/Functions/check-livekit-room-access.1.0.0.json +28 -0
- package/touch/Functions/check-livekit-room-access.http +44 -0
- package/touch/Functions/get-absence-entry.1.0.0.json +28 -0
- package/touch/Functions/get-advisor-stats.1.0.0.json +27 -0
- package/touch/Functions/get-available-slots.1.0.0.json +30 -0
- package/touch/Functions/get-available-slots.http +29 -0
- package/touch/Functions/get-chat-rooms.1.0.0.json +28 -0
- package/touch/Functions/get-chat-rooms.http +62 -0
- package/touch/Functions/get-customer-info.1.0.0.json +27 -0
- package/touch/Functions/get-matrix-sync.1.0.0.json +28 -0
- package/touch/Functions/get-rezervations.1.0.0.json +26 -0
- package/touch/Functions/get-rezervations.http +59 -0
- package/touch/Functions/get-room-messages.1.0.0.json +29 -0
- package/touch/Functions/get-room-messages.http +45 -0
- package/touch/Functions/rezervation-transfer.http +118 -0
- package/touch/Functions/send-room-message.1.0.0.json +29 -0
- package/touch/Functions/src/CheckLivekitRoomAccessMapping.csx +238 -0
- package/touch/Functions/src/GetAbsenceEntryMapping.csx +225 -0
- package/touch/Functions/src/GetAdvisorStatsMapping.csx +190 -0
- package/touch/Functions/src/GetAvailableSlotsMapping.csx +468 -0
- package/touch/Functions/src/GetChatRoomsMapping.csx +202 -0
- package/touch/Functions/src/GetCustomerInfoMapping.csx +140 -0
- package/touch/Functions/src/GetMatrixSyncMapping.csx +197 -0
- package/touch/Functions/src/GetRezervationsMapping.csx +162 -0
- package/touch/Functions/src/GetRoomMessagesMapping.csx +165 -0
- package/touch/Functions/src/SendCancelNotificationMapping.csx +63 -0
- package/touch/Functions/src/SendRoomMessageMapping.csx +131 -0
- package/touch/Schemas/.gitkeep +0 -0
- package/touch/Schemas/absence-entry.1.0.0.json +232 -0
- package/touch/Schemas/advisor-chat-rooms.1.0.0.json +62 -0
- package/touch/Schemas/chat-room.1.0.0.json +110 -0
- package/touch/Schemas/notification-sender.1.0.0.json +159 -0
- package/touch/Schemas/portfolio-manager.1.0.0.json +63 -0
- package/touch/Schemas/rezervation.1.0.0.json +102 -0
- package/touch/Tasks/.gitkeep +0 -0
- package/touch/Tasks/cancel-absence-entry-for-rezervation.1.0.0.json +21 -0
- package/touch/Tasks/check-already-completed-chat-room.1.0.0.json +24 -0
- package/touch/Tasks/check-duplicate-portfolio-manager.1.0.0.json +23 -0
- package/touch/Tasks/check-duplicate-rezervation.1.0.0.json +23 -0
- package/touch/Tasks/check-existing-permanent-chat-room.1.0.0.json +21 -0
- package/touch/Tasks/check-randevu-time.1.0.0.json +17 -0
- package/touch/Tasks/create-permanent-chat-room.1.0.0.json +28 -0
- package/touch/Tasks/determine-transfer-type.1.0.0.json +16 -0
- package/touch/Tasks/enrich-rezervations-for-transfer.1.0.0.json +23 -0
- package/touch/Tasks/execute-permanent-chatroom-update.1.0.0.json +21 -0
- package/touch/Tasks/execute-rez-chatroom-transfer.1.0.0.json +21 -0
- package/touch/Tasks/execute-rezervation-transfer.1.0.0.json +19 -0
- package/touch/Tasks/fetch-absence-entries-for-transfer.1.0.0.json +23 -0
- package/touch/Tasks/fetch-advisors-for-transfer.1.0.0.json +23 -0
- package/touch/Tasks/fetch-permanent-chatrooms-for-transfer.1.0.0.json +23 -0
- package/touch/Tasks/fetch-rez-chatrooms-for-transfer.1.0.0.json +23 -0
- package/touch/Tasks/fetch-rezervations-for-transfer.1.0.0.json +22 -0
- package/touch/Tasks/get-absence-entry-task.1.0.0.json +23 -0
- package/touch/Tasks/get-available-slots-http.1.0.0.json +27 -0
- package/touch/Tasks/get-available-slots.1.0.0.json +24 -0
- package/touch/Tasks/get-chat-room-data-for-rezervation.1.0.0.json +23 -0
- package/touch/Tasks/get-chat-token.1.0.0.json +27 -0
- package/touch/Tasks/get-matrix-room-messages.1.0.0.json +25 -0
- package/touch/Tasks/get-matrix-sync.1.0.0.json +25 -0
- package/touch/Tasks/get-rezervation-data-task.1.0.0.json +22 -0
- package/touch/Tasks/get-rezervation-state-task.1.0.0.json +22 -0
- package/touch/Tasks/get-rezervations-task.1.0.0.json +21 -0
- package/touch/Tasks/get-user-info-for-rezervation.1.0.0.json +24 -0
- package/touch/Tasks/get-video-call-url.1.0.0.json +17 -0
- package/touch/Tasks/invite-user-to-rezervation-room.1.0.0.json +27 -0
- package/touch/Tasks/join-chat-room-for-rezervation.1.0.0.json +28 -0
- package/touch/Tasks/join-matrix-room.1.0.0.json +27 -0
- package/touch/Tasks/join-user-to-room.1.0.0.json +27 -0
- package/touch/Tasks/merge-invited-user.1.0.0.json +17 -0
- package/touch/Tasks/merge-rezervation-update.1.0.0.json +16 -0
- package/touch/Tasks/merge-target-advisor-for-transfer.1.0.0.json +17 -0
- package/touch/Tasks/merge-update-body-for-randevu-update.1.0.0.json +16 -0
- package/touch/Tasks/merge-video-call-urls.1.0.0.json +17 -0
- package/touch/Tasks/query-chat-room-instances.1.0.0.json +23 -0
- package/touch/Tasks/remove-member-from-room.1.0.0.json +28 -0
- package/touch/Tasks/send-matrix-room-message.1.0.0.json +26 -0
- package/touch/Tasks/send-push-notification.1.0.0.json +26 -0
- package/touch/Tasks/send-sms-notification.1.0.0.json +26 -0
- package/touch/Tasks/set-chat-room-status-active.1.0.0.json +16 -0
- package/touch/Tasks/set-chat-room-status-deactive.1.0.0.json +16 -0
- package/touch/Tasks/set-previous-advisor.1.0.0.json +16 -0
- package/touch/Tasks/set-user-from-headers-for-rezervation.1.0.0.json +17 -0
- package/touch/Tasks/start-absence-entry-for-rezervation.1.0.0.json +21 -0
- package/touch/Tasks/start-chat-room-for-rezervation.1.0.0.json +20 -0
- package/touch/Tasks/start-notification-sender.1.0.0.json +20 -0
- package/touch/Tasks/start-permanent-chat-room.1.0.0.json +21 -0
- package/touch/Tasks/start-transfer-from-absence-entry.1.0.0.json +19 -0
- package/touch/Tasks/start-video-call.1.0.0.json +22 -0
- package/touch/Tasks/trigger-chat-room-deactivate.1.0.0.json +21 -0
- package/touch/Tasks/trigger-chat-room-transfer.1.0.0.json +21 -0
- package/touch/Tasks/trigger-chat-room-update.1.0.0.json +20 -0
- package/touch/Tasks/trigger-rezervation-add-invited-participant.1.0.0.json +20 -0
- package/touch/Tasks/trigger-rezervation-apply-update.1.0.0.json +20 -0
- package/touch/Tasks/trigger-rezervation-to-in-meet.1.0.0.json +20 -0
- package/touch/Tasks/trigger-rezervation-video-call-update.1.0.0.json +21 -0
- package/touch/Tasks/validate-date-for-rezervation.1.0.0.json +18 -0
- package/touch/Tasks/validate-slot-for-rezervation.1.0.0.json +24 -0
- package/touch/Tasks/validate-transfer-availability.1.0.0.json +23 -0
- package/touch/Views/.gitkeep +0 -0
- package/touch/Workflows/.gitkeep +0 -0
- package/touch/Workflows/absence-entry.http +458 -0
- package/touch/Workflows/absence-entry.json +179 -0
- package/touch/Workflows/add-participant-to-rezervation.http +47 -0
- package/touch/Workflows/add-participant-to-rezervation.json +340 -0
- package/touch/Workflows/chat-room.http +207 -0
- package/touch/Workflows/chat-room.json +452 -0
- package/touch/Workflows/investment-advisor.json +367 -0
- package/touch/Workflows/notification-sender.http +299 -0
- package/touch/Workflows/notification-sender.json +262 -0
- package/touch/Workflows/portfolio-manager.json +367 -0
- package/touch/Workflows/randevu-update.http +87 -0
- package/touch/Workflows/rezervation-start.json +467 -0
- package/touch/Workflows/rezervation-transfer.json +512 -0
- package/touch/Workflows/rezervation-update.http +87 -0
- package/touch/Workflows/rezervation-update.json +485 -0
- package/touch/Workflows/rezervation.http +214 -0
- package/touch/Workflows/rezervation.json +726 -0
- package/touch/Workflows/src/AllChatRoomsSuccessRule.csx +65 -0
- package/touch/Workflows/src/AlwaysTrueRule.csx +13 -0
- package/touch/Workflows/src/AnyChatRoomFailedRule.csx +64 -0
- package/touch/Workflows/src/AutoProcessRule.csx +38 -0
- package/touch/Workflows/src/BuildRezChatRoomPlanMapping.csx +160 -0
- package/touch/Workflows/src/CanStartRezervationTimerMapping.csx +48 -0
- package/touch/Workflows/src/CanStartTransferMapping.csx +14 -0
- package/touch/Workflows/src/CancelAbsenceEntryForRezervationMapping.csx +48 -0
- package/touch/Workflows/src/CancelAbsenceForRandevuUpdateMapping.csx +62 -0
- package/touch/Workflows/src/ChatRoomCreatedFailedRule.csx +54 -0
- package/touch/Workflows/src/ChatRoomCreatedSuccessRule.csx +54 -0
- package/touch/Workflows/src/ChatRoomRemoveMapping.csx +104 -0
- package/touch/Workflows/src/ChatRoomTransferInviteMapping.csx +109 -0
- package/touch/Workflows/src/ChatRoomTransferRemoveMapping.csx +71 -0
- package/touch/Workflows/src/ChatRoomUpdateMapping.csx +107 -0
- package/touch/Workflows/src/CheckAlreadyCompletedChatRoomMapping.csx +100 -0
- package/touch/Workflows/src/CheckDuplicatePortfolioManagerMapping.csx +119 -0
- package/touch/Workflows/src/CheckDuplicateRezervationMapping.csx +150 -0
- package/touch/Workflows/src/CheckExistingPermanentChatRoomMapping.csx +169 -0
- package/touch/Workflows/src/CheckRandevuTimeMapping.csx +67 -0
- package/touch/Workflows/src/CheckRezervationStateActiveOrInMeetRule.csx +14 -0
- package/touch/Workflows/src/CreateAbsenceEntryForRezervationMapping.csx +111 -0
- package/touch/Workflows/src/CreateAbsenceForRandevuUpdateMapping.csx +108 -0
- package/touch/Workflows/src/CreateChatRoomForRezervationMapping.csx +122 -0
- package/touch/Workflows/src/CreatePermanentChatRoomMapping.csx +140 -0
- package/touch/Workflows/src/CustomerControlToEndRule.csx +14 -0
- package/touch/Workflows/src/DetermineTransferTypeMapping.csx +92 -0
- package/touch/Workflows/src/EnrichRezervationsForTransferMapping.csx +495 -0
- package/touch/Workflows/src/ExecutePermanentChatRoomUpdateMapping.csx +124 -0
- package/touch/Workflows/src/ExecuteRezChatRoomTransferMapping.csx +95 -0
- package/touch/Workflows/src/ExecuteTransferMapping.csx +152 -0
- package/touch/Workflows/src/FetchAbsenceEntriesForTransferMapping.csx +116 -0
- package/touch/Workflows/src/FetchAdvisorsForTransferMapping.csx +145 -0
- package/touch/Workflows/src/FetchPermanentChatRoomsMapping.csx +128 -0
- package/touch/Workflows/src/FetchRezervationsForTransferMapping.csx +124 -0
- package/touch/Workflows/src/GetChatRoomDataForRezervationMapping.csx +100 -0
- package/touch/Workflows/src/GetChatTokenMapping.csx +85 -0
- package/touch/Workflows/src/GetRezervationDataForAddParticipantMapping.csx +105 -0
- package/touch/Workflows/src/GetRezervationDataForRandevuUpdateMapping.csx +110 -0
- package/touch/Workflows/src/GetRezervationDataMapping.csx +111 -0
- package/touch/Workflows/src/GetRezervationStateForRandevuUpdateMapping.csx +80 -0
- package/touch/Workflows/src/GetRezervationStateMapping.csx +92 -0
- package/touch/Workflows/src/GetUserInfoForRezervationMapping.csx +63 -0
- package/touch/Workflows/src/GetVideoCallUrlMapping.csx +62 -0
- package/touch/Workflows/src/HasChangedAdvisorRule.csx +28 -0
- package/touch/Workflows/src/HasChatIntegrationRule.csx +41 -0
- package/touch/Workflows/src/HasExistingPermanentRoomRule.csx +28 -0
- package/touch/Workflows/src/InviteAdvisorForRandevuUpdateMapping.csx +86 -0
- package/touch/Workflows/src/InviteNewAdvisorToRezervationRoomMapping.csx +78 -0
- package/touch/Workflows/src/InviteNewParticipantToRandevuRoomMapping.csx +88 -0
- package/touch/Workflows/src/InvitedUserMergeMapping.csx +77 -0
- package/touch/Workflows/src/InvitedUserNotAllowedRule.csx +71 -0
- package/touch/Workflows/src/InvitedUserNotInMeetRule.csx +19 -0
- package/touch/Workflows/src/IsNotfSentRule.csx +36 -0
- package/touch/Workflows/src/JoinChatRoomForAddParticipantMapping.csx +118 -0
- package/touch/Workflows/src/JoinChatRoomForRandevuStartMapping.csx +119 -0
- package/touch/Workflows/src/JoinChatRoomForRezervationMapping.csx +118 -0
- package/touch/Workflows/src/JoinMatrixRoomMapping.csx +100 -0
- package/touch/Workflows/src/JoinUserToRoomMapping.csx +118 -0
- package/touch/Workflows/src/LoginForAddParticipantChatMapping.csx +102 -0
- package/touch/Workflows/src/LoginForRandevuStartChatMapping.csx +96 -0
- package/touch/Workflows/src/MergeRezervationUpdateMapping.csx +82 -0
- package/touch/Workflows/src/MergeTargetAdvisorForTransferMapping.csx +79 -0
- package/touch/Workflows/src/MergeUpdateBodyForRandevuUpdateMapping.csx +91 -0
- package/touch/Workflows/src/NoExistingPermanentRoomRule.csx +23 -0
- package/touch/Workflows/src/NotificationCompleteAlwaysRule.csx +14 -0
- package/touch/Workflows/src/NotificationCompleteFromPendingRule.csx +41 -0
- package/touch/Workflows/src/NotificationCompleteFromSmsRule.csx +36 -0
- package/touch/Workflows/src/NotificationPushFromPendingRule.csx +42 -0
- package/touch/Workflows/src/NotificationPushFromSmsRule.csx +36 -0
- package/touch/Workflows/src/NotificationSmsPendingRule.csx +32 -0
- package/touch/Workflows/src/PermanentDoneRule.csx +44 -0
- package/touch/Workflows/src/PermanentProcessNextRule.csx +44 -0
- package/touch/Workflows/src/RezChatRoomProcessNextRule.csx +44 -0
- package/touch/Workflows/src/RezChatRoomsDoneRule.csx +44 -0
- package/touch/Workflows/src/SendPushNotificationMapping.csx +146 -0
- package/touch/Workflows/src/SendSmsNotificationMapping.csx +138 -0
- package/touch/Workflows/src/SetChatRoomStatusActiveMapping.csx +22 -0
- package/touch/Workflows/src/SetChatRoomStatusDeactiveMapping.csx +22 -0
- package/touch/Workflows/src/SetPreviousAdvisorMapping.csx +28 -0
- package/touch/Workflows/src/SetUserFromHeadersForRezervationMapping.csx +24 -0
- package/touch/Workflows/src/SlotAvailableRule.csx +33 -0
- package/touch/Workflows/src/SlotUnavailableRule.csx +33 -0
- package/touch/Workflows/src/StartChatRoomForRezervationMapping.csx +100 -0
- package/touch/Workflows/src/StartGetChatTokenForRezervationMapping.csx +71 -0
- package/touch/Workflows/src/StartNotificationForAdvisorMapping.csx +117 -0
- package/touch/Workflows/src/StartNotificationForRezervationFromUserInfoMapping.csx +128 -0
- package/touch/Workflows/src/StartNotificationForUserMapping.csx +117 -0
- package/touch/Workflows/src/StartPermanentChatRoomMapping.csx +92 -0
- package/touch/Workflows/src/StartTransferFromAbsenceEntryMapping.csx +94 -0
- package/touch/Workflows/src/StartVideoCallCustomerSubFlowMapping.csx +37 -0
- package/touch/Workflows/src/StartVideoCallForInvitedParticipantMapping.csx +54 -0
- package/touch/Workflows/src/StartVideoCallForRandevuStartMapping.csx +70 -0
- package/touch/Workflows/src/StartVideoCallStaffSubFlowMapping.csx +37 -0
- package/touch/Workflows/src/StateActiveForUpdateRule.csx +14 -0
- package/touch/Workflows/src/StateActiveRule.csx +14 -0
- package/touch/Workflows/src/StateInMeetRule.csx +14 -0
- package/touch/Workflows/src/StateNotActiveForUpdateRule.csx +14 -0
- package/touch/Workflows/src/StateNotActiveOrInMeetRule.csx +14 -0
- package/touch/Workflows/src/StatusCustomerEnterRule.csx +25 -0
- package/touch/Workflows/src/StatusStaffEnterRule.csx +25 -0
- package/touch/Workflows/src/SyncWorkingHoursRule.csx +46 -0
- package/touch/Workflows/src/TokenSuccessRule.csx +24 -0
- package/touch/Workflows/src/TransferAllDoneRule.csx +50 -0
- package/touch/Workflows/src/TransferHasInvalidRule.csx +34 -0
- package/touch/Workflows/src/TransferProcessNextRule.csx +50 -0
- package/touch/Workflows/src/TriggerChatRoomDeactivateMapping.csx +77 -0
- package/touch/Workflows/src/TriggerChatRoomTransferMapping.csx +93 -0
- package/touch/Workflows/src/TriggerChatRoomUpdateMapping.csx +99 -0
- package/touch/Workflows/src/TriggerRezervationAddInvitedParticipantMapping.csx +77 -0
- package/touch/Workflows/src/TriggerRezervationApplyUpdateMapping.csx +66 -0
- package/touch/Workflows/src/TriggerRezervationToInMeetMapping.csx +69 -0
- package/touch/Workflows/src/TriggerRezervationVideoCallUpdateMapping.csx +67 -0
- package/touch/Workflows/src/ValidateDateForRezervationMapping.csx +60 -0
- package/touch/Workflows/src/ValidateSlotForRandevuUpdateMapping.csx +211 -0
- package/touch/Workflows/src/ValidateSlotForRezervationMapping.csx +246 -0
- package/touch/Workflows/src/ValidateTransferMapping.csx +243 -0
- package/touch/Workflows/src/VideoCallUrlUpdateMergeMapping.csx +141 -0
- package/touch/Workflows/start-chat.json +217 -0
- package/touch/Workflows/start-video-call.http +93 -0
- package/touch/Workflows/start-video-call.json +206 -0
- package/vnext.config.json +58 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using System.Threading.Tasks;
|
|
4
|
+
using BBT.Workflow.Scripting;
|
|
5
|
+
using BBT.Workflow.Definitions;
|
|
6
|
+
|
|
7
|
+
/// <summary>
|
|
8
|
+
/// Generic mapping for join-user-to-room HttpTask (Type 6).
|
|
9
|
+
/// Auto-joins the user specified in instanceData.pendingJoinUserId to the room.
|
|
10
|
+
/// X-Matrix-User is set to the joining user so APISIX authenticates as that user.
|
|
11
|
+
/// Used after invite in: room creation (onEntry), update (add member), transfer transitions.
|
|
12
|
+
/// </summary>
|
|
13
|
+
public class JoinUserToRoomMapping : ScriptBase, IMapping
|
|
14
|
+
{
|
|
15
|
+
public async Task<ScriptResponse> InputHandler(WorkflowTask task, ScriptContext context)
|
|
16
|
+
{
|
|
17
|
+
var httpTask = task as HttpTask;
|
|
18
|
+
if (httpTask == null)
|
|
19
|
+
throw new InvalidOperationException("Task must be an HttpTask");
|
|
20
|
+
|
|
21
|
+
var data = context.Instance?.Data;
|
|
22
|
+
|
|
23
|
+
string roomId = null;
|
|
24
|
+
if (HasProperty(data, "chatIntegration") && data.chatIntegration != null)
|
|
25
|
+
roomId = GetString(data.chatIntegration, "roomId");
|
|
26
|
+
|
|
27
|
+
var pendingJoinUserId = GetString(data, "pendingJoinUserId");
|
|
28
|
+
if (string.IsNullOrWhiteSpace(pendingJoinUserId))
|
|
29
|
+
pendingJoinUserId = GetString(data, "newAdvisorId");
|
|
30
|
+
if (string.IsNullOrWhiteSpace(pendingJoinUserId))
|
|
31
|
+
pendingJoinUserId = GetString(data, "advisorId");
|
|
32
|
+
|
|
33
|
+
if (string.IsNullOrWhiteSpace(roomId) || string.IsNullOrWhiteSpace(pendingJoinUserId))
|
|
34
|
+
return new ScriptResponse();
|
|
35
|
+
|
|
36
|
+
var matrixBaseUrl = await GetSecretAsync("vnext-secret", "workflow-secret", "MatrixBaseUrl");
|
|
37
|
+
if (string.IsNullOrWhiteSpace(matrixBaseUrl))
|
|
38
|
+
throw new InvalidOperationException("MatrixBaseUrl secret is required");
|
|
39
|
+
var fullUrl = matrixBaseUrl.TrimEnd('/') + "/_matrix/client/v3/join/" + Uri.EscapeDataString(roomId);
|
|
40
|
+
httpTask.SetUrl(fullUrl);
|
|
41
|
+
|
|
42
|
+
var xMatrixUser = pendingJoinUserId.Trim();
|
|
43
|
+
if (xMatrixUser.StartsWith("@"))
|
|
44
|
+
{
|
|
45
|
+
var colonIdx = xMatrixUser.IndexOf(':');
|
|
46
|
+
xMatrixUser = colonIdx > 0 ? xMatrixUser.Substring(1, colonIdx - 1) : xMatrixUser.Substring(1);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
var headers = new Dictionary<string, string>
|
|
50
|
+
{
|
|
51
|
+
["Content-Type"] = "application/json",
|
|
52
|
+
["Accept"] = "application/json",
|
|
53
|
+
["X-Matrix-User"] = xMatrixUser
|
|
54
|
+
};
|
|
55
|
+
httpTask.SetHeaders(headers);
|
|
56
|
+
|
|
57
|
+
httpTask.SetBody(new { });
|
|
58
|
+
|
|
59
|
+
return new ScriptResponse();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
public Task<ScriptResponse> OutputHandler(ScriptContext context)
|
|
63
|
+
{
|
|
64
|
+
var result = new ScriptResponse();
|
|
65
|
+
var data = context.Instance?.Data;
|
|
66
|
+
|
|
67
|
+
var user = GetString(data, "user");
|
|
68
|
+
var advisorType = GetString(data, "advisorType");
|
|
69
|
+
var advisorId = GetString(data, "advisorId");
|
|
70
|
+
|
|
71
|
+
string roomId = null;
|
|
72
|
+
if (HasProperty(data, "chatIntegration") && data.chatIntegration != null)
|
|
73
|
+
roomId = GetString(data.chatIntegration, "roomId");
|
|
74
|
+
|
|
75
|
+
var members = new List<object>();
|
|
76
|
+
if (HasProperty(data, "members") && data.members != null)
|
|
77
|
+
{
|
|
78
|
+
foreach (var m in data.members)
|
|
79
|
+
{
|
|
80
|
+
var mid = GetString(m, "memberId") ?? GetString(m, "advisorId");
|
|
81
|
+
members.Add(new { memberId = mid, role = GetString(m, "role") });
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
var roomType = GetString(data, "roomType");
|
|
86
|
+
var startDateTime = GetString(data, "startDateTime");
|
|
87
|
+
var endDateTime = GetString(data, "endDateTime");
|
|
88
|
+
|
|
89
|
+
result.Data = new
|
|
90
|
+
{
|
|
91
|
+
user,
|
|
92
|
+
advisorType,
|
|
93
|
+
advisorId,
|
|
94
|
+
chatIntegration = new { roomId },
|
|
95
|
+
roomType,
|
|
96
|
+
startDateTime,
|
|
97
|
+
endDateTime,
|
|
98
|
+
members = members
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
return Task.FromResult(result);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
private string GetString(dynamic obj, string name)
|
|
105
|
+
{
|
|
106
|
+
if (obj == null) return null;
|
|
107
|
+
try
|
|
108
|
+
{
|
|
109
|
+
if (HasProperty(obj, name))
|
|
110
|
+
{
|
|
111
|
+
var v = GetPropertyValue(obj, name);
|
|
112
|
+
return v?.ToString();
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
catch { }
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Threading.Tasks;
|
|
3
|
+
using BBT.Workflow.Scripting;
|
|
4
|
+
using BBT.Workflow.Definitions;
|
|
5
|
+
|
|
6
|
+
/// <summary>
|
|
7
|
+
/// Mapping for login-for-rezervation-chat when used in add-participant-to-rezervation flow.
|
|
8
|
+
/// Logs in as newUserId. Output merges session with existing chatIntegration (preserves roomId).
|
|
9
|
+
/// </summary>
|
|
10
|
+
public class LoginForAddParticipantChatMapping : ScriptBase, IMapping
|
|
11
|
+
{
|
|
12
|
+
public Task<ScriptResponse> InputHandler(WorkflowTask task, ScriptContext context)
|
|
13
|
+
{
|
|
14
|
+
var httpTask = task as HttpTask;
|
|
15
|
+
if (httpTask == null)
|
|
16
|
+
throw new InvalidOperationException("Task must be an HttpTask");
|
|
17
|
+
|
|
18
|
+
var data = context.Instance?.Data;
|
|
19
|
+
var newUserId = GetString(data, "newUserId");
|
|
20
|
+
if (string.IsNullOrWhiteSpace(newUserId))
|
|
21
|
+
return Task.FromResult(new ScriptResponse());
|
|
22
|
+
|
|
23
|
+
httpTask.SetBody(new { Username = newUserId.Trim() });
|
|
24
|
+
return Task.FromResult(new ScriptResponse());
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
public Task<ScriptResponse> OutputHandler(ScriptContext context)
|
|
28
|
+
{
|
|
29
|
+
var result = new ScriptResponse();
|
|
30
|
+
var response = context.Body;
|
|
31
|
+
var instanceData = context.Instance?.Data;
|
|
32
|
+
var existingChat = GetChatIntegration(instanceData);
|
|
33
|
+
string existingRoomId = GetString(existingChat, "roomId");
|
|
34
|
+
|
|
35
|
+
if (response?.isSuccess == true)
|
|
36
|
+
{
|
|
37
|
+
dynamic data = response.data;
|
|
38
|
+
string sessionId = GetString(data, "sessionId");
|
|
39
|
+
string userId = GetString(data, "userId");
|
|
40
|
+
string username = GetString(data, "username");
|
|
41
|
+
|
|
42
|
+
result.Data = new
|
|
43
|
+
{
|
|
44
|
+
chatIntegration = new
|
|
45
|
+
{
|
|
46
|
+
sessionId,
|
|
47
|
+
userId,
|
|
48
|
+
username,
|
|
49
|
+
roomId = existingRoomId,
|
|
50
|
+
error = (string)null,
|
|
51
|
+
errorCode = (string)null
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
else
|
|
56
|
+
{
|
|
57
|
+
string errorMessage = response?.errorMessage?.ToString() ?? "Chat login failed";
|
|
58
|
+
string statusCode = response?.statusCode != null ? response.statusCode.ToString() : null;
|
|
59
|
+
result.Data = new
|
|
60
|
+
{
|
|
61
|
+
chatIntegration = new
|
|
62
|
+
{
|
|
63
|
+
sessionId = (string)null,
|
|
64
|
+
userId = (string)null,
|
|
65
|
+
username = (string)null,
|
|
66
|
+
roomId = existingRoomId,
|
|
67
|
+
error = errorMessage,
|
|
68
|
+
errorCode = statusCode
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return Task.FromResult(result);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
private string GetString(dynamic obj, string name)
|
|
77
|
+
{
|
|
78
|
+
if (obj == null) return null;
|
|
79
|
+
try
|
|
80
|
+
{
|
|
81
|
+
if (HasProperty(obj, name))
|
|
82
|
+
{
|
|
83
|
+
var v = GetPropertyValue(obj, name);
|
|
84
|
+
return v?.ToString();
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
catch { }
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
private dynamic GetChatIntegration(dynamic data)
|
|
92
|
+
{
|
|
93
|
+
if (data == null) return null;
|
|
94
|
+
try
|
|
95
|
+
{
|
|
96
|
+
if (HasProperty(data, "chatIntegration"))
|
|
97
|
+
return GetPropertyValue(data, "chatIntegration");
|
|
98
|
+
}
|
|
99
|
+
catch { }
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Threading.Tasks;
|
|
3
|
+
using BBT.Workflow.Scripting;
|
|
4
|
+
using BBT.Workflow.Definitions;
|
|
5
|
+
|
|
6
|
+
/// <summary>
|
|
7
|
+
/// Mapping for login-for-rezervation-chat when used in rezervation-start flow.
|
|
8
|
+
/// Uses participantType to determine login user: advisor, customer (user), or invited (invitedUserId).
|
|
9
|
+
/// </summary>
|
|
10
|
+
public class LoginForRandevuStartChatMapping : ScriptBase, IMapping
|
|
11
|
+
{
|
|
12
|
+
public Task<ScriptResponse> InputHandler(WorkflowTask task, ScriptContext context)
|
|
13
|
+
{
|
|
14
|
+
var httpTask = task as HttpTask;
|
|
15
|
+
if (httpTask == null)
|
|
16
|
+
throw new InvalidOperationException("Task must be an HttpTask");
|
|
17
|
+
|
|
18
|
+
var data = context.Instance?.Data;
|
|
19
|
+
var participantType = GetString(data, "participantType");
|
|
20
|
+
var user = GetString(data, "user");
|
|
21
|
+
var advisor = GetString(data, "advisor");
|
|
22
|
+
|
|
23
|
+
var loginUsername = participantType == "advisor" ? advisor
|
|
24
|
+
: participantType == "invited" ? GetString(data, "invitedUserId")
|
|
25
|
+
: user;
|
|
26
|
+
if (string.IsNullOrWhiteSpace(loginUsername))
|
|
27
|
+
throw new InvalidOperationException("Cannot determine login user: participantType, user, advisor, or invitedUserId missing");
|
|
28
|
+
|
|
29
|
+
httpTask.SetBody(new { Username = loginUsername });
|
|
30
|
+
return Task.FromResult(new ScriptResponse());
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
public Task<ScriptResponse> OutputHandler(ScriptContext context)
|
|
34
|
+
{
|
|
35
|
+
var result = new ScriptResponse();
|
|
36
|
+
var response = context.Body;
|
|
37
|
+
|
|
38
|
+
if (response?.isSuccess == true)
|
|
39
|
+
{
|
|
40
|
+
dynamic data = response.data;
|
|
41
|
+
string sessionId = GetString(data, "sessionId");
|
|
42
|
+
string userId = GetString(data, "userId");
|
|
43
|
+
string username = GetString(data, "username");
|
|
44
|
+
|
|
45
|
+
var instanceData = context.Instance?.Data;
|
|
46
|
+
// var existingChat = instanceData?.chatIntegration;
|
|
47
|
+
// string roomId = GetString(existingChat, "roomId");
|
|
48
|
+
|
|
49
|
+
result.Data = new
|
|
50
|
+
{
|
|
51
|
+
chatIntegration = new
|
|
52
|
+
{
|
|
53
|
+
sessionId,
|
|
54
|
+
userId,
|
|
55
|
+
username,
|
|
56
|
+
error = (string)null,
|
|
57
|
+
errorCode = (string)null
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
else
|
|
62
|
+
{
|
|
63
|
+
string errorMessage = response?.errorMessage?.ToString() ?? "Chat login failed";
|
|
64
|
+
string statusCode = response?.statusCode != null ? response.statusCode.ToString() : null;
|
|
65
|
+
result.Data = new
|
|
66
|
+
{
|
|
67
|
+
chatIntegration = new
|
|
68
|
+
{
|
|
69
|
+
sessionId = (string)null,
|
|
70
|
+
userId = (string)null,
|
|
71
|
+
username = (string)null,
|
|
72
|
+
roomId = (string)null,
|
|
73
|
+
error = errorMessage,
|
|
74
|
+
errorCode = statusCode
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return Task.FromResult(result);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
private string GetString(dynamic obj, string name)
|
|
83
|
+
{
|
|
84
|
+
if (obj == null) return null;
|
|
85
|
+
try
|
|
86
|
+
{
|
|
87
|
+
if (HasProperty(obj, name))
|
|
88
|
+
{
|
|
89
|
+
var v = GetPropertyValue(obj, name);
|
|
90
|
+
return v?.ToString();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
catch { }
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using System.Threading.Tasks;
|
|
4
|
+
using BBT.Workflow.Scripting;
|
|
5
|
+
using BBT.Workflow.Definitions;
|
|
6
|
+
|
|
7
|
+
/// <summary>
|
|
8
|
+
/// Merges apply-update transition body into rezervation instance Data.
|
|
9
|
+
/// Used when randevu-update flow triggers apply-update on rezervation.
|
|
10
|
+
/// </summary>
|
|
11
|
+
public class MergeRezervationUpdateMapping : ScriptBase, IMapping
|
|
12
|
+
{
|
|
13
|
+
public Task<ScriptResponse> InputHandler(WorkflowTask task, ScriptContext context)
|
|
14
|
+
{
|
|
15
|
+
return Task.FromResult(new ScriptResponse());
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
public Task<ScriptResponse> OutputHandler(ScriptContext context)
|
|
19
|
+
{
|
|
20
|
+
var instanceData = context.Instance?.Data;
|
|
21
|
+
var body = context.Body;
|
|
22
|
+
|
|
23
|
+
var result = new Dictionary<string, object>();
|
|
24
|
+
if (instanceData != null)
|
|
25
|
+
{
|
|
26
|
+
CopyIfPresent(result, instanceData, "user");
|
|
27
|
+
CopyIfPresent(result, instanceData, "advisor");
|
|
28
|
+
CopyIfPresent(result, instanceData, "startDateTime");
|
|
29
|
+
CopyIfPresent(result, instanceData, "endDateTime");
|
|
30
|
+
CopyIfPresent(result, instanceData, "absenceEntryKey");
|
|
31
|
+
CopyIfPresent(result, instanceData, "chatIntegration");
|
|
32
|
+
CopyIfPresent(result, instanceData, "invitedUser");
|
|
33
|
+
CopyIfPresent(result, instanceData, "webrtcIntegration");
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (body != null)
|
|
37
|
+
{
|
|
38
|
+
var startDateTime = GetString(body, "startDateTime");
|
|
39
|
+
var endDateTime = GetString(body, "endDateTime");
|
|
40
|
+
var advisor = GetString(body, "advisor");
|
|
41
|
+
var absenceEntryKey = GetString(body, "absenceEntryKey");
|
|
42
|
+
var previousAdvisor = GetString(body, "previousAdvisor");
|
|
43
|
+
|
|
44
|
+
if (!string.IsNullOrEmpty(startDateTime)) result["startDateTime"] = startDateTime;
|
|
45
|
+
if (!string.IsNullOrEmpty(endDateTime)) result["endDateTime"] = endDateTime;
|
|
46
|
+
if (!string.IsNullOrEmpty(advisor)) result["advisor"] = advisor;
|
|
47
|
+
if (!string.IsNullOrEmpty(absenceEntryKey)) result["absenceEntryKey"] = absenceEntryKey;
|
|
48
|
+
if (!string.IsNullOrEmpty(previousAdvisor)) result["previousAdvisor"] = previousAdvisor;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return Task.FromResult(new ScriptResponse { Data = result });
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
private void CopyIfPresent(Dictionary<string, object> target, dynamic source, string name)
|
|
55
|
+
{
|
|
56
|
+
if (source == null) return;
|
|
57
|
+
try
|
|
58
|
+
{
|
|
59
|
+
if (HasProperty(source, name))
|
|
60
|
+
{
|
|
61
|
+
var v = GetPropertyValue(source, name);
|
|
62
|
+
if (v != null) target[name] = v;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
catch { }
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
private string GetString(dynamic obj, string name)
|
|
69
|
+
{
|
|
70
|
+
if (obj == null) return null;
|
|
71
|
+
try
|
|
72
|
+
{
|
|
73
|
+
if (HasProperty(obj, name))
|
|
74
|
+
{
|
|
75
|
+
var v = GetPropertyValue(obj, name);
|
|
76
|
+
return v?.ToString();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
catch { }
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using System.Threading.Tasks;
|
|
4
|
+
using BBT.Workflow.Scripting;
|
|
5
|
+
using BBT.Workflow.Definitions;
|
|
6
|
+
|
|
7
|
+
/// <summary>
|
|
8
|
+
/// Script Task mapping for the auto-validate path in rezervation-update.
|
|
9
|
+
/// Reads targetAdvisor from instance data (set by transfer flow) and
|
|
10
|
+
/// sets it as the advisor field, preserving all other instance data.
|
|
11
|
+
/// </summary>
|
|
12
|
+
public class MergeTargetAdvisorForTransferMapping : ScriptBase, IMapping
|
|
13
|
+
{
|
|
14
|
+
public Task<ScriptResponse> InputHandler(WorkflowTask task, ScriptContext context)
|
|
15
|
+
{
|
|
16
|
+
return Task.FromResult(new ScriptResponse());
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
public Task<ScriptResponse> OutputHandler(ScriptContext context)
|
|
20
|
+
{
|
|
21
|
+
var instanceData = context.Instance?.Data;
|
|
22
|
+
var result = new Dictionary<string, object>();
|
|
23
|
+
|
|
24
|
+
if (instanceData != null)
|
|
25
|
+
{
|
|
26
|
+
CopyIfPresent(result, instanceData, "randevuKey");
|
|
27
|
+
CopyIfPresent(result, instanceData, "state");
|
|
28
|
+
CopyIfPresent(result, instanceData, "user");
|
|
29
|
+
CopyIfPresent(result, instanceData, "startDateTime");
|
|
30
|
+
CopyIfPresent(result, instanceData, "endDateTime");
|
|
31
|
+
CopyIfPresent(result, instanceData, "absenceEntryKey");
|
|
32
|
+
CopyIfPresent(result, instanceData, "chatIntegration");
|
|
33
|
+
CopyIfPresent(result, instanceData, "originalAdvisor");
|
|
34
|
+
CopyIfPresent(result, instanceData, "autoProcess");
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
var targetAdvisor = GetString(instanceData, "targetAdvisor");
|
|
38
|
+
if (!string.IsNullOrEmpty(targetAdvisor))
|
|
39
|
+
{
|
|
40
|
+
result["advisor"] = targetAdvisor;
|
|
41
|
+
result["targetAdvisor"] = targetAdvisor;
|
|
42
|
+
}
|
|
43
|
+
else
|
|
44
|
+
{
|
|
45
|
+
CopyIfPresent(result, instanceData, "advisor");
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return Task.FromResult(new ScriptResponse { Data = result });
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
private void CopyIfPresent(Dictionary<string, object> target, dynamic source, string name)
|
|
52
|
+
{
|
|
53
|
+
if (source == null) return;
|
|
54
|
+
try
|
|
55
|
+
{
|
|
56
|
+
if (HasProperty(source, name))
|
|
57
|
+
{
|
|
58
|
+
var v = GetPropertyValue(source, name);
|
|
59
|
+
if (v != null) target[name] = v;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
catch { }
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
private string GetString(dynamic obj, string name)
|
|
66
|
+
{
|
|
67
|
+
if (obj == null) return null;
|
|
68
|
+
try
|
|
69
|
+
{
|
|
70
|
+
if (HasProperty(obj, name))
|
|
71
|
+
{
|
|
72
|
+
var v = GetPropertyValue(obj, name);
|
|
73
|
+
return v?.ToString();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
catch { }
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using System.Threading.Tasks;
|
|
4
|
+
using BBT.Workflow.Scripting;
|
|
5
|
+
using BBT.Workflow.Definitions;
|
|
6
|
+
|
|
7
|
+
/// <summary>
|
|
8
|
+
/// Merges transition body (startDateTime, endDateTime, advisor) into instance Data for randevu-update.
|
|
9
|
+
/// Stores originalAdvisor before overwriting, so cancel/invite logic can use it.
|
|
10
|
+
/// </summary>
|
|
11
|
+
public class MergeUpdateBodyForRandevuUpdateMapping : ScriptBase, IMapping
|
|
12
|
+
{
|
|
13
|
+
public Task<ScriptResponse> InputHandler(WorkflowTask task, ScriptContext context)
|
|
14
|
+
{
|
|
15
|
+
return Task.FromResult(new ScriptResponse());
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
public Task<ScriptResponse> OutputHandler(ScriptContext context)
|
|
19
|
+
{
|
|
20
|
+
var instanceData = context.Instance?.Data;
|
|
21
|
+
var body = context.Body;
|
|
22
|
+
|
|
23
|
+
var result = new Dictionary<string, object>();
|
|
24
|
+
|
|
25
|
+
if (instanceData != null)
|
|
26
|
+
{
|
|
27
|
+
CopyIfPresent(result, instanceData, "randevuKey");
|
|
28
|
+
CopyIfPresent(result, instanceData, "state");
|
|
29
|
+
CopyIfPresent(result, instanceData, "user");
|
|
30
|
+
CopyIfPresent(result, instanceData, "advisor");
|
|
31
|
+
CopyIfPresent(result, instanceData, "startDateTime");
|
|
32
|
+
CopyIfPresent(result, instanceData, "endDateTime");
|
|
33
|
+
// Fallback for get-rezervation-data output which uses startDateTimeOld/endDateTimeOld
|
|
34
|
+
if (!result.ContainsKey("startDateTime"))
|
|
35
|
+
{
|
|
36
|
+
var v = GetString(instanceData, "startDateTimeOld");
|
|
37
|
+
if (!string.IsNullOrEmpty(v)) result["startDateTime"] = v;
|
|
38
|
+
}
|
|
39
|
+
if (!result.ContainsKey("endDateTime"))
|
|
40
|
+
{
|
|
41
|
+
var v = GetString(instanceData, "endDateTimeOld");
|
|
42
|
+
if (!string.IsNullOrEmpty(v)) result["endDateTime"] = v;
|
|
43
|
+
}
|
|
44
|
+
CopyIfPresent(result, instanceData, "absenceEntryKey");
|
|
45
|
+
CopyIfPresent(result, instanceData, "chatIntegration");
|
|
46
|
+
CopyIfPresent(result, instanceData, "originalAdvisor");
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (body != null)
|
|
50
|
+
{
|
|
51
|
+
var startDateTime = GetString(body, "startDateTime");
|
|
52
|
+
var endDateTime = GetString(body, "endDateTime");
|
|
53
|
+
var advisor = GetString(body, "advisor");
|
|
54
|
+
|
|
55
|
+
if (!string.IsNullOrEmpty(startDateTime)) result["startDateTime"] = startDateTime;
|
|
56
|
+
if (!string.IsNullOrEmpty(endDateTime)) result["endDateTime"] = endDateTime;
|
|
57
|
+
if (!string.IsNullOrEmpty(advisor)) result["advisor"] = advisor;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return Task.FromResult(new ScriptResponse { Data = result });
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
private void CopyIfPresent(Dictionary<string, object> target, dynamic source, string name)
|
|
64
|
+
{
|
|
65
|
+
if (source == null) return;
|
|
66
|
+
try
|
|
67
|
+
{
|
|
68
|
+
if (HasProperty(source, name))
|
|
69
|
+
{
|
|
70
|
+
var v = GetPropertyValue(source, name);
|
|
71
|
+
if (v != null) target[name] = v;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
catch { }
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
private string GetString(dynamic obj, string name)
|
|
78
|
+
{
|
|
79
|
+
if (obj == null) return null;
|
|
80
|
+
try
|
|
81
|
+
{
|
|
82
|
+
if (HasProperty(obj, name))
|
|
83
|
+
{
|
|
84
|
+
var v = GetPropertyValue(obj, name);
|
|
85
|
+
return v?.ToString();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
catch { }
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
using System.Threading.Tasks;
|
|
2
|
+
using BBT.Workflow.Scripting;
|
|
3
|
+
|
|
4
|
+
/// <summary>
|
|
5
|
+
/// Condition for chat-init: hasExistingPermanentRoom != true -> create-room-and-open transition (with start-permanent-chat-room task) to in-chat.
|
|
6
|
+
/// </summary>
|
|
7
|
+
public class NoExistingPermanentRoomRule : ScriptBase, IConditionMapping
|
|
8
|
+
{
|
|
9
|
+
public Task<bool> Handler(ScriptContext context)
|
|
10
|
+
{
|
|
11
|
+
var data = context.Instance?.Data;
|
|
12
|
+
if (data == null) return Task.FromResult(true);
|
|
13
|
+
try
|
|
14
|
+
{
|
|
15
|
+
if (!HasProperty(data, "hasExistingPermanentRoom")) return Task.FromResult(true);
|
|
16
|
+
var v = GetPropertyValue(data, "hasExistingPermanentRoom");
|
|
17
|
+
if (v == null) return Task.FromResult(true);
|
|
18
|
+
if (v is bool b) return Task.FromResult(!b);
|
|
19
|
+
return Task.FromResult(!string.Equals(v.ToString(), "true", System.StringComparison.OrdinalIgnoreCase));
|
|
20
|
+
}
|
|
21
|
+
catch { return Task.FromResult(true); }
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
using System.Threading.Tasks;
|
|
2
|
+
using BBT.Workflow.Scripting;
|
|
3
|
+
|
|
4
|
+
/// <summary>
|
|
5
|
+
/// Condition for to-complete auto transition from push-sending state.
|
|
6
|
+
/// Always returns true - after push onEntry completes, transition to complete.
|
|
7
|
+
/// </summary>
|
|
8
|
+
public class NotificationCompleteAlwaysRule : ScriptBase, IConditionMapping
|
|
9
|
+
{
|
|
10
|
+
public Task<bool> Handler(ScriptContext context)
|
|
11
|
+
{
|
|
12
|
+
return Task.FromResult(true);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Threading.Tasks;
|
|
3
|
+
using BBT.Workflow.Scripting;
|
|
4
|
+
|
|
5
|
+
/// <summary>
|
|
6
|
+
/// Condition for to-complete auto transition from pending state.
|
|
7
|
+
/// Rule: channels.sms != true AND (channels.push != true OR hasRegisteredDevice != true)
|
|
8
|
+
/// (Fires when no notification channel is applicable)
|
|
9
|
+
/// </summary>
|
|
10
|
+
public class NotificationCompleteFromPendingRule : ScriptBase, IConditionMapping
|
|
11
|
+
{
|
|
12
|
+
public async Task<bool> Handler(ScriptContext context)
|
|
13
|
+
{
|
|
14
|
+
try
|
|
15
|
+
{
|
|
16
|
+
var data = context?.Instance?.Data;
|
|
17
|
+
if (data == null) return true;
|
|
18
|
+
|
|
19
|
+
if (!HasProperty(data, "channels") || data.channels == null)
|
|
20
|
+
return true;
|
|
21
|
+
|
|
22
|
+
var channels = data.channels;
|
|
23
|
+
|
|
24
|
+
bool smsRequested = HasProperty(channels, "sms") && channels.sms == true;
|
|
25
|
+
if (smsRequested)
|
|
26
|
+
return false;
|
|
27
|
+
|
|
28
|
+
bool pushRequested = HasProperty(channels, "push") && channels.push == true;
|
|
29
|
+
bool hasDevice = HasProperty(data, "hasRegisteredDevice") && data.hasRegisteredDevice == true;
|
|
30
|
+
|
|
31
|
+
if (pushRequested && hasDevice)
|
|
32
|
+
return false;
|
|
33
|
+
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
catch (Exception)
|
|
37
|
+
{
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Threading.Tasks;
|
|
3
|
+
using BBT.Workflow.Scripting;
|
|
4
|
+
|
|
5
|
+
/// <summary>
|
|
6
|
+
/// Condition for to-complete auto transition from sms-sending state.
|
|
7
|
+
/// Rule: channels.push != true OR hasRegisteredDevice != true
|
|
8
|
+
/// </summary>
|
|
9
|
+
public class NotificationCompleteFromSmsRule : ScriptBase, IConditionMapping
|
|
10
|
+
{
|
|
11
|
+
public async Task<bool> Handler(ScriptContext context)
|
|
12
|
+
{
|
|
13
|
+
try
|
|
14
|
+
{
|
|
15
|
+
var data = context?.Instance?.Data;
|
|
16
|
+
if (data == null) return true;
|
|
17
|
+
|
|
18
|
+
if (!HasProperty(data, "channels") || data.channels == null)
|
|
19
|
+
return true;
|
|
20
|
+
|
|
21
|
+
var channels = data.channels;
|
|
22
|
+
bool pushRequested = HasProperty(channels, "push") && channels.push == true;
|
|
23
|
+
if (!pushRequested)
|
|
24
|
+
return true;
|
|
25
|
+
|
|
26
|
+
if (!HasProperty(data, "hasRegisteredDevice"))
|
|
27
|
+
return true;
|
|
28
|
+
|
|
29
|
+
return data.hasRegisteredDevice != true;
|
|
30
|
+
}
|
|
31
|
+
catch (Exception)
|
|
32
|
+
{
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|