1
0
mirror of https://github.com/thomiceli/opengist synced 2024-11-08 12:55:50 +01:00

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

@ -424,6 +424,11 @@ func fork(ctx echo.Context) error {
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 {
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)
}
addFlash(ctx, "Gist has been forked", "success")
return redirect(ctx, "/"+currentUser.Username+"/"+newGist.Uuid)
}