1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
|
import { TRPCError } from "@trpc/server";
import {
and,
asc,
desc,
eq,
exists,
gt,
gte,
inArray,
lt,
lte,
or,
} from "drizzle-orm";
import invariant from "tiny-invariant";
import { z } from "zod";
import { db as DONT_USE_db } from "@karakeep/db";
import {
assets,
AssetTypes,
bookmarkAssets,
bookmarkLinks,
bookmarkLists,
bookmarks,
bookmarksInLists,
bookmarkTags,
bookmarkTexts,
listCollaborators,
rssFeedImportsTable,
tagsOnBookmarks,
} from "@karakeep/db/schema";
import { SearchIndexingQueue, triggerWebhook } from "@karakeep/shared-server";
import { deleteAsset, readAsset } from "@karakeep/shared/assetdb";
import serverConfig from "@karakeep/shared/config";
import {
createSignedToken,
getAlignedExpiry,
} from "@karakeep/shared/signedTokens";
import { zAssetSignedTokenSchema } from "@karakeep/shared/types/assets";
import {
BookmarkTypes,
DEFAULT_NUM_BOOKMARKS_PER_PAGE,
ZBareBookmark,
ZBookmark,
ZBookmarkContent,
zGetBookmarksRequestSchema,
ZPublicBookmark,
} from "@karakeep/shared/types/bookmarks";
import { ZCursor } from "@karakeep/shared/types/pagination";
import {
getBookmarkLinkAssetIdOrUrl,
getBookmarkTitle,
} from "@karakeep/shared/utils/bookmarkUtils";
import { htmlToPlainText } from "@karakeep/shared/utils/htmlUtils";
import { AuthedContext } from "..";
import { mapDBAssetTypeToUserType } from "../lib/attachments";
import { List } from "./lists";
async function dummyDrizzleReturnType() {
const x = await DONT_USE_db.query.bookmarks.findFirst({
with: {
tagsOnBookmarks: {
with: {
tag: true,
},
},
link: true,
text: true,
asset: true,
assets: true,
},
});
if (!x) {
throw new Error();
}
return x;
}
type BookmarkQueryReturnType = Awaited<
ReturnType<typeof dummyDrizzleReturnType>
>;
export class BareBookmark {
protected constructor(
protected ctx: AuthedContext,
private bareBookmark: ZBareBookmark,
) {}
get id() {
return this.bareBookmark.id;
}
get createdAt() {
return this.bareBookmark.createdAt;
}
static async bareFromId(ctx: AuthedContext, bookmarkId: string) {
const bookmark = await ctx.db.query.bookmarks.findFirst({
where: eq(bookmarks.id, bookmarkId),
});
if (!bookmark) {
throw new TRPCError({
code: "NOT_FOUND",
message: "Bookmark not found",
});
}
if (!(await BareBookmark.isAllowedToAccessBookmark(ctx, bookmark))) {
throw new TRPCError({
code: "NOT_FOUND",
message: "Bookmark not found",
});
}
return new BareBookmark(ctx, bookmark);
}
protected static async isAllowedToAccessBookmark(
ctx: AuthedContext,
{ id: bookmarkId, userId: bookmarkOwnerId }: { id: string; userId: string },
): Promise<boolean> {
if (bookmarkOwnerId == ctx.user.id) {
return true;
}
const bookmarkLists = await List.forBookmark(ctx, bookmarkId);
return bookmarkLists.some((l) => l.canUserView());
}
ensureOwnership() {
if (this.bareBookmark.userId != this.ctx.user.id) {
throw new TRPCError({
code: "FORBIDDEN",
message: "User is not allowed to access resource",
});
}
}
}
export class Bookmark extends BareBookmark {
protected constructor(
ctx: AuthedContext,
private bookmark: ZBookmark,
) {
super(ctx, bookmark);
}
private static async toZodSchema(
bookmark: BookmarkQueryReturnType,
includeContent: boolean,
): Promise<ZBookmark> {
const { tagsOnBookmarks, link, text, asset, assets, ...rest } = bookmark;
let content: ZBookmarkContent = {
type: BookmarkTypes.UNKNOWN,
};
if (bookmark.link) {
content = {
type: BookmarkTypes.LINK,
screenshotAssetId: assets.find(
(a) => a.assetType == AssetTypes.LINK_SCREENSHOT,
)?.id,
fullPageArchiveAssetId: assets.find(
(a) => a.assetType == AssetTypes.LINK_FULL_PAGE_ARCHIVE,
)?.id,
precrawledArchiveAssetId: assets.find(
(a) => a.assetType == AssetTypes.LINK_PRECRAWLED_ARCHIVE,
)?.id,
imageAssetId: assets.find(
(a) => a.assetType == AssetTypes.LINK_BANNER_IMAGE,
)?.id,
videoAssetId: assets.find((a) => a.assetType == AssetTypes.LINK_VIDEO)
?.id,
url: link.url,
title: link.title,
description: link.description,
imageUrl: link.imageUrl,
favicon: link.favicon,
htmlContent: includeContent
? await Bookmark.getBookmarkHtmlContent(link, bookmark.userId)
: null,
crawledAt: link.crawledAt,
author: link.author,
publisher: link.publisher,
datePublished: link.datePublished,
dateModified: link.dateModified,
};
}
if (bookmark.text) {
content = {
type: BookmarkTypes.TEXT,
// It's ok to include the text content as it's usually not big and is used to render the text bookmark card.
text: text.text ?? "",
sourceUrl: text.sourceUrl,
};
}
if (bookmark.asset) {
content = {
type: BookmarkTypes.ASSET,
assetType: asset.assetType,
assetId: asset.assetId,
fileName: asset.fileName,
sourceUrl: asset.sourceUrl,
size: assets.find((a) => a.id == asset.assetId)?.size,
content: includeContent ? asset.content : null,
};
}
return {
tags: tagsOnBookmarks
.map((t) => ({
attachedBy: t.attachedBy,
...t.tag,
}))
.sort((a, b) =>
a.attachedBy === "ai" ? 1 : b.attachedBy === "ai" ? -1 : 0,
),
content,
assets: assets.map((a) => ({
id: a.id,
assetType: mapDBAssetTypeToUserType(a.assetType),
fileName: a.fileName,
})),
...rest,
};
}
static async fromId(
ctx: AuthedContext,
bookmarkId: string,
includeContent: boolean,
) {
const bookmark = await ctx.db.query.bookmarks.findFirst({
where: eq(bookmarks.id, bookmarkId),
with: {
tagsOnBookmarks: {
with: {
tag: true,
},
},
link: true,
text: true,
asset: true,
assets: true,
},
});
if (!bookmark) {
throw new TRPCError({
code: "NOT_FOUND",
message: "Bookmark not found",
});
}
if (!(await BareBookmark.isAllowedToAccessBookmark(ctx, bookmark))) {
throw new TRPCError({
code: "NOT_FOUND",
message: "Bookmark not found",
});
}
return Bookmark.fromData(
ctx,
await Bookmark.toZodSchema(bookmark, includeContent),
);
}
static fromData(ctx: AuthedContext, data: ZBookmark) {
return new Bookmark(ctx, data);
}
static async loadMulti(
ctx: AuthedContext,
input: z.infer<typeof zGetBookmarksRequestSchema>,
): Promise<{
bookmarks: Bookmark[];
nextCursor: ZCursor | null;
}> {
if (input.ids && input.ids.length == 0) {
return { bookmarks: [], nextCursor: null };
}
if (!input.limit) {
input.limit = DEFAULT_NUM_BOOKMARKS_PER_PAGE;
}
if (input.listId) {
const list = await List.fromId(ctx, input.listId);
if (list.type === "smart") {
input.ids = await list.getBookmarkIds();
delete input.listId;
}
}
const sq = ctx.db.$with("bookmarksSq").as(
ctx.db
.select()
.from(bookmarks)
.where(
and(
// Access control: User can access bookmarks if they either:
// 1. Own the bookmark (always)
// 2. The bookmark is in a specific shared list being viewed
// When listId is specified, we need special handling to show all bookmarks in that list
input.listId !== undefined
? // If querying a specific list, check if user has access to that list
or(
eq(bookmarks.userId, ctx.user.id),
// User is the owner of the list being queried
exists(
ctx.db
.select()
.from(bookmarkLists)
.where(
and(
eq(bookmarkLists.id, input.listId),
eq(bookmarkLists.userId, ctx.user.id),
),
),
),
// User is a collaborator on the list being queried
exists(
ctx.db
.select()
.from(listCollaborators)
.where(
and(
eq(listCollaborators.listId, input.listId),
eq(listCollaborators.userId, ctx.user.id),
),
),
),
)
: // If not querying a specific list, only show bookmarks the user owns
// Shared bookmarks should only appear when viewing the specific shared list
eq(bookmarks.userId, ctx.user.id),
input.archived !== undefined
? eq(bookmarks.archived, input.archived)
: undefined,
input.favourited !== undefined
? eq(bookmarks.favourited, input.favourited)
: undefined,
input.ids ? inArray(bookmarks.id, input.ids) : undefined,
input.tagId !== undefined
? exists(
ctx.db
.select()
.from(tagsOnBookmarks)
.where(
and(
eq(tagsOnBookmarks.bookmarkId, bookmarks.id),
eq(tagsOnBookmarks.tagId, input.tagId),
),
),
)
: undefined,
input.rssFeedId !== undefined
? exists(
ctx.db
.select()
.from(rssFeedImportsTable)
.where(
and(
eq(rssFeedImportsTable.bookmarkId, bookmarks.id),
eq(rssFeedImportsTable.rssFeedId, input.rssFeedId),
),
),
)
: undefined,
input.listId !== undefined
? exists(
ctx.db
.select()
.from(bookmarksInLists)
.where(
and(
eq(bookmarksInLists.bookmarkId, bookmarks.id),
eq(bookmarksInLists.listId, input.listId),
),
),
)
: undefined,
input.cursor
? input.sortOrder === "asc"
? or(
gt(bookmarks.createdAt, input.cursor.createdAt),
and(
eq(bookmarks.createdAt, input.cursor.createdAt),
gte(bookmarks.id, input.cursor.id),
),
)
: or(
lt(bookmarks.createdAt, input.cursor.createdAt),
and(
eq(bookmarks.createdAt, input.cursor.createdAt),
lte(bookmarks.id, input.cursor.id),
),
)
: undefined,
),
)
.limit(input.limit + 1)
.orderBy(
input.sortOrder === "asc"
? asc(bookmarks.createdAt)
: desc(bookmarks.createdAt),
desc(bookmarks.id),
),
);
// TODO: Consider not inlining the tags in the response of getBookmarks as this query is getting kinda expensive
const results = await ctx.db
.with(sq)
.select()
.from(sq)
.leftJoin(tagsOnBookmarks, eq(sq.id, tagsOnBookmarks.bookmarkId))
.leftJoin(bookmarkTags, eq(tagsOnBookmarks.tagId, bookmarkTags.id))
.leftJoin(bookmarkLinks, eq(bookmarkLinks.id, sq.id))
.leftJoin(bookmarkTexts, eq(bookmarkTexts.id, sq.id))
.leftJoin(bookmarkAssets, eq(bookmarkAssets.id, sq.id))
.leftJoin(assets, eq(assets.bookmarkId, sq.id))
.orderBy(desc(sq.createdAt), desc(sq.id));
const bookmarksRes = results.reduce<Record<string, ZBookmark>>(
(acc, row) => {
const bookmarkId = row.bookmarksSq.id;
if (!acc[bookmarkId]) {
let content: ZBookmarkContent;
if (row.bookmarkLinks) {
content = {
type: BookmarkTypes.LINK,
url: row.bookmarkLinks.url,
title: row.bookmarkLinks.title,
description: row.bookmarkLinks.description,
imageUrl: row.bookmarkLinks.imageUrl,
favicon: row.bookmarkLinks.favicon,
htmlContent: input.includeContent
? row.bookmarkLinks.contentAssetId
? null // Will be populated later from asset
: row.bookmarkLinks.htmlContent
: null,
contentAssetId: row.bookmarkLinks.contentAssetId,
crawledAt: row.bookmarkLinks.crawledAt,
author: row.bookmarkLinks.author,
publisher: row.bookmarkLinks.publisher,
datePublished: row.bookmarkLinks.datePublished,
dateModified: row.bookmarkLinks.dateModified,
};
} else if (row.bookmarkTexts) {
content = {
type: BookmarkTypes.TEXT,
text: row.bookmarkTexts.text ?? "",
sourceUrl: row.bookmarkTexts.sourceUrl ?? null,
};
} else if (row.bookmarkAssets) {
content = {
type: BookmarkTypes.ASSET,
assetId: row.bookmarkAssets.assetId,
assetType: row.bookmarkAssets.assetType,
fileName: row.bookmarkAssets.fileName,
sourceUrl: row.bookmarkAssets.sourceUrl ?? null,
size: null, // This will get filled in the asset loop
content: input.includeContent
? (row.bookmarkAssets.content ?? null)
: null,
};
} else {
content = {
type: BookmarkTypes.UNKNOWN,
};
}
acc[bookmarkId] = {
...row.bookmarksSq,
content,
tags: [],
assets: [],
};
}
if (
row.bookmarkTags &&
// Duplicates may occur because of the join, so we need to make sure we're not adding the same tag twice
!acc[bookmarkId].tags.some((t) => t.id == row.bookmarkTags!.id)
) {
invariant(
row.tagsOnBookmarks,
"if bookmark tag is set, its many-to-many relation must also be set",
);
acc[bookmarkId].tags.push({
...row.bookmarkTags,
attachedBy: row.tagsOnBookmarks.attachedBy,
});
}
if (
row.assets &&
!acc[bookmarkId].assets.some((a) => a.id == row.assets!.id)
) {
if (acc[bookmarkId].content.type == BookmarkTypes.LINK) {
const content = acc[bookmarkId].content;
invariant(content.type == BookmarkTypes.LINK);
if (row.assets.assetType == AssetTypes.LINK_SCREENSHOT) {
content.screenshotAssetId = row.assets.id;
}
if (row.assets.assetType == AssetTypes.LINK_FULL_PAGE_ARCHIVE) {
content.fullPageArchiveAssetId = row.assets.id;
}
if (row.assets.assetType == AssetTypes.LINK_BANNER_IMAGE) {
content.imageAssetId = row.assets.id;
}
if (row.assets.assetType == AssetTypes.LINK_VIDEO) {
content.videoAssetId = row.assets.id;
}
if (row.assets.assetType == AssetTypes.LINK_PRECRAWLED_ARCHIVE) {
content.precrawledArchiveAssetId = row.assets.id;
}
acc[bookmarkId].content = content;
}
if (acc[bookmarkId].content.type == BookmarkTypes.ASSET) {
const content = acc[bookmarkId].content;
if (row.assets.id == content.assetId) {
// If this is the bookmark's main aset, caputure its size.
content.size = row.assets.size;
}
}
acc[bookmarkId].assets.push({
id: row.assets.id,
assetType: mapDBAssetTypeToUserType(row.assets.assetType),
fileName: row.assets.fileName,
});
}
return acc;
},
{},
);
const bookmarksArr = Object.values(bookmarksRes);
// Fetch HTML content from assets for bookmarks that have contentAssetId (large content)
if (input.includeContent) {
await Promise.all(
bookmarksArr.map(async (bookmark) => {
if (
bookmark.content.type === BookmarkTypes.LINK &&
bookmark.content.contentAssetId &&
!bookmark.content.htmlContent // Only fetch if not already inline
) {
try {
const asset = await readAsset({
userId: bookmark.userId,
assetId: bookmark.content.contentAssetId,
});
bookmark.content.htmlContent = asset.asset.toString("utf8");
} catch (error) {
// If asset reading fails, keep htmlContent as null
console.warn(
`Failed to read HTML content asset ${bookmark.content.contentAssetId}:`,
error,
);
}
}
}),
);
}
bookmarksArr.sort((a, b) => {
if (a.createdAt != b.createdAt) {
return input.sortOrder === "asc"
? a.createdAt.getTime() - b.createdAt.getTime()
: b.createdAt.getTime() - a.createdAt.getTime();
} else {
return b.id.localeCompare(a.id);
}
});
bookmarksArr.forEach((b) => {
b.tags.sort((a, b) =>
a.attachedBy === "ai" ? 1 : b.attachedBy === "ai" ? -1 : 0,
);
});
let nextCursor = null;
if (bookmarksArr.length > input.limit) {
const nextItem = bookmarksArr.pop()!;
nextCursor = {
id: nextItem.id,
createdAt: nextItem.createdAt,
};
}
return {
bookmarks: bookmarksArr.map((b) => Bookmark.fromData(ctx, b)),
nextCursor,
};
}
asZBookmark(): ZBookmark {
if (this.bookmark.userId === this.ctx.user.id) {
return this.bookmark;
}
// Collaborators shouldn't see owner-specific state such as favourites,
// archived flag, or personal notes.
return {
...this.bookmark,
archived: false,
favourited: false,
note: null,
};
}
asPublicBookmark(): ZPublicBookmark {
const getPublicSignedAssetUrl = (assetId: string) => {
const payload: z.infer<typeof zAssetSignedTokenSchema> = {
assetId,
userId: this.ctx.user.id,
};
const signedToken = createSignedToken(
payload,
serverConfig.signingSecret(),
// Tokens will expire in 1 hour and will have a grace period of 15mins
getAlignedExpiry(/* interval */ 3600, /* grace */ 900),
);
return `${serverConfig.publicApiUrl}/public/assets/${assetId}?token=${signedToken}`;
};
const getContent = (
content: ZBookmarkContent,
): ZPublicBookmark["content"] => {
switch (content.type) {
case BookmarkTypes.LINK: {
return {
type: BookmarkTypes.LINK,
url: content.url,
};
}
case BookmarkTypes.TEXT: {
return {
type: BookmarkTypes.TEXT,
text: content.text,
};
}
case BookmarkTypes.ASSET: {
return {
type: BookmarkTypes.ASSET,
assetType: content.assetType,
assetId: content.assetId,
assetUrl: getPublicSignedAssetUrl(content.assetId),
fileName: content.fileName,
sourceUrl: content.sourceUrl,
};
}
default: {
throw new Error("Unknown bookmark content type");
}
}
};
const getBannerImageUrl = (content: ZBookmarkContent): string | null => {
switch (content.type) {
case BookmarkTypes.LINK: {
const assetIdOrUrl = getBookmarkLinkAssetIdOrUrl(content);
if (!assetIdOrUrl) {
return null;
}
if (assetIdOrUrl.localAsset) {
return getPublicSignedAssetUrl(assetIdOrUrl.assetId);
} else {
return assetIdOrUrl.url;
}
}
case BookmarkTypes.TEXT: {
return null;
}
case BookmarkTypes.ASSET: {
switch (content.assetType) {
case "image":
return `${getPublicSignedAssetUrl(content.assetId)}`;
case "pdf": {
const screenshotAssetId = this.bookmark.assets.find(
(r) => r.assetType === "assetScreenshot",
)?.id;
if (!screenshotAssetId) {
return null;
}
return getPublicSignedAssetUrl(screenshotAssetId);
}
default: {
const _exhaustiveCheck: never = content.assetType;
return null;
}
}
}
default: {
throw new Error("Unknown bookmark content type");
}
}
};
// WARNING: Everything below is exposed in the public APIs, don't use spreads!
return {
id: this.bookmark.id,
createdAt: this.bookmark.createdAt,
modifiedAt: this.bookmark.modifiedAt,
title: getBookmarkTitle(this.bookmark),
tags: this.bookmark.tags.map((t) => t.name),
content: getContent(this.bookmark.content),
bannerImageUrl: getBannerImageUrl(this.bookmark.content),
};
}
static async getBookmarkHtmlContent(
{
contentAssetId,
htmlContent,
}: {
contentAssetId: string | null;
htmlContent: string | null;
},
userId: string,
): Promise<string | null> {
if (contentAssetId) {
// Read large HTML content from asset
const asset = await readAsset({
userId,
assetId: contentAssetId,
});
return asset.asset.toString("utf8");
} else if (htmlContent) {
return htmlContent;
}
return null;
}
static async getBookmarkPlainTextContent(
{
contentAssetId,
htmlContent,
}: {
contentAssetId: string | null;
htmlContent: string | null;
},
userId: string,
): Promise<string | null> {
const content = await this.getBookmarkHtmlContent(
{
contentAssetId,
htmlContent,
},
userId,
);
if (!content) {
return null;
}
return htmlToPlainText(content);
}
private async cleanupAssets() {
const assetIds: Set<string> = new Set<string>(
this.bookmark.assets.map((a) => a.id),
);
// Todo: Remove when the bookmark asset is also in the assets table
if (this.bookmark.content.type == BookmarkTypes.ASSET) {
assetIds.add(this.bookmark.content.assetId);
}
await Promise.all(
Array.from(assetIds).map((assetId) =>
deleteAsset({ userId: this.bookmark.userId, assetId }),
),
);
}
async delete() {
this.ensureOwnership();
const deleted = await this.ctx.db
.delete(bookmarks)
.where(
and(
eq(bookmarks.userId, this.ctx.user.id),
eq(bookmarks.id, this.bookmark.id),
),
);
await SearchIndexingQueue.enqueue(
{
bookmarkId: this.bookmark.id,
type: "delete",
},
{
groupId: this.ctx.user.id,
},
);
await triggerWebhook(this.bookmark.id, "deleted", this.ctx.user.id, {
groupId: this.ctx.user.id,
});
if (deleted.changes > 0) {
await this.cleanupAssets();
}
}
}
|