diff options
Diffstat (limited to 'packages/workers')
| -rw-r--r-- | packages/workers/crawler.ts | 14 | ||||
| -rw-r--r-- | packages/workers/openai.ts | 1 |
2 files changed, 14 insertions, 1 deletions
diff --git a/packages/workers/crawler.ts b/packages/workers/crawler.ts index 45d2f530..4febc1ca 100644 --- a/packages/workers/crawler.ts +++ b/packages/workers/crawler.ts @@ -70,6 +70,17 @@ export class CrawlerWorker { } } +async function getBookmarkUrl(bookmarkId: string) { + const bookmark = await prisma.bookmarkedLink.findUnique({ + where: { id: bookmarkId }, + }); + + if (!bookmark) { + throw new Error("The bookmark either doesn't exist or not a link"); + } + return bookmark.url; +} + async function crawlPage(url: string) { if (!browser) { throw new Error("The browser must have been initalized by this point."); @@ -98,7 +109,8 @@ async function runCrawler(job: Job<ZCrawlLinkRequest, void>) { return; } - const { url, bookmarkId } = request.data; + const { bookmarkId } = request.data; + const url = await getBookmarkUrl(bookmarkId); logger.info( `[Crawler][${jobId}] Will crawl "${url}" for link with id "${bookmarkId}"`, diff --git a/packages/workers/openai.ts b/packages/workers/openai.ts index 1adedeba..7c45b2cb 100644 --- a/packages/workers/openai.ts +++ b/packages/workers/openai.ts @@ -140,6 +140,7 @@ async function createTags(tags: string[], userId: string) { async function connectTags(bookmarkId: string, tagIds: string[]) { // TODO: Prisma doesn't support createMany in Sqlite + // TODO: This could fail on refetch if the tags are already there await Promise.all( tagIds.map((tagId) => { return prisma.tagsOnBookmarks.create({ |
