mirror of
https://github.com/thomiceli/opengist.git
synced 2025-06-19 08:27:13 +02:00
Disable self-fork
This commit is contained in:
@ -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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user