Skip to content

Commit 306efbb

Browse files
committed
fix template card undefined
1 parent 04fd8d3 commit 306efbb

File tree

3 files changed

+40
-23
lines changed

3 files changed

+40
-23
lines changed

client/package-lock.json

Lines changed: 0 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/src/channels/web.channel.ts

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,55 @@ export class WebChannel extends BaseChannel {
2121

2222
async prepareMessage(req: Request, res: Response) { }
2323

24-
public async sendMessageToUser({ userId, text, type }: {
24+
public async sendMessageToUser({ userId, text, type, channelData }: {
2525
type?: string;
2626
userId: string;
2727
text: string;
28+
channelData: any;
2829
}) {
2930
try {
30-
if (App.io) {
31+
let result = { userId, messages: text || '', template: {} };
3132

32-
App.io.to(userId).emit(
33-
type || SOCKET_EVENTS.MESSAGE,
34-
{ userId, message: text });
33+
if (channelData) {
34+
result.template = {
35+
data: channelData.extendData,
36+
type: channelData.type,
37+
}
38+
}
39+
console.log('result: ' + JSON.stringify(result));
40+
if (App.io) {
41+
App.io.to(userId).emit(type || SOCKET_EVENTS.MESSAGE, result);
3542
}
3643
} catch (e) {
3744
logger.info(
3845
`[WEB] Bot send message to User failed - Error: ${e.message}`,
3946
)
4047
}
4148
}
49+
50+
// async detectTemplate(channelData: any) {
51+
// let result = null;
52+
// if (!channelData) return result;
53+
54+
// switch (channelData.type) {
55+
// case 'list-button':
56+
// result = {
57+
// data: channelData.extendData,
58+
// type: channelData.type,
59+
// }
60+
// break;
61+
// case 'list-card':
62+
// result = {
63+
// data: channelData.extendData,
64+
// type: channelData.type,
65+
// }
66+
// break;
67+
// default:
68+
// logger.info(
69+
// `[WEB] channel web does not support type ${channelData.type}`,
70+
// )
71+
// break;
72+
// }
73+
// return result;
74+
// }
4275
}

server/src/services/conversation.service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ export class ConversationService {
7373
return await webChannel.sendMessageToUser({
7474
userId: recipient.id,
7575
text,
76-
type
76+
type,
77+
channelData,
7778
})
7879
default:
7980
logger.info(

0 commit comments

Comments
 (0)