mirror of
https://github.com/versia-pub/server.git
synced 2025-12-06 16:38:19 +01:00
Fix for follower/following timelines being wrong
This commit is contained in:
parent
8bda61e099
commit
342a8011f1
|
|
@ -1,7 +1,8 @@
|
|||
import { apiRoute, applyConfig } from "@api";
|
||||
import { errorResponse, jsonResponse } from "@response";
|
||||
import { fetchTimeline } from "@timelines";
|
||||
import { client } from "~database/datasource";
|
||||
import { userToAPI } from "~database/entities/User";
|
||||
import { type UserWithRelations, userToAPI } from "~database/entities/User";
|
||||
import { userRelations } from "~database/entities/relations";
|
||||
|
||||
export const meta = applyConfig({
|
||||
|
|
@ -40,7 +41,9 @@ export default apiRoute<{
|
|||
|
||||
if (!user) return errorResponse("User not found", 404);
|
||||
|
||||
const objects = await client.user.findMany({
|
||||
const { objects, link } = await fetchTimeline<UserWithRelations>(
|
||||
client.user,
|
||||
{
|
||||
where: {
|
||||
relationships: {
|
||||
some: {
|
||||
|
|
@ -59,23 +62,15 @@ export default apiRoute<{
|
|||
orderBy: {
|
||||
id: "desc",
|
||||
},
|
||||
});
|
||||
|
||||
// Constuct HTTP Link header (next and prev)
|
||||
const linkHeader = [];
|
||||
if (objects.length > 0) {
|
||||
const urlWithoutQuery = req.url.split("?")[0];
|
||||
linkHeader.push(
|
||||
`<${urlWithoutQuery}?max_id=${objects.at(-1)?.id}>; rel="next"`,
|
||||
`<${urlWithoutQuery}?min_id=${objects[0].id}>; rel="prev"`,
|
||||
},
|
||||
req,
|
||||
);
|
||||
}
|
||||
|
||||
return jsonResponse(
|
||||
await Promise.all(objects.map((object) => userToAPI(object))),
|
||||
200,
|
||||
{
|
||||
Link: linkHeader.join(", "),
|
||||
Link: link,
|
||||
},
|
||||
);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import { apiRoute, applyConfig } from "@api";
|
||||
import { errorResponse, jsonResponse } from "@response";
|
||||
import { fetchTimeline } from "@timelines";
|
||||
import { client } from "~database/datasource";
|
||||
import { userToAPI } from "~database/entities/User";
|
||||
import { userToAPI, type UserWithRelations } from "~database/entities/User";
|
||||
import { userRelations } from "~database/entities/relations";
|
||||
|
||||
export const meta = applyConfig({
|
||||
|
|
@ -40,7 +41,9 @@ export default apiRoute<{
|
|||
|
||||
if (!user) return errorResponse("User not found", 404);
|
||||
|
||||
const objects = await client.user.findMany({
|
||||
const { objects, link } = await fetchTimeline<UserWithRelations>(
|
||||
client.user,
|
||||
{
|
||||
where: {
|
||||
relationshipSubjects: {
|
||||
some: {
|
||||
|
|
@ -59,23 +62,15 @@ export default apiRoute<{
|
|||
orderBy: {
|
||||
id: "desc",
|
||||
},
|
||||
});
|
||||
|
||||
// Constuct HTTP Link header (next and prev)
|
||||
const linkHeader = [];
|
||||
if (objects.length > 0) {
|
||||
const urlWithoutQuery = req.url.split("?")[0];
|
||||
linkHeader.push(
|
||||
`<${urlWithoutQuery}?max_id=${objects.at(-1)?.id}>; rel="next"`,
|
||||
`<${urlWithoutQuery}?min_id=${objects[0].id}>; rel="prev"`,
|
||||
},
|
||||
req,
|
||||
);
|
||||
}
|
||||
|
||||
return jsonResponse(
|
||||
await Promise.all(objects.map((object) => userToAPI(object))),
|
||||
200,
|
||||
{
|
||||
Link: linkHeader.join(", "),
|
||||
Link: link,
|
||||
},
|
||||
);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ export default apiRoute<{
|
|||
since_id,
|
||||
limit = "20",
|
||||
exclude_reblogs,
|
||||
only_media = false,
|
||||
pinned,
|
||||
} = extraData.parsedRequest;
|
||||
|
||||
|
|
@ -70,6 +71,8 @@ export default apiRoute<{
|
|||
id: user.id,
|
||||
},
|
||||
},
|
||||
// If only_media is true, only return statuses with attachments
|
||||
attachments: only_media ? { some: {} } : undefined,
|
||||
id: {
|
||||
lt: max_id,
|
||||
gt: min_id,
|
||||
|
|
|
|||
Loading…
Reference in a new issue