Skip to content

Instantly share code, notes, and snippets.

@GregRos
Last active October 13, 2022 13:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GregRos/b75e35e046f7f70d50dc4f88dd7afc2b to your computer and use it in GitHub Desktop.
Save GregRos/b75e35e046f7f70d50dc4f88dd7afc2b 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 to update name.")
}
if (perms !== "WRITE" && perms !== "ADMIN") {
throw new Error("Not enough permissions to update squggle.")
}
}
// ... UPDATE CODE ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment