Fix api invite
This commit is contained in:
parent
ae7e5fe722
commit
def9e38341
1 changed files with 7 additions and 3 deletions
|
|
@ -376,7 +376,7 @@ tabloRouter.post("/invite/:tabloId", regularUserCheckMiddleware, checkTabloAdmin
|
|||
.from("tablos")
|
||||
.select("name")
|
||||
.eq("id", tabloId)
|
||||
.single();
|
||||
.maybeSingle();
|
||||
|
||||
if (tabloError || !tablo) {
|
||||
return c.json({ error: "Tablo not found" }, 404);
|
||||
|
|
@ -388,7 +388,7 @@ tabloRouter.post("/invite/:tabloId", regularUserCheckMiddleware, checkTabloAdmin
|
|||
.from("user_introductions")
|
||||
.select("config")
|
||||
.eq("user_id", sender.id)
|
||||
.single();
|
||||
.maybeSingle();
|
||||
|
||||
if (introError) {
|
||||
return c.json({ error: introError.message }, 500);
|
||||
|
|
@ -404,6 +404,10 @@ tabloRouter.post("/invite/:tabloId", regularUserCheckMiddleware, checkTabloAdmin
|
|||
});
|
||||
|
||||
if (error) {
|
||||
// Check if this is a duplicate invite error
|
||||
if (error.code === "23505") {
|
||||
return c.json({ error: "User has already been invited to this tablo" }, 409);
|
||||
}
|
||||
return c.json({ error: error.message }, 500);
|
||||
}
|
||||
|
||||
|
|
@ -497,7 +501,7 @@ tabloRouter.post("/invite/:tabloId", regularUserCheckMiddleware, checkTabloAdmin
|
|||
.select("id")
|
||||
.eq("tablo_id", tabloId)
|
||||
.eq("user_id", recipientUser.id)
|
||||
.single();
|
||||
.maybeSingle();
|
||||
|
||||
if (existingAccessError) {
|
||||
return c.json({ error: existingAccessError.message }, 500);
|
||||
|
|
|
|||
Loading…
Reference in a new issue