Skip to content

Commit

Permalink
fix: sms auto log issue (#703)
Browse files Browse the repository at this point in the history
  • Loading branch information
embbnux authored Aug 31, 2023
1 parent ba36927 commit 5ddad1b
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion src/modules/ConversationLogger/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,23 @@ import {
ConversationLogger as ConversationLoggerBase,
} from '@ringcentral-integration/commons/modules/ConversationLogger';

const getCurrentDateTimeStamp = () => {
let today = new Date();
let dd = today.getDate();
let mm = today.getMonth() + 1;
const yyyy = today.getFullYear();
let ddString = dd.toString();
let mmString = mm.toString();
if (dd < 10) {
ddString = `0${dd}`;
}
if (mm < 10) {
mmString = `0${mm}`;
}
const todayString = `${mmString}/${ddString}/${yyyy}`;
return new Date(todayString).getTime();
};

@Module({
deps: [
'ThirdPartyService'
Expand All @@ -14,6 +31,12 @@ export class ConversationLogger extends ConversationLoggerBase {
this._logFunction = async (data) => {
await this._doLog(data);
};
this._accordWithLogRequirement = (conversation) => {
const { date } = conversation;
const dateTimeStamp = new Date(date).getTime();
const currentDateTimeStamp = getCurrentDateTimeStamp();
return currentDateTimeStamp === dateTimeStamp;
};
}

async _doLog(conversation) {
Expand Down Expand Up @@ -48,7 +71,7 @@ export class ConversationLogger extends ConversationLoggerBase {
await this._autoLogConversation({
conversation,
});
} else if (this.autoLog) {
} else if (this.autoLog) { // override here for voicemail and fax support
// new entry
const numbers: string[] = [];
const numberMap: Record<string, boolean> = {};
Expand Down

0 comments on commit 5ddad1b

Please sign in to comment.