add auth token cleanup logic
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import type { Bookmark, BookmarkTag } from "@markone/core/bookmark"
|
||||
import type { Bookmark, BookmarkId, BookmarkTag } from "@markone/core/bookmark"
|
||||
import type { User } from "@markone/core/user"
|
||||
import { Readability } from "@mozilla/readability"
|
||||
import { JSDOM } from "jsdom"
|
||||
@@ -72,6 +72,14 @@ function findBookmark(id: string, user: User): Bookmark | null {
|
||||
return bookmark
|
||||
}
|
||||
|
||||
function deleteBookmark(id: BookmarkId, user: User) {
|
||||
db.query("DELETE FROM bookmarks WHERE user_id = $userId AND id = $id").run({
|
||||
id,
|
||||
userId: user.id,
|
||||
})
|
||||
db.query("DELETE FROM bookmark_tags WHERE bookmark_id = ?").run(id)
|
||||
}
|
||||
|
||||
async function cacheContent(url: string): Promise<CachedContent | null> {
|
||||
const res = await fetch(url).catch(() => {
|
||||
throw new LinkUnreachable()
|
||||
@@ -162,6 +170,7 @@ function findBookmarkTags(bookmark: Bookmark): BookmarkTag[] {
|
||||
export {
|
||||
insertDemoBookmarks,
|
||||
insertBookmark,
|
||||
deleteBookmark,
|
||||
findBookmark,
|
||||
findBookmarkCachedContent,
|
||||
cacheContent,
|
||||
|
Reference in New Issue
Block a user