|
1 |
| -import { and, asc, count, desc, eq, gt, like, lt, or } from "drizzle-orm"; |
2 |
| -import Elysia, { t } from "elysia"; |
3 |
| -import { XMLParser } from "fast-xml-parser"; |
| 1 | +import {and, asc, count, desc, eq, gt, like, lt, or} from "drizzle-orm"; |
| 2 | +import Elysia, {t} from "elysia"; |
| 3 | +import {XMLParser} from "fast-xml-parser"; |
4 | 4 | import html2md from 'html-to-md';
|
5 | 5 | import type {DB} from "../_worker";
|
6 | 6 | import {feeds, visits} from "../db/schema";
|
@@ -231,6 +231,16 @@ export function FeedService() {
|
231 | 231 | id_num = parseInt(id);
|
232 | 232 | }
|
233 | 233 |
|
| 234 | + const feed = await db.query.feeds.findFirst({ |
| 235 | + where: eq(feeds.id, id_num), |
| 236 | + columns: {createdAt: true}, |
| 237 | + }); |
| 238 | + if (!feed) { |
| 239 | + set.status = 404; |
| 240 | + return "Not found"; |
| 241 | + } |
| 242 | + const created_at = feed.createdAt; |
| 243 | + |
234 | 244 | const cache = PublicCache();
|
235 | 245 | function formatAndCacheData(
|
236 | 246 | feed: any,
|
@@ -270,9 +280,9 @@ export function FeedService() {
|
270 | 280 | const tempPreviousFeed = await db.query.feeds.findFirst({
|
271 | 281 | where: and(
|
272 | 282 | and(eq(feeds.draft, 0), eq(feeds.listed, 1)),
|
273 |
| - lt(feeds.id, id_num), |
| 283 | + lt(feeds.createdAt, created_at), |
274 | 284 | ),
|
275 |
| - orderBy: [desc(feeds.id)], |
| 285 | + orderBy: [desc(feeds.createdAt)], |
276 | 286 | with: {
|
277 | 287 | hashtags: {
|
278 | 288 | columns: {},
|
@@ -300,9 +310,9 @@ export function FeedService() {
|
300 | 310 | const tempNextFeed = await db.query.feeds.findFirst({
|
301 | 311 | where: and(
|
302 | 312 | and(eq(feeds.draft, 0), eq(feeds.listed, 1)),
|
303 |
| - gt(feeds.id, id_num), |
| 313 | + gt(feeds.createdAt, created_at), |
304 | 314 | ),
|
305 |
| - orderBy: [asc(feeds.id)], |
| 315 | + orderBy: [asc(feeds.createdAt)], |
306 | 316 | with: {
|
307 | 317 | hashtags: {
|
308 | 318 | columns: {},
|
|
0 commit comments