refactor: extract star/notification/badge helpers into database.py and add enrich_items content module

Introduce `update_target_stars`, `get_target_owner_uid`, and `VOTABLE_TARGETS`/`STAR_TARGETS` in database.py; replace inline badge insertion with `award_badge()` and inline notification creation with `create_notification()` across auth, comments, and follow routers; add `enrich_items()` in new content module to centralize post/gist list assembly and remove duplicated enrichment logic from feed and gists routers.
This commit is contained in:
2026-05-23 06:34:13 +00:00
parent ab1121a42a
commit d7d8314da0
34 changed files with 211 additions and 367 deletions
+6 -19
View File
@@ -1,3 +1,5 @@
import { Http } from "./Http.js";
export class VoteManager {
constructor() {
this.initVoteButtons();
@@ -6,37 +8,22 @@ export class VoteManager {
initVoteButtons() {
document.querySelectorAll(".post-action-btn[data-vote]").forEach((btn) => {
btn.addEventListener("click", async () => {
btn.addEventListener("click", () => {
const targetUid = btn.dataset.target;
const targetType = btn.dataset.type || "post";
const value = btn.dataset.vote;
const form = document.createElement("form");
form.method = "POST";
form.action = `/votes/${targetType}/${targetUid}`;
const input = document.createElement("input");
input.type = "hidden";
input.name = "value";
input.value = value;
form.appendChild(input);
document.body.appendChild(form);
form.submit();
Http.postForm(`/votes/${targetType}/${targetUid}`, { value: btn.dataset.vote });
});
});
}
initNotificationDismiss() {
document.querySelectorAll(".notification-dismiss").forEach((btn) => {
btn.addEventListener("click", async () => {
btn.addEventListener("click", () => {
const uid = btn.dataset.uid;
if (!uid) {
return;
}
const form = document.createElement("form");
form.method = "POST";
form.action = `/notifications/mark-read/${uid}`;
document.body.appendChild(form);
form.submit();
Http.postForm(`/notifications/mark-read/${uid}`);
});
});
}