Disable self-fork

This commit is contained in:
Thomas Miceli 2023-03-15 01:01:42 +01:00
parent 0f42ef01b0
commit 12625ed462
No known key found for this signature in database
GPG key ID: D86C6F6390AF050F

View file

@ -424,6 +424,11 @@ func fork(ctx echo.Context) error {
return errorRes(500, "Error checking if gist is already forked", err) return errorRes(500, "Error checking if gist is already forked", err)
} }
if gist.User.ID == currentUser.ID {
addFlash(ctx, "Unable to fork own gists", "error")
return redirect(ctx, "/"+gist.User.Username+"/"+gist.Uuid)
}
if alreadyForked.ID != 0 { if alreadyForked.ID != 0 {
return redirect(ctx, "/"+alreadyForked.User.Username+"/"+alreadyForked.Uuid) return redirect(ctx, "/"+alreadyForked.User.Username+"/"+alreadyForked.Uuid)
} }
@ -455,6 +460,8 @@ func fork(ctx echo.Context) error {
return errorRes(500, "Error incrementing the fork count", err) return errorRes(500, "Error incrementing the fork count", err)
} }
addFlash(ctx, "Gist has been forked", "success")
return redirect(ctx, "/"+currentUser.Username+"/"+newGist.Uuid) return redirect(ctx, "/"+currentUser.Username+"/"+newGist.Uuid)
} }