sleep for 1 second to avoid rate limiting

This commit is contained in:
Hongbo Wu
2024-07-22 18:36:11 +08:00
parent 95657e3d3e
commit 110f537e72
4 changed files with 54 additions and 39 deletions

View File

@ -13,7 +13,7 @@ import { importCsv } from './csv'
import { queueEmailJob } from './job'
import { importMatterArchive } from './matterHistory'
import { ImportStatus, updateMetrics } from './metrics'
import { CONTENT_FETCH_URL, createCloudTask, emailUserUrl } from './task'
import { CONTENT_FETCH_URL, createCloudTask } from './task'
export enum ArticleSavingRequestStatus {
Failed = 'FAILED',
@ -118,28 +118,6 @@ const importURL = async (
})
}
const createEmailCloudTask = async (userId: string, payload: unknown) => {
if (!process.env.JWT_SECRET) {
throw 'Envrionment not setup correctly'
}
const exp = Math.floor(Date.now() / 1000) + 60 * 60 * 24 // 1 day
const authToken = (await signToken(
{ uid: userId, exp },
process.env.JWT_SECRET
)) as string
const headers = {
'Omnivore-Authorization': authToken,
}
return createCloudTask(
emailUserUrl(),
payload,
headers,
'omnivore-email-queue'
)
}
const sendImportFailedEmail = async (
redisDataSource: RedisDataSource,
userId: string

View File

@ -3,14 +3,6 @@ import { CloudTasksClient, protos } from '@google-cloud/tasks'
const cloudTask = new CloudTasksClient()
export const emailUserUrl = () => {
const envar = process.env.INTERNAL_SVC_ENDPOINT
if (envar) {
return envar + 'api/user/email'
}
throw 'INTERNAL_SVC_ENDPOINT not set'
}
export const CONTENT_FETCH_URL = process.env.CONTENT_FETCH_GCF_URL
export const createCloudTask = async (