Fix tablo api update

This commit is contained in:
Arthur Belleville 2025-10-11 10:31:03 +02:00
parent 0af43496aa
commit ab5e233d22
No known key found for this signature in database

View file

@ -133,7 +133,7 @@ tabloRouter.post("/create-and-invite", async (c) => {
.single(); .single();
if (ownerError || !ownerData || invitedUserError || !invitedUser) { if (ownerError || !ownerData || invitedUserError || !invitedUser) {
return c.json({ error: "owner_id is incorrect" }, 400); return c.json({ error: "owner_id or invited_user_id is incorrect" }, 400);
} }
const ownerDataTyped = ownerData as { const ownerDataTyped = ownerData as {
@ -306,15 +306,24 @@ tabloRouter.patch("/update", async (c) => {
const updatedTablo = update as Tables<"tablos">; const updatedTablo = update as Tables<"tablos">;
const isUpdatingName =
tablo.name !== undefined && tablo.name !== updatedTablo.name;
if (error) { if (error) {
return c.json({ error: error.message }, 500); return c.json({ error: error.message }, 500);
} }
const channel = streamServerClient.channel("messaging", updatedTablo.id); if (isUpdatingName) {
await channel.update({ const channel = streamServerClient.channel("messaging", updatedTablo.id);
// @ts-ignore try {
name: updatedTablo.name, await channel.update({
}); // @ts-ignore
name: updatedTablo.name,
});
} catch (error) {
console.error("error updating channel", error);
}
}
return c.json({ message: "Tablo updated successfully" }); return c.json({ message: "Tablo updated successfully" });
}); });