mirror of
https://github.com/versia-pub/server.git
synced 2025-12-06 08:28:19 +01:00
fix(api): 🐛 Correctly return empty body without content-type headers, when returning empty responses
This commit is contained in:
parent
2743528727
commit
06376cf58a
|
|
@ -146,7 +146,7 @@ export default apiRoute((app) => {
|
||||||
|
|
||||||
await role.linkUser(targetUser.id);
|
await role.linkUser(targetUser.id);
|
||||||
|
|
||||||
return context.newResponse(null, 204);
|
return context.body(null, 204);
|
||||||
});
|
});
|
||||||
|
|
||||||
app.openapi(routeDelete, async (context) => {
|
app.openapi(routeDelete, async (context) => {
|
||||||
|
|
@ -186,6 +186,6 @@ export default apiRoute((app) => {
|
||||||
|
|
||||||
await role.unlinkUser(targetUser.id);
|
await role.unlinkUser(targetUser.id);
|
||||||
|
|
||||||
return context.newResponse(null, 204);
|
return context.body(null, 204);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -337,6 +337,6 @@ export default apiRoute((app) =>
|
||||||
email: email ?? "",
|
email: email ?? "",
|
||||||
});
|
});
|
||||||
|
|
||||||
return context.newResponse(null, 200);
|
return context.body(null, 200);
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -352,6 +352,6 @@ export default apiRoute((app) => {
|
||||||
|
|
||||||
await db.delete(Emojis).where(eq(Emojis.id, id));
|
await db.delete(Emojis).where(eq(Emojis.id, id));
|
||||||
|
|
||||||
return context.newResponse(null, 204);
|
return context.body(null, 204);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,6 @@ export default apiRoute((app) =>
|
||||||
dismissed: true,
|
dismissed: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
return context.newResponse(null, 200);
|
return context.body(null, 200);
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,6 @@ export default apiRoute((app) =>
|
||||||
|
|
||||||
await user.clearAllNotifications();
|
await user.clearAllNotifications();
|
||||||
|
|
||||||
return context.newResponse(null, 200);
|
return context.body(null, 200);
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,6 @@ export default apiRoute((app) =>
|
||||||
|
|
||||||
await user.clearSomeNotifications(ids);
|
await user.clearSomeNotifications(ids);
|
||||||
|
|
||||||
return context.newResponse(null, 200);
|
return context.body(null, 200);
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -226,7 +226,7 @@ export default apiRoute((app) => {
|
||||||
visible,
|
visible,
|
||||||
});
|
});
|
||||||
|
|
||||||
return context.newResponse(null, 204);
|
return context.body(null, 204);
|
||||||
});
|
});
|
||||||
|
|
||||||
app.openapi(routeDelete, async (context) => {
|
app.openapi(routeDelete, async (context) => {
|
||||||
|
|
@ -261,6 +261,6 @@ export default apiRoute((app) => {
|
||||||
|
|
||||||
await role.delete();
|
await role.delete();
|
||||||
|
|
||||||
return context.newResponse(null, 204);
|
return context.body(null, 204);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -343,6 +343,6 @@ export default apiRoute((app) => {
|
||||||
.delete(Filters)
|
.delete(Filters)
|
||||||
.where(and(eq(Filters.userId, user.id), eq(Filters.id, id)));
|
.where(and(eq(Filters.userId, user.id), eq(Filters.id, id)));
|
||||||
|
|
||||||
return context.newResponse(null, 204);
|
return context.body(null, 204);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ export default apiRoute((app) =>
|
||||||
ip: context.env.ip ?? null,
|
ip: context.env.ip ?? null,
|
||||||
});
|
});
|
||||||
|
|
||||||
return context.newResponse(
|
return context.body(
|
||||||
"Request processing initiated.\nImplement the Instance Messaging Extension to receive any eventual feedback (errors, etc.)",
|
"Request processing initiated.\nImplement the Instance Messaging Extension to receive any eventual feedback (errors, etc.)",
|
||||||
200,
|
200,
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@ export default apiRoute((app) =>
|
||||||
}
|
}
|
||||||
|
|
||||||
// Can't directly copy file into Response because this crashes Bun for now
|
// Can't directly copy file into Response because this crashes Bun for now
|
||||||
return context.newResponse(buffer, 200, {
|
return context.body(buffer, 200, {
|
||||||
"Content-Type": file.type || "application/octet-stream",
|
"Content-Type": file.type || "application/octet-stream",
|
||||||
"Content-Length": `${file.size - start}`,
|
"Content-Length": `${file.size - start}`,
|
||||||
"Content-Range": `bytes ${start}-${end}/${file.size}`,
|
"Content-Range": `bytes ${start}-${end}/${file.size}`,
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,7 @@ export default apiRoute((app) =>
|
||||||
.get("Content-Disposition")
|
.get("Content-Disposition")
|
||||||
?.match(/filename="(.+)"/)?.[1] || id.split("/").pop();
|
?.match(/filename="(.+)"/)?.[1] || id.split("/").pop();
|
||||||
|
|
||||||
return context.newResponse(media.body, media.status as StatusCode, {
|
return context.body(media.body, media.status as StatusCode, {
|
||||||
"Content-Type":
|
"Content-Type":
|
||||||
media.headers.get("Content-Type") || "application/octet-stream",
|
media.headers.get("Content-Type") || "application/octet-stream",
|
||||||
"Content-Length": media.headers.get("Content-Length") || "0",
|
"Content-Length": media.headers.get("Content-Length") || "0",
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,6 @@ export default apiRoute((app) =>
|
||||||
getLogger(["federation", "messaging"])
|
getLogger(["federation", "messaging"])
|
||||||
.info`Received message via ${chalk.bold("Instance Messaging")}:\n${content}`;
|
.info`Received message via ${chalk.bold("Instance Messaging")}:\n${content}`;
|
||||||
|
|
||||||
return context.newResponse(null, 200);
|
return context.body(null, 200);
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -116,7 +116,7 @@ export default apiRoute((app) =>
|
||||||
ip: context.env.ip ?? null,
|
ip: context.env.ip ?? null,
|
||||||
});
|
});
|
||||||
|
|
||||||
return context.newResponse(
|
return context.body(
|
||||||
"Request processing initiated.\nImplement the Instance Messaging Extension to receive any eventual feedback (errors, etc.)",
|
"Request processing initiated.\nImplement the Instance Messaging Extension to receive any eventual feedback (errors, etc.)",
|
||||||
200,
|
200,
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ export const bait = createMiddleware(async (context, next) => {
|
||||||
if (requestIp?.address) {
|
if (requestIp?.address) {
|
||||||
for (const ip of config.http.bait.bait_ips) {
|
for (const ip of config.http.bait.bait_ips) {
|
||||||
if (matches(ip, requestIp.address)) {
|
if (matches(ip, requestIp.address)) {
|
||||||
return context.newResponse(file.stream());
|
return context.body(file.stream());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -43,7 +43,7 @@ export const bait = createMiddleware(async (context, next) => {
|
||||||
|
|
||||||
for (const agent of config.http.bait.bait_user_agents) {
|
for (const agent of config.http.bait.bait_user_agents) {
|
||||||
if (new RegExp(agent).test(ua)) {
|
if (new RegExp(agent).test(ua)) {
|
||||||
return context.newResponse(file.stream());
|
return context.body(file.stream());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -201,7 +201,7 @@ export default (plugin: PluginType): void => {
|
||||||
.delete(OpenIdAccounts)
|
.delete(OpenIdAccounts)
|
||||||
.where(eq(OpenIdAccounts.id, account.id));
|
.where(eq(OpenIdAccounts.id, account.id));
|
||||||
|
|
||||||
return context.newResponse(null, 204);
|
return context.body(null, 204);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue