gfsd
This commit is contained in:
+51
-1
@@ -881,7 +881,7 @@ export const handleUpload = async (req, res, self) => {
|
||||
const subSize = subFile.data.length;
|
||||
const subItemSlug = lib.generateSlug(11);
|
||||
|
||||
await db`
|
||||
const insertedSub = await db`
|
||||
INSERT INTO album_items ${db({
|
||||
item_id: itemid,
|
||||
dest: subFilename,
|
||||
@@ -894,7 +894,57 @@ export const handleUpload = async (req, res, self) => {
|
||||
order_index: i,
|
||||
slug: subItemSlug
|
||||
}, 'item_id', 'dest', 'mime', 'size', 'checksum', 'phash', 'width', 'height', 'order_index', 'slug')}
|
||||
RETURNING id
|
||||
`;
|
||||
const subItemId = insertedSub?.[0]?.id;
|
||||
|
||||
// Process any per-subf0ck tags passed in parts
|
||||
const rawSubTags = parts[`subf0ck_tags_${i}`] || parts[`subtags_${i}`];
|
||||
if (subItemId && rawSubTags) {
|
||||
const parsedSubTags = String(rawSubTags)
|
||||
.split(/[,;\n]+/)
|
||||
.map(t => t.trim())
|
||||
.filter(t => t.length > 0 && t.length <= 85 && !['sfw', 'nsfw', 'nsfl'].includes(t.toLowerCase()));
|
||||
|
||||
for (const sTag of parsedSubTags) {
|
||||
try {
|
||||
let tagRow = await db`SELECT id FROM tags WHERE normalized = slugify(${sTag}) LIMIT 1`;
|
||||
if (tagRow.length === 0) {
|
||||
await db`INSERT INTO tags ${db({ tag: sTag }, 'tag')}`;
|
||||
tagRow = await db`SELECT id FROM tags WHERE normalized = slugify(${sTag}) LIMIT 1`;
|
||||
}
|
||||
if (tagRow.length > 0) {
|
||||
const sTagId = tagRow[0].id;
|
||||
await db`
|
||||
INSERT INTO album_items_tags_assign (album_item_id, tag_id, user_id)
|
||||
VALUES (${subItemId}, ${sTagId}, ${req.session.id})
|
||||
ON CONFLICT DO NOTHING
|
||||
`;
|
||||
await db`
|
||||
INSERT INTO tags_assign (item_id, tag_id, user_id)
|
||||
VALUES (${itemid}, ${sTagId}, ${req.session.id})
|
||||
ON CONFLICT DO NOTHING
|
||||
`;
|
||||
}
|
||||
} catch (stErr) {
|
||||
console.warn(`[UPLOAD] Error assigning tag "${sTag}" to subf0ck ${subItemId}:`, stErr.message);
|
||||
}
|
||||
}
|
||||
} else if (subItemId && i === 0 && tags && tags.length > 0) {
|
||||
// Backfill initial post tags to cover subf0ck
|
||||
for (const sTag of tags) {
|
||||
try {
|
||||
let tagRow = await db`SELECT id FROM tags WHERE normalized = slugify(${sTag}) LIMIT 1`;
|
||||
if (tagRow.length > 0) {
|
||||
await db`
|
||||
INSERT INTO album_items_tags_assign (album_item_id, tag_id, user_id)
|
||||
VALUES (${subItemId}, ${tagRow[0].id}, ${req.session.id})
|
||||
ON CONFLICT DO NOTHING
|
||||
`;
|
||||
}
|
||||
} catch (_) {}
|
||||
}
|
||||
}
|
||||
|
||||
// Generate thumbnail for album item filmstrip
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user