feat: implement database migrations for wordfilter, DMs, user invites, and site settings while adding video title import utilities.
This commit is contained in:
@@ -2368,6 +2368,9 @@ class CommentSystem {
|
||||
previewItem.classList.remove('cf-uploading');
|
||||
previewItem.dataset.url = url;
|
||||
previewItem.dataset.fileId = fileData.id;
|
||||
previewItem.dataset.dest = fileData.dest;
|
||||
previewItem.dataset.mime = fileData.mime;
|
||||
previewItem.dataset.originalFilename = file.name;
|
||||
previewItem.innerHTML = '';
|
||||
|
||||
if (fileData.mime.startsWith('image/')) {
|
||||
@@ -2855,7 +2858,25 @@ class CommentSystem {
|
||||
const text = textarea.value.trim();
|
||||
const parentId = wrap.dataset.parent || null;
|
||||
|
||||
if (!text.trim()) return;
|
||||
// Collect file IDs and files from upload previews
|
||||
const fileIds = [];
|
||||
const files = [];
|
||||
const previewArea = wrap.querySelector('.comment-file-preview');
|
||||
if (previewArea) {
|
||||
previewArea.querySelectorAll('.cf-preview-item').forEach(item => {
|
||||
if (item.dataset.fileId) {
|
||||
fileIds.push(item.dataset.fileId);
|
||||
files.push({
|
||||
id: parseInt(item.dataset.fileId, 10),
|
||||
dest: item.dataset.dest,
|
||||
mime: item.dataset.mime,
|
||||
original_filename: item.dataset.originalFilename
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (!text && fileIds.length === 0) return;
|
||||
if (submitBtn.classList.contains('loading') || submitBtn.disabled) return;
|
||||
if (wrap._pendingUploads > 0) return;
|
||||
|
||||
@@ -2890,16 +2911,6 @@ class CommentSystem {
|
||||
params.append('content', text);
|
||||
if (videoTime !== null) params.append('video_time', videoTime.toFixed(3));
|
||||
|
||||
// Collect file IDs from upload previews
|
||||
const fileIds = [];
|
||||
const previewArea = wrap.querySelector('.comment-file-preview');
|
||||
if (previewArea) {
|
||||
previewArea.querySelectorAll('.cf-preview-item').forEach(item => {
|
||||
if (item.dataset.fileId) {
|
||||
fileIds.push(item.dataset.fileId);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (fileIds.length > 0) {
|
||||
params.append('file_ids', fileIds.join(','));
|
||||
}
|
||||
@@ -2981,6 +2992,7 @@ class CommentSystem {
|
||||
item_id: this.itemId,
|
||||
parent_id: parentId ? parseInt(parentId, 10) : null,
|
||||
content: text,
|
||||
files: files,
|
||||
created_at: json.comment.created_at || new Date().toISOString(),
|
||||
username: currentUsername,
|
||||
user_id: session.id || null,
|
||||
|
||||
@@ -253,7 +253,7 @@ export default (router, tpl) => {
|
||||
const body = req.post || {};
|
||||
const item_id = parseInt(body.item_id, 10);
|
||||
const parent_id = body.parent_id ? parseInt(body.parent_id, 10) : null;
|
||||
let content = body.content;
|
||||
let content = body.content || '';
|
||||
content = await applyWordFilter(content);
|
||||
const video_time = (body.video_time !== undefined && body.video_time !== '' && !isNaN(parseFloat(body.video_time)))
|
||||
? parseFloat(body.video_time)
|
||||
@@ -261,7 +261,10 @@ export default (router, tpl) => {
|
||||
|
||||
if (cfg.main.development) console.log("DEBUG: Posting comment:", { item_id, parent_id, content: content?.substring(0, 20) });
|
||||
|
||||
if (!content || !content.trim()) {
|
||||
const fileIdsRaw = body.file_ids || '';
|
||||
const fileIds = fileIdsRaw ? fileIdsRaw.split(',').map(id => parseInt(id, 10)).filter(id => !isNaN(id) && id > 0) : [];
|
||||
|
||||
if ((!content || !content.trim()) && fileIds.length === 0) {
|
||||
return res.reply({ body: JSON.stringify({ success: false, message: "Empty comment" }) });
|
||||
}
|
||||
|
||||
@@ -283,7 +286,7 @@ export default (router, tpl) => {
|
||||
item_id,
|
||||
user_id: req.session.id,
|
||||
parent_id: parent_id || null,
|
||||
content: content
|
||||
content: content || ''
|
||||
};
|
||||
if (video_time !== null) insertData.video_time = video_time;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user