Ensuring the flagging post has a message or post id

This commit is contained in:
Keith Stevens
2023-01-11 16:36:40 +09:00
parent f4d0ad1cc8
commit 454f332823
2 changed files with 7 additions and 3 deletions
@@ -16,7 +16,7 @@ export function MessageTableEntry(props: MessageTableEntryProps) {
return (
<div>
<FlaggableElement text={item.text} post_id={item.id} key={`flag_${item.id}`}>
<FlaggableElement text={item.text} message_id={item.message_id} post_id={item.id} key={`flag_${item.id}`}>
<HStack>
<Avatar
size="sm"
+6 -2
View File
@@ -6,7 +6,7 @@ import { withoutRole } from "src/lib/auth";
*/
const handler = withoutRole("banned", async (req, res, token) => {
// Parse out the local message_id, task ID and the interaction contents.
const { message_id, label_map, text } = await JSON.parse(req.body);
const { message_id, post_id, label_map, text } = await JSON.parse(req.body);
const interactionRes = await fetch(`${process.env.FASTAPI_URL}/api/v1/text_labels`, {
method: "POST",
@@ -16,7 +16,7 @@ const handler = withoutRole("banned", async (req, res, token) => {
},
body: JSON.stringify({
type: "text_labels",
message_id: message_id,
message_id: message_id || post_id,
labels: label_map,
text: text,
user: {
@@ -26,6 +26,10 @@ const handler = withoutRole("banned", async (req, res, token) => {
},
}),
});
if (interactionRes.status !== 204) {
const r = await interactionRes.json();
console.error(JSON.stringify(r));
}
res.status(interactionRes.status).end();
});