Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: livechat interaction handler is receiving its context data wrapped in a second instance of the context class #803

Merged
merged 1 commit into from
Sep 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions src/server/managers/AppListenerManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ import { UIActionButtonContext } from '../../definition/ui';
import type { IUIKitResponse, IUIKitSurface, UIKitIncomingInteraction } from '../../definition/uikit';
import { UIKitIncomingInteractionType } from '../../definition/uikit';
import { isUIKitIncomingInteractionActionButtonMessageBox } from '../../definition/uikit/IUIKitIncomingInteractionActionButton';
import type { IUIKitLivechatIncomingInteraction } from '../../definition/uikit/livechat';
import { UIKitLivechatBlockInteractionContext } from '../../definition/uikit/livechat';
import type { IUIKitLivechatBlockIncomingInteraction, IUIKitLivechatIncomingInteraction } from '../../definition/uikit/livechat';
import type {
IUIKitIncomingInteractionMessageContainer,
IUIKitIncomingInteractionModalContainer,
Expand Down Expand Up @@ -1016,14 +1015,17 @@ export class AppListenerManager {

const app = this.manager.getOneById(appId);

const interactionContext = ((interactionType: UIKitIncomingInteractionType, interactionData: IUIKitLivechatIncomingInteraction) => {
const { actionId, message, visitor, room, triggerId, container } = interactionData;
const interactionData = ((
interactionType: UIKitIncomingInteractionType,
interaction: IUIKitLivechatIncomingInteraction,
): IUIKitLivechatBlockIncomingInteraction => {
const { actionId, message, visitor, room, triggerId, container } = interaction;

switch (interactionType) {
case UIKitIncomingInteractionType.BLOCK: {
const { value, blockId } = interactionData.payload as { value: string; blockId: string };
const { value, blockId } = interaction.payload as { value: string; blockId: string };

return new UIKitLivechatBlockInteractionContext({
return {
appId,
actionId,
blockId,
Expand All @@ -1033,12 +1035,12 @@ export class AppListenerManager {
value,
message,
container: container as IUIKitIncomingInteractionModalContainer | IUIKitIncomingInteractionMessageContainer,
});
};
}
}
})(type, data);

return app.call(method, interactionContext);
return app.call(method, interactionData);
}

// Livechat
Expand Down
Loading