gohan
This commit is contained in:
@@ -574,6 +574,7 @@ export default (router, tpl) => {
|
||||
SELECT
|
||||
i.slug,
|
||||
i.xd_score,
|
||||
COALESCE(i.visibility, 0) as visibility,
|
||||
(SELECT ta.tag_id FROM tags_assign ta
|
||||
WHERE ta.item_id = i.id AND ta.tag_id = ANY(${[1, 2, cfg.nsfl_tag_id || 3]}::int[])
|
||||
ORDER BY ta.tag_id LIMIT 1) AS rating_tag_id
|
||||
@@ -613,29 +614,30 @@ export default (router, tpl) => {
|
||||
// 1. Thread live update
|
||||
db.notify('comments', JSON.stringify(livePayload));
|
||||
|
||||
// 2. Sidebar activity update
|
||||
// Compute is_long using the full content (not the truncated notifyBody) so the
|
||||
// sidebar renders the correct clamped state immediately on first paint.
|
||||
const activityIsLong = content.length > 120
|
||||
|| content.split('\n').length > 2
|
||||
|| activityFiles.length > 0
|
||||
|| /\[(video|audio|youtube|img)\]|!\[|https?:\/\//i.test(content);
|
||||
db.notify('activity', JSON.stringify({
|
||||
user_id: req.session.id,
|
||||
item_id: item_id,
|
||||
type: 'comment',
|
||||
body: notifyBody,
|
||||
id: commentId,
|
||||
item_rating_class: ratingClass,
|
||||
item_rating_label: ratingLabel,
|
||||
avatar: req.session.avatar,
|
||||
avatar_file: req.session.avatar_file,
|
||||
username: req.session.user,
|
||||
username_color: req.session.username_color,
|
||||
display_name: req.session.display_name || null,
|
||||
files: activityFiles,
|
||||
is_long: activityIsLong
|
||||
}));
|
||||
// 2. Sidebar activity update (only for public items)
|
||||
const itemVisibility = itemQuery[0]?.visibility ?? 0;
|
||||
if (itemVisibility === 0) {
|
||||
const activityIsLong = content.length > 120
|
||||
|| content.split('\n').length > 2
|
||||
|| activityFiles.length > 0
|
||||
|| /\[(video|audio|youtube|img)\]|!\[|https?:\/\//i.test(content);
|
||||
db.notify('activity', JSON.stringify({
|
||||
user_id: req.session.id,
|
||||
item_id: item_id,
|
||||
type: 'comment',
|
||||
body: notifyBody,
|
||||
id: commentId,
|
||||
item_rating_class: ratingClass,
|
||||
item_rating_label: ratingLabel,
|
||||
avatar: req.session.avatar,
|
||||
avatar_file: req.session.avatar_file,
|
||||
username: req.session.user,
|
||||
username_color: req.session.username_color,
|
||||
display_name: req.session.display_name || null,
|
||||
files: activityFiles,
|
||||
is_long: activityIsLong
|
||||
}));
|
||||
}
|
||||
|
||||
// Automatically subscribe user to the thread
|
||||
const subResult = await db`
|
||||
@@ -1024,6 +1026,7 @@ export default (router, tpl) => {
|
||||
WHERE c.is_deleted = false
|
||||
AND i.active = true
|
||||
AND i.is_deleted = false
|
||||
AND COALESCE(i.visibility, 0) = 0
|
||||
AND ${db.unsafe(modequery)}
|
||||
${!req.session && globalfilter ? db`and not exists (select 1 from tags_assign where item_id = i.id and (${db.unsafe(globalfilter)}))` : db``}
|
||||
${excludedTags.length > 0 ? db`and not exists (select 1 from tags_assign where item_id = i.id and tag_id = any(${excludedTags}::int[]))` : db``}
|
||||
|
||||
Reference in New Issue
Block a user