fix(api): 🐛 Force text content-type header on all empty responses

Fixes a problem where the content-type would default to application/json
This commit is contained in:
Jesse Wierzbinski 2024-12-07 13:24:24 +01:00
parent 06376cf58a
commit 5074ac788f
No known key found for this signature in database
11 changed files with 13 additions and 12 deletions

View file

@ -146,7 +146,7 @@ export default apiRoute((app) => {
await role.linkUser(targetUser.id); await role.linkUser(targetUser.id);
return context.body(null, 204); return context.text("", 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.body(null, 204); return context.text("", 204);
}); });
}); });

View file

@ -34,6 +34,7 @@ describe(meta.route, () => {
}); });
expect(response.ok).toBe(true); expect(response.ok).toBe(true);
expect(response.headers.get("Content-Type")).not.toContain("json");
}); });
test("should refuse invalid emails", async () => { test("should refuse invalid emails", async () => {

View file

@ -337,6 +337,6 @@ export default apiRoute((app) =>
email: email ?? "", email: email ?? "",
}); });
return context.body(null, 200); return context.text("", 200);
}), }),
); );

View file

@ -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.body(null, 204); return context.text("", 204);
}); });
}); });

View file

@ -68,6 +68,6 @@ export default apiRoute((app) =>
dismissed: true, dismissed: true,
}); });
return context.body(null, 200); return context.text("", 200);
}), }),
); );

View file

@ -47,6 +47,6 @@ export default apiRoute((app) =>
await user.clearAllNotifications(); await user.clearAllNotifications();
return context.body(null, 200); return context.text("", 200);
}), }),
); );

View file

@ -60,6 +60,6 @@ export default apiRoute((app) =>
await user.clearSomeNotifications(ids); await user.clearSomeNotifications(ids);
return context.body(null, 200); return context.text("", 200);
}), }),
); );

View file

@ -226,7 +226,7 @@ export default apiRoute((app) => {
visible, visible,
}); });
return context.body(null, 204); return context.text("", 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.body(null, 204); return context.text("", 204);
}); });
}); });

View file

@ -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.body(null, 204); return context.text("", 204);
}); });
}); });

View file

@ -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.body(null, 200); return context.text("", 200);
}), }),
); );

View file

@ -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.body(null, 204); return context.text("", 204);
}, },
); );
}); });