mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
@@ -243,7 +243,7 @@ func prepareUserInfo(ctx *context.Context) *user_model.User {
|
||||
ctx.ServerError("auth.HasTwoFactorByUID", err)
|
||||
return nil
|
||||
}
|
||||
hasWebAuthn, err := auth.HasWebAuthnRegistrationsByUID(u.ID)
|
||||
hasWebAuthn, err := auth.HasWebAuthnRegistrationsByUID(ctx, u.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("auth.HasWebAuthnRegistrationsByUID", err)
|
||||
return nil
|
||||
@@ -421,13 +421,13 @@ func EditUserPost(ctx *context.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
wn, err := auth.GetWebAuthnCredentialsByUID(u.ID)
|
||||
wn, err := auth.GetWebAuthnCredentialsByUID(ctx, u.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("auth.GetTwoFactorByUID", err)
|
||||
return
|
||||
}
|
||||
for _, cred := range wn {
|
||||
if _, err := auth.DeleteCredential(cred.ID, u.ID); err != nil {
|
||||
if _, err := auth.DeleteCredential(ctx, cred.ID, u.ID); err != nil {
|
||||
ctx.ServerError("auth.DeleteCredential", err)
|
||||
return
|
||||
}
|
||||
|
@@ -243,7 +243,7 @@ func SignInPost(ctx *context.Context) {
|
||||
}
|
||||
|
||||
// Check if the user has webauthn registration
|
||||
hasWebAuthnTwofa, err := auth.HasWebAuthnRegistrationsByUID(u.ID)
|
||||
hasWebAuthnTwofa, err := auth.HasWebAuthnRegistrationsByUID(ctx, u.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("UserSignIn", err)
|
||||
return
|
||||
|
@@ -185,7 +185,7 @@ func linkAccount(ctx *context.Context, u *user_model.User, gothUser goth.User, r
|
||||
}
|
||||
|
||||
// If WebAuthn is enrolled -> Redirect to WebAuthn instead
|
||||
regs, err := auth.GetWebAuthnCredentialsByUID(u.ID)
|
||||
regs, err := auth.GetWebAuthnCredentialsByUID(ctx, u.ID)
|
||||
if err == nil && len(regs) > 0 {
|
||||
ctx.Redirect(setting.AppSubURL + "/user/webauthn")
|
||||
return
|
||||
|
@@ -237,7 +237,7 @@ func newAccessTokenResponse(ctx go_context.Context, grant *auth.OAuth2Grant, ser
|
||||
idToken.EmailVerified = user.IsActive
|
||||
}
|
||||
if grant.ScopeContains("groups") {
|
||||
groups, err := getOAuthGroupsForUser(user)
|
||||
groups, err := getOAuthGroupsForUser(ctx, user)
|
||||
if err != nil {
|
||||
log.Error("Error getting groups: %v", err)
|
||||
return nil, &AccessTokenError{
|
||||
@@ -291,7 +291,7 @@ func InfoOAuth(ctx *context.Context) {
|
||||
Picture: ctx.Doer.AvatarLink(ctx),
|
||||
}
|
||||
|
||||
groups, err := getOAuthGroupsForUser(ctx.Doer)
|
||||
groups, err := getOAuthGroupsForUser(ctx, ctx.Doer)
|
||||
if err != nil {
|
||||
ctx.ServerError("Oauth groups for user", err)
|
||||
return
|
||||
@@ -303,8 +303,8 @@ func InfoOAuth(ctx *context.Context) {
|
||||
|
||||
// returns a list of "org" and "org:team" strings,
|
||||
// that the given user is a part of.
|
||||
func getOAuthGroupsForUser(user *user_model.User) ([]string, error) {
|
||||
orgs, err := org_model.GetUserOrgsList(user)
|
||||
func getOAuthGroupsForUser(ctx go_context.Context, user *user_model.User) ([]string, error) {
|
||||
orgs, err := org_model.GetUserOrgsList(ctx, user)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("GetUserOrgList: %w", err)
|
||||
}
|
||||
@@ -1197,7 +1197,7 @@ func handleOAuth2SignIn(ctx *context.Context, source *auth.Source, u *user_model
|
||||
}
|
||||
|
||||
// If WebAuthn is enrolled -> Redirect to WebAuthn instead
|
||||
regs, err := auth.GetWebAuthnCredentialsByUID(u.ID)
|
||||
regs, err := auth.GetWebAuthnCredentialsByUID(ctx, u.ID)
|
||||
if err == nil && len(regs) > 0 {
|
||||
ctx.Redirect(setting.AppSubURL + "/user/webauthn")
|
||||
return
|
||||
|
@@ -55,7 +55,7 @@ func WebAuthnLoginAssertion(ctx *context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
exists, err := auth.ExistsWebAuthnCredentialsForUID(user.ID)
|
||||
exists, err := auth.ExistsWebAuthnCredentialsForUID(ctx, user.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("UserSignIn", err)
|
||||
return
|
||||
@@ -127,14 +127,14 @@ func WebAuthnLoginAssertionPost(ctx *context.Context) {
|
||||
}
|
||||
|
||||
// Success! Get the credential and update the sign count with the new value we received.
|
||||
dbCred, err := auth.GetWebAuthnCredentialByCredID(user.ID, cred.ID)
|
||||
dbCred, err := auth.GetWebAuthnCredentialByCredID(ctx, user.ID, cred.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetWebAuthnCredentialByCredID", err)
|
||||
return
|
||||
}
|
||||
|
||||
dbCred.SignCount = cred.Authenticator.SignCount
|
||||
if err := dbCred.UpdateSignCount(); err != nil {
|
||||
if err := dbCred.UpdateSignCount(ctx); err != nil {
|
||||
ctx.ServerError("UpdateSignCount", err)
|
||||
return
|
||||
}
|
||||
|
@@ -23,7 +23,7 @@ func TopicSearch(ctx *context.Context) {
|
||||
},
|
||||
}
|
||||
|
||||
topics, total, err := repo_model.FindTopics(opts)
|
||||
topics, total, err := repo_model.FindTopics(ctx, opts)
|
||||
if err != nil {
|
||||
ctx.Error(http.StatusInternalServerError)
|
||||
return
|
||||
|
@@ -131,7 +131,7 @@ func Home(ctx *context.Context) {
|
||||
|
||||
var isFollowing bool
|
||||
if ctx.Doer != nil {
|
||||
isFollowing = user_model.IsFollowing(ctx.Doer.ID, ctx.ContextUser.ID)
|
||||
isFollowing = user_model.IsFollowing(ctx, ctx.Doer.ID, ctx.ContextUser.ID)
|
||||
}
|
||||
|
||||
ctx.Data["Repos"] = repos
|
||||
|
@@ -76,7 +76,7 @@ func UpdateLabel(ctx *context.Context) {
|
||||
l.Description = form.Description
|
||||
l.Color = form.Color
|
||||
l.SetArchived(form.IsArchived)
|
||||
if err := issues_model.UpdateLabel(l); err != nil {
|
||||
if err := issues_model.UpdateLabel(ctx, l); err != nil {
|
||||
ctx.ServerError("UpdateLabel", err)
|
||||
return
|
||||
}
|
||||
@@ -85,7 +85,7 @@ func UpdateLabel(ctx *context.Context) {
|
||||
|
||||
// DeleteLabel delete a label
|
||||
func DeleteLabel(ctx *context.Context) {
|
||||
if err := issues_model.DeleteLabel(ctx.Org.Organization.ID, ctx.FormInt64("id")); err != nil {
|
||||
if err := issues_model.DeleteLabel(ctx, ctx.Org.Organization.ID, ctx.FormInt64("id")); err != nil {
|
||||
ctx.Flash.Error("DeleteLabel: " + err.Error())
|
||||
} else {
|
||||
ctx.Flash.Success(ctx.Tr("repo.issues.label_deletion_success"))
|
||||
|
@@ -1412,7 +1412,7 @@ func ViewIssue(ctx *context.Context) {
|
||||
if ctx.Doer != nil {
|
||||
iw.UserID = ctx.Doer.ID
|
||||
iw.IssueID = issue.ID
|
||||
iw.IsWatching, err = issues_model.CheckIssueWatch(ctx.Doer, issue)
|
||||
iw.IsWatching, err = issues_model.CheckIssueWatch(ctx, ctx.Doer, issue)
|
||||
if err != nil {
|
||||
ctx.ServerError("CheckIssueWatch", err)
|
||||
return
|
||||
@@ -1530,7 +1530,7 @@ func ViewIssue(ctx *context.Context) {
|
||||
if ctx.Repo.Repository.IsTimetrackerEnabled(ctx) {
|
||||
if ctx.IsSigned {
|
||||
// Deal with the stopwatch
|
||||
ctx.Data["IsStopwatchRunning"] = issues_model.StopwatchExists(ctx.Doer.ID, issue.ID)
|
||||
ctx.Data["IsStopwatchRunning"] = issues_model.StopwatchExists(ctx, ctx.Doer.ID, issue.ID)
|
||||
if !ctx.Data["IsStopwatchRunning"].(bool) {
|
||||
var exists bool
|
||||
var swIssue *issues_model.Issue
|
||||
@@ -2708,7 +2708,7 @@ func ListIssues(ctx *context.Context) {
|
||||
|
||||
var labelIDs []int64
|
||||
if splitted := strings.Split(ctx.FormString("labels"), ","); len(splitted) > 0 {
|
||||
labelIDs, err = issues_model.GetLabelIDsInRepoByNames(ctx.Repo.Repository.ID, splitted)
|
||||
labelIDs, err = issues_model.GetLabelIDsInRepoByNames(ctx, ctx.Repo.Repository.ID, splitted)
|
||||
if err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
@@ -2720,7 +2720,7 @@ func ListIssues(ctx *context.Context) {
|
||||
for i := range part {
|
||||
// uses names and fall back to ids
|
||||
// non existent milestones are discarded
|
||||
mile, err := issues_model.GetMilestoneByRepoIDANDName(ctx.Repo.Repository.ID, part[i])
|
||||
mile, err := issues_model.GetMilestoneByRepoIDANDName(ctx, ctx.Repo.Repository.ID, part[i])
|
||||
if err == nil {
|
||||
mileIDs = append(mileIDs, mile.ID)
|
||||
continue
|
||||
@@ -3037,7 +3037,7 @@ func NewComment(ctx *context.Context) {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
if err := stopTimerIfAvailable(ctx.Doer, issue); err != nil {
|
||||
if err := stopTimerIfAvailable(ctx, ctx.Doer, issue); err != nil {
|
||||
ctx.ServerError("CreateOrStopIssueStopwatch", err)
|
||||
return
|
||||
}
|
||||
|
@@ -145,7 +145,7 @@ func UpdateLabel(ctx *context.Context) {
|
||||
l.Color = form.Color
|
||||
|
||||
l.SetArchived(form.IsArchived)
|
||||
if err := issues_model.UpdateLabel(l); err != nil {
|
||||
if err := issues_model.UpdateLabel(ctx, l); err != nil {
|
||||
ctx.ServerError("UpdateLabel", err)
|
||||
return
|
||||
}
|
||||
@@ -154,7 +154,7 @@ func UpdateLabel(ctx *context.Context) {
|
||||
|
||||
// DeleteLabel delete a label
|
||||
func DeleteLabel(ctx *context.Context) {
|
||||
if err := issues_model.DeleteLabel(ctx.Repo.Repository.ID, ctx.FormInt64("id")); err != nil {
|
||||
if err := issues_model.DeleteLabel(ctx, ctx.Repo.Repository.ID, ctx.FormInt64("id")); err != nil {
|
||||
ctx.Flash.Error("DeleteLabel: " + err.Error())
|
||||
} else {
|
||||
ctx.Flash.Success(ctx.Tr("repo.issues.label_deletion_success"))
|
||||
@@ -173,7 +173,7 @@ func UpdateIssueLabel(ctx *context.Context) {
|
||||
switch action := ctx.FormString("action"); action {
|
||||
case "clear":
|
||||
for _, issue := range issues {
|
||||
if err := issue_service.ClearLabels(issue, ctx.Doer); err != nil {
|
||||
if err := issue_service.ClearLabels(ctx, issue, ctx.Doer); err != nil {
|
||||
ctx.ServerError("ClearLabels", err)
|
||||
return
|
||||
}
|
||||
@@ -208,14 +208,14 @@ func UpdateIssueLabel(ctx *context.Context) {
|
||||
|
||||
if action == "attach" {
|
||||
for _, issue := range issues {
|
||||
if err = issue_service.AddLabel(issue, ctx.Doer, label); err != nil {
|
||||
if err = issue_service.AddLabel(ctx, issue, ctx.Doer, label); err != nil {
|
||||
ctx.ServerError("AddLabel", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for _, issue := range issues {
|
||||
if err = issue_service.RemoveLabel(issue, ctx.Doer, label); err != nil {
|
||||
if err = issue_service.RemoveLabel(ctx, issue, ctx.Doer, label); err != nil {
|
||||
ctx.ServerError("RemoveLabel", err)
|
||||
return
|
||||
}
|
||||
|
@@ -22,7 +22,7 @@ func IssueStopwatch(c *context.Context) {
|
||||
|
||||
var showSuccessMessage bool
|
||||
|
||||
if !issues_model.StopwatchExists(c.Doer.ID, issue.ID) {
|
||||
if !issues_model.StopwatchExists(c, c.Doer.ID, issue.ID) {
|
||||
showSuccessMessage = true
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ func IssueStopwatch(c *context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := issues_model.CreateOrStopIssueStopwatch(c.Doer, issue); err != nil {
|
||||
if err := issues_model.CreateOrStopIssueStopwatch(c, c.Doer, issue); err != nil {
|
||||
c.ServerError("CreateOrStopIssueStopwatch", err)
|
||||
return
|
||||
}
|
||||
@@ -55,12 +55,12 @@ func CancelStopwatch(c *context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := issues_model.CancelStopwatch(c.Doer, issue); err != nil {
|
||||
if err := issues_model.CancelStopwatch(c, c.Doer, issue); err != nil {
|
||||
c.ServerError("CancelStopwatch", err)
|
||||
return
|
||||
}
|
||||
|
||||
stopwatches, err := issues_model.GetUserStopwatches(c.Doer.ID, db.ListOptions{})
|
||||
stopwatches, err := issues_model.GetUserStopwatches(c, c.Doer.ID, db.ListOptions{})
|
||||
if err != nil {
|
||||
c.ServerError("GetUserStopwatches", err)
|
||||
return
|
||||
|
@@ -47,7 +47,7 @@ func IssueWatch(ctx *context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := issues_model.CreateOrUpdateIssueWatch(ctx.Doer.ID, issue.ID, watch); err != nil {
|
||||
if err := issues_model.CreateOrUpdateIssueWatch(ctx, ctx.Doer.ID, issue.ID, watch); err != nil {
|
||||
ctx.ServerError("CreateOrUpdateIssueWatch", err)
|
||||
return
|
||||
}
|
||||
|
@@ -232,13 +232,13 @@ func MigratePost(ctx *context.Context) {
|
||||
opts.Releases = false
|
||||
}
|
||||
|
||||
err = repo_model.CheckCreateRepository(ctx.Doer, ctxUser, opts.RepoName, false)
|
||||
err = repo_model.CheckCreateRepository(ctx, ctx.Doer, ctxUser, opts.RepoName, false)
|
||||
if err != nil {
|
||||
handleMigrateError(ctx, ctxUser, err, "MigratePost", tpl, form)
|
||||
return
|
||||
}
|
||||
|
||||
err = task.MigrateRepository(ctx.Doer, ctxUser, opts)
|
||||
err = task.MigrateRepository(ctx, ctx.Doer, ctxUser, opts)
|
||||
if err == nil {
|
||||
ctx.Redirect(ctxUser.HomeLink() + "/" + url.PathEscape(opts.RepoName))
|
||||
return
|
||||
@@ -260,7 +260,7 @@ func setMigrationContextData(ctx *context.Context, serviceType structs.GitServic
|
||||
}
|
||||
|
||||
func MigrateRetryPost(ctx *context.Context) {
|
||||
if err := task.RetryMigrateTask(ctx.Repo.Repository.ID); err != nil {
|
||||
if err := task.RetryMigrateTask(ctx, ctx.Repo.Repository.ID); err != nil {
|
||||
log.Error("Retry task failed: %v", err)
|
||||
ctx.ServerError("task.RetryMigrateTask", err)
|
||||
return
|
||||
@@ -269,7 +269,7 @@ func MigrateRetryPost(ctx *context.Context) {
|
||||
}
|
||||
|
||||
func MigrateCancelPost(ctx *context.Context) {
|
||||
migratingTask, err := admin_model.GetMigratingTask(ctx.Repo.Repository.ID)
|
||||
migratingTask, err := admin_model.GetMigratingTask(ctx, ctx.Repo.Repository.ID)
|
||||
if err != nil {
|
||||
log.Error("GetMigratingTask: %v", err)
|
||||
ctx.Redirect(ctx.Repo.Repository.Link())
|
||||
@@ -277,7 +277,7 @@ func MigrateCancelPost(ctx *context.Context) {
|
||||
}
|
||||
if migratingTask.Status == structs.TaskStatusRunning {
|
||||
taskUpdate := &admin_model.Task{ID: migratingTask.ID, Status: structs.TaskStatusFailed, Message: "canceled"}
|
||||
if err = taskUpdate.UpdateCols("status", "message"); err != nil {
|
||||
if err = taskUpdate.UpdateCols(ctx, "status", "message"); err != nil {
|
||||
ctx.ServerError("task.UpdateCols", err)
|
||||
return
|
||||
}
|
||||
|
@@ -65,7 +65,7 @@ func Milestones(ctx *context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
stats, err := issues_model.GetMilestonesStatsByRepoCondAndKw(builder.And(builder.Eq{"id": ctx.Repo.Repository.ID}), keyword)
|
||||
stats, err := issues_model.GetMilestonesStatsByRepoCondAndKw(ctx, builder.And(builder.Eq{"id": ctx.Repo.Repository.ID}), keyword)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetMilestoneStats", err)
|
||||
return
|
||||
@@ -74,7 +74,7 @@ func Milestones(ctx *context.Context) {
|
||||
ctx.Data["ClosedCount"] = stats.ClosedCount
|
||||
|
||||
if ctx.Repo.Repository.IsTimetrackerEnabled(ctx) {
|
||||
if err := miles.LoadTotalTrackedTimes(); err != nil {
|
||||
if err := miles.LoadTotalTrackedTimes(ctx); err != nil {
|
||||
ctx.ServerError("LoadTotalTrackedTimes", err)
|
||||
return
|
||||
}
|
||||
@@ -142,7 +142,7 @@ func NewMilestonePost(ctx *context.Context) {
|
||||
}
|
||||
|
||||
deadline = time.Date(deadline.Year(), deadline.Month(), deadline.Day(), 23, 59, 59, 0, deadline.Location())
|
||||
if err = issues_model.NewMilestone(&issues_model.Milestone{
|
||||
if err = issues_model.NewMilestone(ctx, &issues_model.Milestone{
|
||||
RepoID: ctx.Repo.Repository.ID,
|
||||
Name: form.Title,
|
||||
Content: form.Content,
|
||||
@@ -214,7 +214,7 @@ func EditMilestonePost(ctx *context.Context) {
|
||||
m.Name = form.Title
|
||||
m.Content = form.Content
|
||||
m.DeadlineUnix = timeutil.TimeStamp(deadline.Unix())
|
||||
if err = issues_model.UpdateMilestone(m, m.IsClosed); err != nil {
|
||||
if err = issues_model.UpdateMilestone(ctx, m, m.IsClosed); err != nil {
|
||||
ctx.ServerError("UpdateMilestone", err)
|
||||
return
|
||||
}
|
||||
@@ -236,7 +236,7 @@ func ChangeMilestoneStatus(ctx *context.Context) {
|
||||
}
|
||||
id := ctx.ParamsInt64(":id")
|
||||
|
||||
if err := issues_model.ChangeMilestoneStatusByRepoIDAndID(ctx.Repo.Repository.ID, id, toClose); err != nil {
|
||||
if err := issues_model.ChangeMilestoneStatusByRepoIDAndID(ctx, ctx.Repo.Repository.ID, id, toClose); err != nil {
|
||||
if issues_model.IsErrMilestoneNotExist(err) {
|
||||
ctx.NotFound("", err)
|
||||
} else {
|
||||
@@ -249,7 +249,7 @@ func ChangeMilestoneStatus(ctx *context.Context) {
|
||||
|
||||
// DeleteMilestone delete a milestone
|
||||
func DeleteMilestone(ctx *context.Context) {
|
||||
if err := issues_model.DeleteMilestoneByRepoID(ctx.Repo.Repository.ID, ctx.FormInt64("id")); err != nil {
|
||||
if err := issues_model.DeleteMilestoneByRepoID(ctx, ctx.Repo.Repository.ID, ctx.FormInt64("id")); err != nil {
|
||||
ctx.Flash.Error("DeleteMilestoneByRepoID: " + err.Error())
|
||||
} else {
|
||||
ctx.Flash.Success(ctx.Tr("repo.milestones.deletion_success"))
|
||||
|
@@ -1270,7 +1270,7 @@ func MergePullRequest(ctx *context.Context) {
|
||||
}
|
||||
log.Trace("Pull request merged: %d", pr.ID)
|
||||
|
||||
if err := stopTimerIfAvailable(ctx.Doer, issue); err != nil {
|
||||
if err := stopTimerIfAvailable(ctx, ctx.Doer, issue); err != nil {
|
||||
ctx.ServerError("CreateOrStopIssueStopwatch", err)
|
||||
return
|
||||
}
|
||||
@@ -1326,9 +1326,9 @@ func CancelAutoMergePullRequest(ctx *context.Context) {
|
||||
ctx.Redirect(fmt.Sprintf("%s/pulls/%d", ctx.Repo.RepoLink, issue.Index))
|
||||
}
|
||||
|
||||
func stopTimerIfAvailable(user *user_model.User, issue *issues_model.Issue) error {
|
||||
if issues_model.StopwatchExists(user.ID, issue.ID) {
|
||||
if err := issues_model.CreateOrStopIssueStopwatch(user, issue); err != nil {
|
||||
func stopTimerIfAvailable(ctx *context.Context, user *user_model.User, issue *issues_model.Issue) error {
|
||||
if issues_model.StopwatchExists(ctx, user.ID, issue.ID) {
|
||||
if err := issues_model.CreateOrStopIssueStopwatch(ctx, user, issue); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
@@ -344,7 +344,7 @@ func acceptOrRejectRepoTransfer(ctx *context.Context, accept bool) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if !repoTransfer.CanUserAcceptTransfer(ctx.Doer) {
|
||||
if !repoTransfer.CanUserAcceptTransfer(ctx, ctx.Doer) {
|
||||
return errors.New("user does not have enough permissions")
|
||||
}
|
||||
|
||||
@@ -359,7 +359,7 @@ func acceptOrRejectRepoTransfer(ctx *context.Context, accept bool) error {
|
||||
}
|
||||
ctx.Flash.Success(ctx.Tr("repo.settings.transfer.success"))
|
||||
} else {
|
||||
if err := models.CancelRepositoryTransfer(ctx.Repo.Repository); err != nil {
|
||||
if err := models.CancelRepositoryTransfer(ctx, ctx.Repo.Repository); err != nil {
|
||||
return err
|
||||
}
|
||||
ctx.Flash.Success(ctx.Tr("repo.settings.transfer.rejected"))
|
||||
|
@@ -127,7 +127,7 @@ func ChangeCollaborationAccessMode(ctx *context.Context) {
|
||||
|
||||
// DeleteCollaboration delete a collaboration for a repository
|
||||
func DeleteCollaboration(ctx *context.Context) {
|
||||
if err := repo_service.DeleteCollaboration(ctx.Repo.Repository, ctx.FormInt64("id")); err != nil {
|
||||
if err := repo_service.DeleteCollaboration(ctx, ctx.Repo.Repository, ctx.FormInt64("id")); err != nil {
|
||||
ctx.Flash.Error("DeleteCollaboration: " + err.Error())
|
||||
} else {
|
||||
ctx.Flash.Success(ctx.Tr("repo.settings.remove_collaborator_success"))
|
||||
|
@@ -799,7 +799,7 @@ func SettingsPost(ctx *context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := models.CancelRepositoryTransfer(ctx.Repo.Repository); err != nil {
|
||||
if err := models.CancelRepositoryTransfer(ctx, ctx.Repo.Repository); err != nil {
|
||||
ctx.ServerError("CancelRepositoryTransfer", err)
|
||||
return
|
||||
}
|
||||
@@ -863,7 +863,7 @@ func SettingsPost(ctx *context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := repo_model.SetArchiveRepoState(repo, true); err != nil {
|
||||
if err := repo_model.SetArchiveRepoState(ctx, repo, true); err != nil {
|
||||
log.Error("Tried to archive a repo: %s", err)
|
||||
ctx.Flash.Error(ctx.Tr("repo.settings.archive.error"))
|
||||
ctx.Redirect(ctx.Repo.RepoLink + "/settings")
|
||||
@@ -881,7 +881,7 @@ func SettingsPost(ctx *context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := repo_model.SetArchiveRepoState(repo, false); err != nil {
|
||||
if err := repo_model.SetArchiveRepoState(ctx, repo, false); err != nil {
|
||||
log.Error("Tried to unarchive a repo: %s", err)
|
||||
ctx.Flash.Error(ctx.Tr("repo.settings.unarchive.error"))
|
||||
ctx.Redirect(ctx.Repo.RepoLink + "/settings")
|
||||
|
@@ -45,7 +45,7 @@ func TopicsPost(ctx *context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
err := repo_model.SaveTopics(ctx.Repo.Repository.ID, validTopics...)
|
||||
err := repo_model.SaveTopics(ctx, ctx.Repo.Repository.ID, validTopics...)
|
||||
if err != nil {
|
||||
log.Error("SaveTopics failed: %v", err)
|
||||
ctx.JSON(http.StatusInternalServerError, map[string]any{
|
||||
|
@@ -640,7 +640,7 @@ func safeURL(address string) string {
|
||||
func checkHomeCodeViewable(ctx *context.Context) {
|
||||
if len(ctx.Repo.Units) > 0 {
|
||||
if ctx.Repo.Repository.IsBeingCreated() {
|
||||
task, err := admin_model.GetMigratingTask(ctx.Repo.Repository.ID)
|
||||
task, err := admin_model.GetMigratingTask(ctx, ctx.Repo.Repository.ID)
|
||||
if err != nil {
|
||||
if admin_model.IsErrTaskDoesNotExist(err) {
|
||||
ctx.Data["Repo"] = ctx.Repo
|
||||
@@ -893,7 +893,7 @@ func renderLanguageStats(ctx *context.Context) {
|
||||
}
|
||||
|
||||
func renderRepoTopics(ctx *context.Context) {
|
||||
topics, _, err := repo_model.FindTopics(&repo_model.FindTopicOptions{
|
||||
topics, _, err := repo_model.FindTopics(ctx, &repo_model.FindTopicOptions{
|
||||
RepoID: ctx.Repo.Repository.ID,
|
||||
})
|
||||
if err != nil {
|
||||
|
@@ -30,7 +30,7 @@ func prepareContextForCommonProfile(ctx *context.Context) {
|
||||
func PrepareContextForProfileBigAvatar(ctx *context.Context) {
|
||||
prepareContextForCommonProfile(ctx)
|
||||
|
||||
ctx.Data["IsFollowing"] = ctx.Doer != nil && user_model.IsFollowing(ctx.Doer.ID, ctx.ContextUser.ID)
|
||||
ctx.Data["IsFollowing"] = ctx.Doer != nil && user_model.IsFollowing(ctx, ctx.Doer.ID, ctx.ContextUser.ID)
|
||||
ctx.Data["ShowUserEmail"] = setting.UI.ShowUserEmail && ctx.ContextUser.Email != "" && ctx.IsSigned && !ctx.ContextUser.KeepEmailPrivate
|
||||
|
||||
// Show OpenID URIs
|
||||
|
@@ -59,7 +59,7 @@ func getDashboardContextUser(ctx *context.Context) *user_model.User {
|
||||
}
|
||||
ctx.Data["ContextUser"] = ctxUser
|
||||
|
||||
orgs, err := organization.GetUserOrgsList(ctx.Doer)
|
||||
orgs, err := organization.GetUserOrgsList(ctx, ctx.Doer)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetUserOrgsList", err)
|
||||
return nil
|
||||
@@ -213,13 +213,13 @@ func Milestones(ctx *context.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
counts, err := issues_model.CountMilestonesByRepoCondAndKw(userRepoCond, keyword, isShowClosed)
|
||||
counts, err := issues_model.CountMilestonesByRepoCondAndKw(ctx, userRepoCond, keyword, isShowClosed)
|
||||
if err != nil {
|
||||
ctx.ServerError("CountMilestonesByRepoIDs", err)
|
||||
return
|
||||
}
|
||||
|
||||
milestones, err := issues_model.SearchMilestones(repoCond, page, isShowClosed, sortType, keyword)
|
||||
milestones, err := issues_model.SearchMilestones(ctx, repoCond, page, isShowClosed, sortType, keyword)
|
||||
if err != nil {
|
||||
ctx.ServerError("SearchMilestones", err)
|
||||
return
|
||||
@@ -256,7 +256,7 @@ func Milestones(ctx *context.Context) {
|
||||
}
|
||||
|
||||
if milestones[i].Repo.IsTimetrackerEnabled(ctx) {
|
||||
err := milestones[i].LoadTotalTrackedTime()
|
||||
err := milestones[i].LoadTotalTrackedTime(ctx)
|
||||
if err != nil {
|
||||
ctx.ServerError("LoadTotalTrackedTime", err)
|
||||
return
|
||||
@@ -265,7 +265,7 @@ func Milestones(ctx *context.Context) {
|
||||
i++
|
||||
}
|
||||
|
||||
milestoneStats, err := issues_model.GetMilestonesStatsByRepoCondAndKw(repoCond, keyword)
|
||||
milestoneStats, err := issues_model.GetMilestonesStatsByRepoCondAndKw(ctx, repoCond, keyword)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetMilestoneStats", err)
|
||||
return
|
||||
@@ -275,7 +275,7 @@ func Milestones(ctx *context.Context) {
|
||||
if len(repoIDs) == 0 {
|
||||
totalMilestoneStats = milestoneStats
|
||||
} else {
|
||||
totalMilestoneStats, err = issues_model.GetMilestonesStatsByRepoCondAndKw(userRepoCond, keyword)
|
||||
totalMilestoneStats, err = issues_model.GetMilestonesStatsByRepoCondAndKw(ctx, userRepoCond, keyword)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetMilestoneStats", err)
|
||||
return
|
||||
|
@@ -292,9 +292,9 @@ func Action(ctx *context.Context) {
|
||||
var err error
|
||||
switch ctx.FormString("action") {
|
||||
case "follow":
|
||||
err = user_model.FollowUser(ctx.Doer.ID, ctx.ContextUser.ID)
|
||||
err = user_model.FollowUser(ctx, ctx.Doer.ID, ctx.ContextUser.ID)
|
||||
case "unfollow":
|
||||
err = user_model.UnfollowUser(ctx.Doer.ID, ctx.ContextUser.ID)
|
||||
err = user_model.UnfollowUser(ctx, ctx.Doer.ID, ctx.ContextUser.ID)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
|
@@ -59,7 +59,7 @@ func loadSecurityData(ctx *context.Context) {
|
||||
}
|
||||
ctx.Data["TOTPEnrolled"] = enrolled
|
||||
|
||||
credentials, err := auth_model.GetWebAuthnCredentialsByUID(ctx.Doer.ID)
|
||||
credentials, err := auth_model.GetWebAuthnCredentialsByUID(ctx, ctx.Doer.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetWebAuthnCredentialsByUID", err)
|
||||
return
|
||||
|
@@ -29,7 +29,7 @@ func WebAuthnRegister(ctx *context.Context) {
|
||||
form.Name = strconv.FormatInt(time.Now().UnixNano(), 16)
|
||||
}
|
||||
|
||||
cred, err := auth.GetWebAuthnCredentialByName(ctx.Doer.ID, form.Name)
|
||||
cred, err := auth.GetWebAuthnCredentialByName(ctx, ctx.Doer.ID, form.Name)
|
||||
if err != nil && !auth.IsErrWebAuthnCredentialNotExist(err) {
|
||||
ctx.ServerError("GetWebAuthnCredentialsByUID", err)
|
||||
return
|
||||
@@ -88,7 +88,7 @@ func WebauthnRegisterPost(ctx *context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
dbCred, err := auth.GetWebAuthnCredentialByName(ctx.Doer.ID, name)
|
||||
dbCred, err := auth.GetWebAuthnCredentialByName(ctx, ctx.Doer.ID, name)
|
||||
if err != nil && !auth.IsErrWebAuthnCredentialNotExist(err) {
|
||||
ctx.ServerError("GetWebAuthnCredentialsByUID", err)
|
||||
return
|
||||
@@ -99,7 +99,7 @@ func WebauthnRegisterPost(ctx *context.Context) {
|
||||
}
|
||||
|
||||
// Create the credential
|
||||
_, err = auth.CreateCredential(ctx.Doer.ID, name, cred)
|
||||
_, err = auth.CreateCredential(ctx, ctx.Doer.ID, name, cred)
|
||||
if err != nil {
|
||||
ctx.ServerError("CreateCredential", err)
|
||||
return
|
||||
@@ -112,7 +112,7 @@ func WebauthnRegisterPost(ctx *context.Context) {
|
||||
// WebauthnDelete deletes an security key by id
|
||||
func WebauthnDelete(ctx *context.Context) {
|
||||
form := web.GetForm(ctx).(*forms.WebauthnDeleteForm)
|
||||
if _, err := auth.DeleteCredential(form.ID, ctx.Doer.ID); err != nil {
|
||||
if _, err := auth.DeleteCredential(ctx, form.ID, ctx.Doer.ID); err != nil {
|
||||
ctx.ServerError("GetWebAuthnCredentialByID", err)
|
||||
return
|
||||
}
|
||||
|
@@ -14,7 +14,7 @@ import (
|
||||
|
||||
// GetStopwatches get all stopwatches
|
||||
func GetStopwatches(ctx *context.Context) {
|
||||
sws, err := issues_model.GetUserStopwatches(ctx.Doer.ID, db.ListOptions{
|
||||
sws, err := issues_model.GetUserStopwatches(ctx, ctx.Doer.ID, db.ListOptions{
|
||||
Page: ctx.FormInt("page"),
|
||||
PageSize: convert.ToCorrectPageSize(ctx.FormInt("limit")),
|
||||
})
|
||||
@@ -23,7 +23,7 @@ func GetStopwatches(ctx *context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
count, err := issues_model.CountUserStopwatches(ctx.Doer.ID)
|
||||
count, err := issues_model.CountUserStopwatches(ctx, ctx.Doer.ID)
|
||||
if err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
|
@@ -14,7 +14,7 @@ import (
|
||||
|
||||
// TaskStatus returns task's status
|
||||
func TaskStatus(ctx *context.Context) {
|
||||
task, opts, err := admin_model.GetMigratingTaskByID(ctx.ParamsInt64("task"), ctx.Doer.ID)
|
||||
task, opts, err := admin_model.GetMigratingTaskByID(ctx, ctx.ParamsInt64("task"), ctx.Doer.ID)
|
||||
if err != nil {
|
||||
if admin_model.IsErrTaskDoesNotExist(err) {
|
||||
ctx.JSON(http.StatusNotFound, map[string]any{
|
||||
|
Reference in New Issue
Block a user