Skip to content

Commit

Permalink
Add user uuid and deployment id to NATS subjects
Browse files Browse the repository at this point in the history
  • Loading branch information
harishmohanraj committed Jul 15, 2024
1 parent 0d1eb07 commit 24c2015
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions app/src/server/websocket/nats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,17 @@ export async function sendMsgToNatsServer(

// Initiate chat or continue conversation
const initiateChatSubject = `chat.server.initiate_chat`;
const serverInputSubject = `chat.server.messages.${threadId}`;
const serverInputSubject = `chat.server.messages.${userUUID}.${FASTAGENCY_DEPLOYMENT_UUID}.${threadId}`;
const subject = shouldCallInitiateChat ? initiateChatSubject : serverInputSubject;

NatsConnectionManager.clearConversationHistory(threadId);
const payload = { user_id: userUUID, thread_id: threadId, team_id: selectedTeamUUID, msg: message };
const payload = {
user_id: userUUID,
thread_id: threadId,
team_id: selectedTeamUUID,
msg: message,
deployment_id: FASTAGENCY_DEPLOYMENT_UUID,
};
console.log('-----------');
console.log(selectedTeamUUID);
console.log(payload);
Expand All @@ -226,7 +232,7 @@ export async function sendMsgToNatsServer(
NatsConnectionManager.setTimeout(threadId, timeoutCallback, 45000);

if (shouldCallInitiateChat) {
const clientInputSubject = `chat.client.messages.${threadId}`;
const clientInputSubject = `chat.client.messages.${userUUID}.${FASTAGENCY_DEPLOYMENT_UUID}.${threadId}`;
await setupSubscription(js, jc, clientInputSubject, threadId, socket, context, currentChatDetails);
} else {
NatsConnectionManager.setConversationId(threadId, conversationId);
Expand Down

0 comments on commit 24c2015

Please sign in to comment.