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();
|
||||
|
||||
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 {
|
||||
|
|
@ -306,15 +306,24 @@ tabloRouter.patch("/update", async (c) => {
|
|||
|
||||
const updatedTablo = update as Tables<"tablos">;
|
||||
|
||||
const isUpdatingName =
|
||||
tablo.name !== undefined && tablo.name !== updatedTablo.name;
|
||||
|
||||
if (error) {
|
||||
return c.json({ error: error.message }, 500);
|
||||
}
|
||||
|
||||
const channel = streamServerClient.channel("messaging", updatedTablo.id);
|
||||
await channel.update({
|
||||
// @ts-ignore
|
||||
name: updatedTablo.name,
|
||||
});
|
||||
if (isUpdatingName) {
|
||||
const channel = streamServerClient.channel("messaging", updatedTablo.id);
|
||||
try {
|
||||
await channel.update({
|
||||
// @ts-ignore
|
||||
name: updatedTablo.name,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("error updating channel", error);
|
||||
}
|
||||
}
|
||||
|
||||
return c.json({ message: "Tablo updated successfully" });
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue