Changeset 59f0170 in Klonkt for src/routes/posts.js


Ignore:
Timestamp:
06/24/2026 02:26:32 PM (3 months ago)
Author:
Robin Genis <roboburr@…>
Branches:
main
Children:
dc8e9bd
Parents:
2e9773f
Message:

refactor(comments): remove native comments — social is fediverse-only

Removes routes/comments.js + admin-comments.js (+ mounts), the comment section &
reply UI on posts, comment loading in the post route, the admin moderation page +
links, and the per-site comment-moderation settings. The 'From the fediverse'
section is now the post's comment area. The .comment CSS stays (reused there);
the comments table is left in place (dead) so old-data cascade-deletes still work.

Co-Authored-By: Claude <noreply@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/routes/posts.js

    r2e9773f r59f0170  
    710710  }
    711711
    712   // Comments: top-level + replies. Two-pass build: fetch all approved
    713   // comments for the post, then group replies under their parent.
    714   const commentRows = db.prepare(`
    715     SELECT c.id, c.parent_comment_id, c.content, c.status, c.created_at,
    716            c.author_id, u.username AS author_username,
    717            COALESCE(u.avatar_url, (SELECT profile_photo FROM sites WHERE owner_id = u.id AND profile_photo IS NOT NULL ORDER BY is_primary DESC, created_at ASC LIMIT 1)) AS author_avatar
    718     FROM comments c JOIN users u ON u.id = c.author_id
    719     WHERE c.post_id = ? AND c.status = 'approved'
    720     ORDER BY c.created_at ASC
    721   `).all(post.id);
    722   const topLevel = [];
    723   const repliesById = new Map();
    724   for (const c of commentRows) {
    725     if (c.parent_comment_id) {
    726       if (!repliesById.has(c.parent_comment_id)) repliesById.set(c.parent_comment_id, []);
    727       repliesById.get(c.parent_comment_id).push(c);
    728     } else {
    729       topLevel.push(c);
    730     }
    731   }
    732   for (const c of topLevel) c.replies = repliesById.get(c.id) || [];
    733   const totalComments = commentRows.length;
     712  // Native comments removed: social interaction is fediverse-only (see the
     713  // "From the fediverse" section below).
    734714
    735715  // Prev / next chronological (kept for back-compat — "post-nav" feature
     
    818798    olderPost,
    819799    relatedPosts,
    820     comments: topLevel,
    821     totalComments,
    822800    fediverse,
    823801    canManageSite,
Note: See TracChangeset for help on using the changeset viewer.