1
0
Fork 0
mirror of https://git.sr.ht/~roxwize/mipilin synced 2025-05-12 00:03:06 +00:00

Rae from website

Signed-off-by: roxwize <rae@roxwize.xyz>
This commit is contained in:
Rae 5e 2025-01-22 20:34:25 -05:00
parent 453a143bfa
commit a3e6df6ce8
Signed by: rae
GPG key ID: 5B1A0FAB9BAB81EE
13 changed files with 691 additions and 35 deletions

View file

@ -7,7 +7,7 @@ import {
updates,
users
} from "../db/schema.js";
import { and, desc, eq } from "drizzle-orm";
import { and, desc, eq, ne } from "drizzle-orm";
import { getMoods, render, render404, UserStatus } from "./util.js";
import { PgColumn } from "drizzle-orm/pg-core";
import dayjs from "dayjs";
@ -79,10 +79,15 @@ export default async function (app: Express, db: NodePgDatabase) {
.select({
id: journalEntries.id,
title: journalEntries.title,
date: journalEntries.date
date: journalEntries.date,
visibility: journalEntries.visibility
})
.from(journalEntries)
.where(eq(journalEntries.user, user.id))
.where(
user.id === req.session["uid"] || req.session["status"] & UserStatus.MODERATOR
? eq(journalEntries.user, user.id)
: and(eq(journalEntries.user, user.id), ne(journalEntries.visibility, 0))
)
.orderBy(desc(journalEntries.date))
.limit(5)
).map((e) => {
@ -90,6 +95,7 @@ export default async function (app: Express, db: NodePgDatabase) {
id: e.id,
title: e.title,
date: e.date,
visibility: e.visibility,
relativeDate: now.to(e.date)
};
});
@ -115,7 +121,7 @@ export default async function (app: Express, db: NodePgDatabase) {
};
});
if (!isSelf) {
if (!isSelf && userMood) {
userMood.mood = moods[userMood.mood as number];
}