Fix tablo api update
This commit is contained in:
parent
0af43496aa
commit
ab5e233d22
1 changed files with 15 additions and 6 deletions
|
|
@ -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" });
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue