v3: consistent tabs url across app, maxy small fixes
All checks were successful
Build and Publish Docker Image / build-and-push (push) Successful in 42s
All checks were successful
Build and Publish Docker Image / build-and-push (push) Successful in 42s
This commit is contained in:
@@ -1,13 +1,12 @@
|
||||
import { type Dump } from "../model/interfaces.ts";
|
||||
import { db, dumpRowToApi, isDumpRow } from "../model/db.ts";
|
||||
import {
|
||||
db,
|
||||
DUMP_SELECT_COLUMNS as SELECT_COLS,
|
||||
dumpRowToApi,
|
||||
isDumpRow,
|
||||
} from "../model/db.ts";
|
||||
import { UUID_RE } from "../lib/slugify.ts";
|
||||
|
||||
// Mirrors dump-service SELECT_COLS — kept local to avoid a circular import
|
||||
// (dump-service.ts must import relinkBacklinks from this file).
|
||||
const SELECT_COLS =
|
||||
"id, kind, title, slug, comment, user_id, created_at, updated_at, url, rich_content, file_name, file_mime, file_size, vote_count, is_private, custom_thumbnail_mime," +
|
||||
" (SELECT COUNT(*) FROM comments WHERE dump_id = dumps.id AND deleted = 0) as comment_count";
|
||||
|
||||
// Matches http(s) URLs in free text — stops at whitespace or markdown-link
|
||||
// delimiters (so `[text](url)` and `<url>` don't swallow the closing char).
|
||||
const URL_RE = /https?:\/\/[^\s)\]<>"']+/g;
|
||||
|
||||
@@ -5,7 +5,14 @@ import {
|
||||
type Dump,
|
||||
type UpdateDumpRequest,
|
||||
} from "../model/interfaces.ts";
|
||||
import { db, dumpApiToRow, dumpRowToApi, isDumpRow } from "../model/db.ts";
|
||||
import {
|
||||
db,
|
||||
DUMP_SELECT_COLUMNS as SELECT_COLS,
|
||||
DUMP_SELECT_COLUMNS_ALIASED as SELECT_COLS_ALIASED,
|
||||
dumpApiToRow,
|
||||
dumpRowToApi,
|
||||
isDumpRow,
|
||||
} from "../model/db.ts";
|
||||
import { fetchRichContent, isValidHttpUrl } from "./rich-content-service.ts";
|
||||
import {
|
||||
broadcastDumpDeleted,
|
||||
@@ -40,16 +47,6 @@ function titleFromUrl(url: string): string {
|
||||
}
|
||||
}
|
||||
|
||||
const BASE_COLS =
|
||||
"id, kind, title, slug, comment, user_id, created_at, updated_at, url, rich_content, file_name, file_mime, file_size, vote_count, is_private, custom_thumbnail_mime";
|
||||
|
||||
const SELECT_COLS = `${BASE_COLS},
|
||||
(SELECT COUNT(*) FROM comments WHERE dump_id = dumps.id AND deleted = 0) as comment_count`;
|
||||
|
||||
const SELECT_COLS_ALIASED =
|
||||
"d.id, d.kind, d.title, d.slug, d.comment, d.user_id, d.created_at, d.updated_at, d.url, d.rich_content, d.file_name, d.file_mime, d.file_size, d.vote_count, d.is_private, d.custom_thumbnail_mime," +
|
||||
" (SELECT COUNT(*) FROM comments WHERE dump_id = d.id AND deleted = 0) as comment_count";
|
||||
|
||||
export async function createUrlDump(
|
||||
request: CreateUrlDumpRequest,
|
||||
userId: string,
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
} from "./notification-service.ts";
|
||||
import {
|
||||
db,
|
||||
DUMP_SELECT_COLUMNS_ALIASED as SELECT_COLS_ALIASED,
|
||||
dumpRowToApi,
|
||||
isDumpRow,
|
||||
isFollowRow,
|
||||
@@ -21,12 +22,6 @@ import {
|
||||
userRowToApi,
|
||||
} from "../model/db.ts";
|
||||
|
||||
// Mirrors dump-service SELECT_COLS_ALIASED — kept local to avoid circular imports
|
||||
const SELECT_COLS_ALIASED =
|
||||
"d.id, d.kind, d.title, d.slug, d.comment, d.user_id, d.created_at, d.updated_at, d.url, d.rich_content, " +
|
||||
"d.file_name, d.file_mime, d.file_size, d.vote_count, d.is_private, d.custom_thumbnail_mime," +
|
||||
" (SELECT COUNT(*) FROM comments WHERE dump_id = d.id AND deleted = 0) as comment_count";
|
||||
|
||||
// ── Follow / unfollow a user ──────────────────────────────────────────────────
|
||||
|
||||
export function followUser(followerId: string, followedUserId: string): void {
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
} from "../model/interfaces.ts";
|
||||
import {
|
||||
db,
|
||||
DUMP_COLUMNS_ALIASED,
|
||||
dumpRowToApi,
|
||||
isDumpRow,
|
||||
isPlaylistRow,
|
||||
@@ -28,9 +29,6 @@ import {
|
||||
import { makeSlug, UUID_RE } from "../lib/slugify.ts";
|
||||
import { linkAttachments } from "./attachment-service.ts";
|
||||
|
||||
const DUMP_SELECT_COLS =
|
||||
"id, kind, title, slug, comment, user_id, created_at, updated_at, url, rich_content, file_name, file_mime, file_size, vote_count, is_private, custom_thumbnail_mime";
|
||||
|
||||
const PLAYLIST_SELECT = `p.*, u.username as owner_username,
|
||||
(SELECT COUNT(*) FROM playlist_dumps pd WHERE pd.playlist_id = p.id) as dump_count
|
||||
FROM playlists p LEFT JOIN users u ON u.id = p.user_id`;
|
||||
@@ -91,12 +89,11 @@ export function getPlaylist(
|
||||
throw new APIException(APIErrorCode.NOT_FOUND, 404, "Playlist not found");
|
||||
}
|
||||
|
||||
const dumpCols = DUMP_SELECT_COLS.split(", ").map((c) => `d.${c}`).join(", ");
|
||||
const isOwner = requestingUserId === playlist.userId;
|
||||
|
||||
// For public playlists (or when viewed by non-owner), filter out private dumps
|
||||
const rows = db.prepare(
|
||||
`SELECT ${dumpCols},
|
||||
`SELECT ${DUMP_COLUMNS_ALIASED},
|
||||
(SELECT COUNT(*) FROM comments WHERE dump_id = d.id AND deleted = 0) as comment_count
|
||||
FROM dumps d
|
||||
INNER JOIN playlist_dumps pd ON d.id = pd.dump_id
|
||||
|
||||
Reference in New Issue
Block a user