Skip to content

Commit

Permalink
feat: add timezone property to payload
Browse files Browse the repository at this point in the history
  • Loading branch information
LemmyMwaura committed Apr 30, 2024
1 parent af10aec commit 580d614
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export interface GcpJob

/** In case of a Cloud Scheduler, the time at which to perform the action */
scheduleTime: Timestamp;
timeZone: string;
}

export enum HttpMethodTypes {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ export class WhatsAppUploadMediaHandler extends FunctionHandler<CommunicationCha

const bot = await botsRepo$.getDocumentById(botId);

return bot.publishedOn;
return bot?.publishedOn;
}

private __hasExpired(blockUpdatedTime: moment.Moment)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export class WhatsappUploadMediaCronHandler extends FunctionHandler<WhatsappCron
const [res] = await this.createCronJob(data.channel, jobName);

tools.Logger.log(() => `[WhatsappMediaUpdateCronHandler] - Job successfully created with Name: ${res.name}`);
console.log({res});

} catch (error) {
tools.Logger.error(() => `[WhatsappMediaUpdateCronHandler] - Error in WhatsappMediaUpdateCronHandler: ${error.message}`);
Expand All @@ -59,7 +58,8 @@ export class WhatsappUploadMediaCronHandler extends FunctionHandler<WhatsappCron

private async createCronJob(channel: CommunicationChannel, jobName: string) {
const endpoint = `https://${this.locationId}-${this.projectId}.cloudfunctions.net/channelWhatsappUploadMedia`;
const body = JSON.stringify(channel);

const body = JSON.stringify({data: channel});

const currentTime = Timestamp.fromDate(new Date());

Expand All @@ -72,7 +72,8 @@ export class WhatsappUploadMediaCronHandler extends FunctionHandler<WhatsappCron
headers: { 'Content-Type': 'application/json' },
},
schedule: '0 18 */30 * *',
scheduleTime: currentTime
scheduleTime: currentTime,
timeZone: 'Etc/UTC'
};

const request = {
Expand Down

0 comments on commit 580d614

Please sign in to comment.