Skip to content

Instantly share code, notes, and snippets.

@GregRos
Created October 13, 2022 12:57
Show Gist options
  • Save GregRos/b65d41d2696e4010d8345868ed7aa70a to your computer and use it in GitHub Desktop.
Save GregRos/b65d41d2696e4010d8345868ed7aa70a to your computer and use it in GitHub Desktop.
// Updates the squggle by id
export async function updateSquggle(data) {
const owner = await getSquggleOwnerInfo(data.id)
if (owner.id !== USER) {
if (!owner.isTeam) {
throw new Error("Owner not a team")
}
const perms = await getUserTeamPermissions(owner.id)
if (!perms) {
throw new Error("User not member of team")
}
if ("name" in data && perms !== "ADMIN") {
throw new Error("Not enough permissions")
}
if (perms !== "WRITE" && perms !== "ADMIN") {
throw new Error("Not enough permissions")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment