umlaut fix
This commit is contained in:
@@ -105,7 +105,7 @@ class CommentSystem {
|
|||||||
try {
|
try {
|
||||||
// Decode Base64 for safe template transfer
|
// Decode Base64 for safe template transfer
|
||||||
const raw = dataEl.textContent.trim();
|
const raw = dataEl.textContent.trim();
|
||||||
const json = atob(raw);
|
const json = new TextDecoder().decode(Uint8Array.from(atob(raw), c => c.charCodeAt(0)));
|
||||||
const comments = JSON.parse(json);
|
const comments = JSON.parse(json);
|
||||||
|
|
||||||
const subEl = document.getElementById('initial-subscription');
|
const subEl = document.getElementById('initial-subscription');
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ export default (router, tpl) => {
|
|||||||
// Require login
|
// Require login
|
||||||
if (!req.session) {
|
if (!req.session) {
|
||||||
return res.reply({
|
return res.reply({
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json; charset=utf-8' },
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
success: true,
|
success: true,
|
||||||
comments: [],
|
comments: [],
|
||||||
@@ -39,7 +39,7 @@ export default (router, tpl) => {
|
|||||||
|
|
||||||
// Transform for frontend if needed, or send as is
|
// Transform for frontend if needed, or send as is
|
||||||
return res.reply({
|
return res.reply({
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json; charset=utf-8' },
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
success: true,
|
success: true,
|
||||||
comments,
|
comments,
|
||||||
@@ -84,7 +84,7 @@ export default (router, tpl) => {
|
|||||||
if (!req.session || !req.session.user) {
|
if (!req.session || !req.session.user) {
|
||||||
if (isJson) {
|
if (isJson) {
|
||||||
return res.reply({
|
return res.reply({
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json; charset=utf-8' },
|
||||||
body: JSON.stringify({ success: false, require_login: true })
|
body: JSON.stringify({ success: false, require_login: true })
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@@ -132,7 +132,7 @@ export default (router, tpl) => {
|
|||||||
|
|
||||||
if (isJson) {
|
if (isJson) {
|
||||||
return res.reply({
|
return res.reply({
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json; charset=utf-8' },
|
||||||
body: JSON.stringify({ success: true, comments: processedComments })
|
body: JSON.stringify({ success: true, comments: processedComments })
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -201,13 +201,10 @@ export default (router, tpl) => {
|
|||||||
const mentionedNames = [...new Set(matches.map(m => m[1]))];
|
const mentionedNames = [...new Set(matches.map(m => m[1]))];
|
||||||
const lowerNames = mentionedNames.map(n => n.toLowerCase());
|
const lowerNames = mentionedNames.map(n => n.toLowerCase());
|
||||||
|
|
||||||
console.log("DEBUG: Mentions found:", mentionedNames);
|
|
||||||
|
|
||||||
let mentionedUsers = [];
|
let mentionedUsers = [];
|
||||||
if (lowerNames.length > 0) {
|
if (lowerNames.length > 0) {
|
||||||
// Fetch IDs via login column (lowercase)
|
// Fetch IDs via login column (lowercase)
|
||||||
mentionedUsers = await db`SELECT id, user FROM "user" WHERE login IN ${db(lowerNames)}`;
|
mentionedUsers = await db`SELECT id, user FROM "user" WHERE login IN ${db(lowerNames)}`;
|
||||||
console.log("DEBUG: Users resolved:", mentionedUsers);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. Get parent author
|
// 2. Get parent author
|
||||||
@@ -263,7 +260,7 @@ export default (router, tpl) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return res.reply({
|
return res.reply({
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json; charset=utf-8' },
|
||||||
body: JSON.stringify({ success: true, comment: newComment[0] })
|
body: JSON.stringify({ success: true, comment: newComment[0] })
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -295,7 +292,7 @@ export default (router, tpl) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return res.reply({
|
return res.reply({
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json; charset=utf-8' },
|
||||||
body: JSON.stringify({ success: true, subscribed })
|
body: JSON.stringify({ success: true, subscribed })
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -319,7 +316,7 @@ export default (router, tpl) => {
|
|||||||
await db`UPDATE comments SET is_deleted = true, content = '[deleted]' WHERE id = ${commentId}`;
|
await db`UPDATE comments SET is_deleted = true, content = '[deleted]' WHERE id = ${commentId}`;
|
||||||
|
|
||||||
return res.reply({
|
return res.reply({
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json; charset=utf-8' },
|
||||||
body: JSON.stringify({ success: true })
|
body: JSON.stringify({ success: true })
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -347,7 +344,7 @@ export default (router, tpl) => {
|
|||||||
await db`UPDATE comments SET content = ${content}, updated_at = NOW() WHERE id = ${commentId}`;
|
await db`UPDATE comments SET content = ${content}, updated_at = NOW() WHERE id = ${commentId}`;
|
||||||
|
|
||||||
return res.reply({
|
return res.reply({
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json; charset=utf-8' },
|
||||||
body: JSON.stringify({ success: true })
|
body: JSON.stringify({ success: true })
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -370,7 +367,7 @@ export default (router, tpl) => {
|
|||||||
await db`UPDATE comments SET is_pinned = ${newPinned} WHERE id = ${commentId}`;
|
await db`UPDATE comments SET is_pinned = ${newPinned} WHERE id = ${commentId}`;
|
||||||
|
|
||||||
return res.reply({
|
return res.reply({
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json; charset=utf-8' },
|
||||||
body: JSON.stringify({ success: true, is_pinned: newPinned })
|
body: JSON.stringify({ success: true, is_pinned: newPinned })
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -393,7 +390,7 @@ export default (router, tpl) => {
|
|||||||
await db`UPDATE items SET is_comments_locked = ${newLocked} WHERE id = ${itemId}`;
|
await db`UPDATE items SET is_comments_locked = ${newLocked} WHERE id = ${itemId}`;
|
||||||
|
|
||||||
return res.reply({
|
return res.reply({
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json; charset=utf-8' },
|
||||||
body: JSON.stringify({ success: true, is_locked: newLocked })
|
body: JSON.stringify({ success: true, is_locked: newLocked })
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ export default (router, tpl) => {
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
return res.reply({
|
return res.reply({
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json; charset=utf-8' },
|
||||||
body: JSON.stringify({ success: true, notifications })
|
body: JSON.stringify({ success: true, notifications })
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -36,7 +36,7 @@ export default (router, tpl) => {
|
|||||||
try {
|
try {
|
||||||
await db`UPDATE notifications SET is_read = true WHERE user_id = ${req.session.id}`;
|
await db`UPDATE notifications SET is_read = true WHERE user_id = ${req.session.id}`;
|
||||||
return res.reply({
|
return res.reply({
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json; charset=utf-8' },
|
||||||
body: JSON.stringify({ success: true })
|
body: JSON.stringify({ success: true })
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -51,7 +51,7 @@ export default (router, tpl) => {
|
|||||||
try {
|
try {
|
||||||
await db`UPDATE notifications SET is_read = true WHERE id = ${id} AND user_id = ${req.session.id}`;
|
await db`UPDATE notifications SET is_read = true WHERE id = ${id} AND user_id = ${req.session.id}`;
|
||||||
return res.reply({
|
return res.reply({
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json; charset=utf-8' },
|
||||||
body: JSON.stringify({ success: true })
|
body: JSON.stringify({ success: true })
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
Reference in New Issue
Block a user