Skip to content

Commit

Permalink
Merge pull request #2 from AvayaExperiencePlatform/feature/utilize-so…
Browse files Browse the repository at this point in the history
…urce-type-address

Utilize sourceType & sourceAdress for CC phone number + Fix some logging
  • Loading branch information
zaelzanati authored Feb 19, 2024
2 parents b0734a7 + d4f4596 commit 2715587
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ COPY --from=base lib/ /lib/
COPY --from=base usr/ /usr/
COPY --from=base app/ /app/
COPY --from=base bin/ /bin/
EXPOSE 3030
EXPOSE 4210

ENV NODE_ENV production

Expand Down
5 changes: 4 additions & 1 deletion src/controllers/axp-callback-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ export class AXPCallbackController extends BaseController {
return { success: true, message: 'Message Processed to CPaaS' };
} else return { success: false, message: 'Unknown connector type!' };
} catch (error) {
this.logger.error(`Error occured in AXP Callback Handler - `, error);
this.logger.error(`Error occured in AXP Callback Handler - `, error?.message);
if (error?.response?.data) {
this.logger.error(`Error response recieved:`, { data: error.response.data })
}
throw new InternalServerError('Error occurred in callback handler');
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/controllers/cpaas-callback-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ export class CPaaSCallbackController extends BaseController {
this.logger.info(`Response received from CPaaS Callback Handler`, { response });
return { success: true, message: 'Message Processed!' };
} catch (error) {
this.logger.error(`Error occured in CPaaS Callback Handler - `, error);
this.logger.error(`Error occured in CPaaS Callback Handler - `, error?.message);
if (error?.response?.data) {
this.logger.error(`Error response recieved:`, { data: error.response.data })
}
throw new InternalServerError('Error occurred in callback handler');
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/infrastructure/services/axp/axp-connector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default class AXPConnector implements AbstractConnector {
}

public async sendMessage(message: NormalizedMessage): Promise<NormalizedMessage> {
this.logger.info(`Sending normalized message to AXP: `, { message });
this.logger.info(`Sending normalized message to AXP: `, { normalizedMessage: message });
const axpMessage = transformToAXPMessage(message);
this.logger.info(`Transformed normalized message to AXP Fromat: `, { axpMessage });
const sentMessage = await this.apiClient.sendMessage(axpMessage);
Expand Down
2 changes: 1 addition & 1 deletion src/infrastructure/services/cpaas/cpaas-connector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default class CPaaSConnector implements AbstractConnector {
}

public async sendMessage(message: NormalizedMessage): Promise<NormalizedMessage> {
this.logger.info(`Sending normalized message to CPaaS: `, { message });
this.logger.info(`Sending normalized message to CPaaS: `, { normalizedMessage: message });

const cpaasMessage = transformToCPaaSMessage(message);
this.logger.info(`Transformed normalized message to CPaaS Fromat: `, { cpaasMessage });
Expand Down
14 changes: 9 additions & 5 deletions src/infrastructure/types/transformers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ export const normalizeAXPMessage = (message: IncomingMessage): NormalizedMessage
return {
message: {
id: message.message.messageId,
senderId: message.message.providerDialogId.split('_')[1],
receiverId: message.message.providerDialogId.split('_')[0],
receieverName: message.message.senderParticipantName,
senderName: message.message.recipientParticipants[0]?.displayName,
senderId: message.message.headers.sourceAddress,
receiverId: message.message.recipientParticipants[0].providerParticipantId,
senderName: message.message.senderParticipantName,
receieverName: message.message.recipientParticipants[0]?.displayName,
text: message.message.body.elementText.text,
timestamp: message.message.receivedAt,
},
Expand Down Expand Up @@ -47,9 +47,13 @@ export const transformToAXPMessage = (message: NormalizedMessage): AXPSendMessag
textFormat: 'PLAINTEXT',
},
},
headers: {
sourceType: 'SMS',
sourceAddress: message.message.receiverId
},
senderName: message.message.senderName,
providerSenderId: message.message.senderId,
providerDialogId: `${message.message.senderId}_${message.message.receiverId}`,
providerDialogId: `SMS_${message.message.senderId}_${message.message.receiverId}`,
providerMessageId: message.message.id,
engagementParameters: { receipientId: message.message.receiverId },
};
Expand Down
8 changes: 8 additions & 0 deletions src/infrastructure/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ export type AXPIncomingMessage = {
providerParticipantId: string;
channelProviderId: string;
}[];
headers?:{
sourceType: string;
sourceAddress: string;
};
providerDialogId: string;
providerSenderId: string;
receivedAt: string;
Expand Down Expand Up @@ -106,6 +110,10 @@ export type AXPSendMessage = {
textFormat: 'PLAINTEXT';
};
};
headers?:{
sourceType: string;
sourceAddress: string;
};
senderName: string;
providerSenderId: string;
providerDialogId?: string;
Expand Down

0 comments on commit 2715587

Please sign in to comment.