diff options
author | KN4CK3R <admin@oldschoolhack.me> | 2022-03-22 08:03:22 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-22 15:03:22 +0800 |
commit | 80fd25524e13dedbdc3527b32d008de152213a89 (patch) | |
tree | 63b2bfe4ffaf1dce12080cabdc2e845c8731a673 /routers/api/v1/user | |
parent | 5495ba7660979973ba19e304786135da474e0e64 (diff) | |
download | gitea-80fd25524e13dedbdc3527b32d008de152213a89.tar.gz gitea-80fd25524e13dedbdc3527b32d008de152213a89.zip |
Renamed ctx.User to ctx.Doer. (#19161)
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Diffstat (limited to 'routers/api/v1/user')
-rw-r--r-- | routers/api/v1/user/app.go | 16 | ||||
-rw-r--r-- | routers/api/v1/user/email.go | 6 | ||||
-rw-r--r-- | routers/api/v1/user/follower.go | 12 | ||||
-rw-r--r-- | routers/api/v1/user/gpg_key.go | 20 | ||||
-rw-r--r-- | routers/api/v1/user/key.go | 16 | ||||
-rw-r--r-- | routers/api/v1/user/repo.go | 10 | ||||
-rw-r--r-- | routers/api/v1/user/settings.go | 24 | ||||
-rw-r--r-- | routers/api/v1/user/star.go | 12 | ||||
-rw-r--r-- | routers/api/v1/user/user.go | 12 | ||||
-rw-r--r-- | routers/api/v1/user/watch.go | 10 |
10 files changed, 69 insertions, 69 deletions
diff --git a/routers/api/v1/user/app.go b/routers/api/v1/user/app.go index 94cfab45bd..165b8f005e 100644 --- a/routers/api/v1/user/app.go +++ b/routers/api/v1/user/app.go @@ -45,7 +45,7 @@ func ListAccessTokens(ctx *context.APIContext) { // "200": // "$ref": "#/responses/AccessTokenList" - opts := models.ListAccessTokensOptions{UserID: ctx.User.ID, ListOptions: utils.GetListOptions(ctx)} + opts := models.ListAccessTokensOptions{UserID: ctx.Doer.ID, ListOptions: utils.GetListOptions(ctx)} count, err := models.CountAccessTokens(opts) if err != nil { @@ -99,7 +99,7 @@ func CreateAccessToken(ctx *context.APIContext) { form := web.GetForm(ctx).(*api.CreateAccessTokenOption) t := &models.AccessToken{ - UID: ctx.User.ID, + UID: ctx.Doer.ID, Name: form.Name, } @@ -157,7 +157,7 @@ func DeleteAccessToken(ctx *context.APIContext) { if tokenID == 0 { tokens, err := models.ListAccessTokens(models.ListAccessTokensOptions{ Name: token, - UserID: ctx.User.ID, + UserID: ctx.Doer.ID, }) if err != nil { ctx.Error(http.StatusInternalServerError, "ListAccessTokens", err) @@ -180,7 +180,7 @@ func DeleteAccessToken(ctx *context.APIContext) { return } - if err := models.DeleteAccessTokenByID(tokenID, ctx.User.ID); err != nil { + if err := models.DeleteAccessTokenByID(tokenID, ctx.Doer.ID); err != nil { if models.IsErrAccessTokenNotExist(err) { ctx.NotFound() } else { @@ -215,7 +215,7 @@ func CreateOauth2Application(ctx *context.APIContext) { app, err := auth.CreateOAuth2Application(auth.CreateOAuth2ApplicationOptions{ Name: data.Name, - UserID: ctx.User.ID, + UserID: ctx.Doer.ID, RedirectURIs: data.RedirectURIs, }) if err != nil { @@ -252,7 +252,7 @@ func ListOauth2Applications(ctx *context.APIContext) { // "200": // "$ref": "#/responses/OAuth2ApplicationList" - apps, total, err := auth.ListOAuth2Applications(ctx.User.ID, utils.GetListOptions(ctx)) + apps, total, err := auth.ListOAuth2Applications(ctx.Doer.ID, utils.GetListOptions(ctx)) if err != nil { ctx.Error(http.StatusInternalServerError, "ListOAuth2Applications", err) return @@ -288,7 +288,7 @@ func DeleteOauth2Application(ctx *context.APIContext) { // "404": // "$ref": "#/responses/notFound" appID := ctx.ParamsInt64(":id") - if err := auth.DeleteOAuth2Application(appID, ctx.User.ID); err != nil { + if err := auth.DeleteOAuth2Application(appID, ctx.Doer.ID); err != nil { if auth.IsErrOAuthApplicationNotFound(err) { ctx.NotFound() } else { @@ -365,7 +365,7 @@ func UpdateOauth2Application(ctx *context.APIContext) { app, err := auth.UpdateOAuth2Application(auth.UpdateOAuth2ApplicationOptions{ Name: data.Name, - UserID: ctx.User.ID, + UserID: ctx.Doer.ID, ID: appID, RedirectURIs: data.RedirectURIs, }) diff --git a/routers/api/v1/user/email.go b/routers/api/v1/user/email.go index ed79723c60..9060741c59 100644 --- a/routers/api/v1/user/email.go +++ b/routers/api/v1/user/email.go @@ -28,7 +28,7 @@ func ListEmails(ctx *context.APIContext) { // "200": // "$ref": "#/responses/EmailList" - emails, err := user_model.GetEmailAddresses(ctx.User.ID) + emails, err := user_model.GetEmailAddresses(ctx.Doer.ID) if err != nil { ctx.Error(http.StatusInternalServerError, "GetEmailAddresses", err) return @@ -71,7 +71,7 @@ func AddEmail(ctx *context.APIContext) { emails := make([]*user_model.EmailAddress, len(form.Emails)) for i := range form.Emails { emails[i] = &user_model.EmailAddress{ - UID: ctx.User.ID, + UID: ctx.Doer.ID, Email: form.Emails[i], IsActivated: !setting.Service.RegisterEmailConfirm, } @@ -124,7 +124,7 @@ func DeleteEmail(ctx *context.APIContext) { for i := range form.Emails { emails[i] = &user_model.EmailAddress{ Email: form.Emails[i], - UID: ctx.User.ID, + UID: ctx.Doer.ID, } } diff --git a/routers/api/v1/user/follower.go b/routers/api/v1/user/follower.go index 1eacb89db2..063f68519c 100644 --- a/routers/api/v1/user/follower.go +++ b/routers/api/v1/user/follower.go @@ -18,7 +18,7 @@ import ( func responseAPIUsers(ctx *context.APIContext, users []*user_model.User) { apiUsers := make([]*api.User, len(users)) for i := range users { - apiUsers[i] = convert.ToUser(users[i], ctx.User) + apiUsers[i] = convert.ToUser(users[i], ctx.Doer) } ctx.JSON(http.StatusOK, &apiUsers) } @@ -54,7 +54,7 @@ func ListMyFollowers(ctx *context.APIContext) { // "200": // "$ref": "#/responses/UserList" - listUserFollowers(ctx, ctx.User) + listUserFollowers(ctx, ctx.Doer) } // ListFollowers list the given user's followers @@ -120,7 +120,7 @@ func ListMyFollowing(ctx *context.APIContext) { // "200": // "$ref": "#/responses/UserList" - listUserFollowing(ctx, ctx.User) + listUserFollowing(ctx, ctx.Doer) } // ListFollowing list the users that the given user is following @@ -184,7 +184,7 @@ func CheckMyFollowing(ctx *context.APIContext) { if ctx.Written() { return } - checkUserFollowing(ctx, ctx.User, target.ID) + checkUserFollowing(ctx, ctx.Doer, target.ID) } // CheckFollowing check if one user is following another user @@ -239,7 +239,7 @@ func Follow(ctx *context.APIContext) { if ctx.Written() { return } - if err := user_model.FollowUser(ctx.User.ID, target.ID); err != nil { + if err := user_model.FollowUser(ctx.Doer.ID, target.ID); err != nil { ctx.Error(http.StatusInternalServerError, "FollowUser", err) return } @@ -265,7 +265,7 @@ func Unfollow(ctx *context.APIContext) { if ctx.Written() { return } - if err := user_model.UnfollowUser(ctx.User.ID, target.ID); err != nil { + if err := user_model.UnfollowUser(ctx.Doer.ID, target.ID); err != nil { ctx.Error(http.StatusInternalServerError, "UnfollowUser", err) return } diff --git a/routers/api/v1/user/gpg_key.go b/routers/api/v1/user/gpg_key.go index 26aeeeabf9..5e98b21fb8 100644 --- a/routers/api/v1/user/gpg_key.go +++ b/routers/api/v1/user/gpg_key.go @@ -91,7 +91,7 @@ func ListMyGPGKeys(ctx *context.APIContext) { // "200": // "$ref": "#/responses/GPGKeyList" - listGPGKeys(ctx, ctx.User.ID, utils.GetListOptions(ctx)) + listGPGKeys(ctx, ctx.Doer.ID, utils.GetListOptions(ctx)) } // GetGPGKey get the GPG key based on a id @@ -128,8 +128,8 @@ func GetGPGKey(ctx *context.APIContext) { // CreateUserGPGKey creates new GPG key to given user by ID. func CreateUserGPGKey(ctx *context.APIContext, form api.CreateGPGKeyOption, uid int64) { - token := asymkey_model.VerificationToken(ctx.User, 1) - lastToken := asymkey_model.VerificationToken(ctx.User, 0) + token := asymkey_model.VerificationToken(ctx.Doer, 1) + lastToken := asymkey_model.VerificationToken(ctx.Doer, 0) keys, err := asymkey_model.AddGPGKey(uid, form.ArmoredKey, token, form.Signature) if err != nil && asymkey_model.IsErrGPGInvalidTokenSignature(err) { @@ -156,7 +156,7 @@ func GetVerificationToken(ctx *context.APIContext) { // "404": // "$ref": "#/responses/notFound" - token := asymkey_model.VerificationToken(ctx.User, 1) + token := asymkey_model.VerificationToken(ctx.Doer, 1) ctx.PlainText(http.StatusOK, token) } @@ -178,12 +178,12 @@ func VerifyUserGPGKey(ctx *context.APIContext) { // "$ref": "#/responses/validationError" form := web.GetForm(ctx).(*api.VerifyGPGKeyOption) - token := asymkey_model.VerificationToken(ctx.User, 1) - lastToken := asymkey_model.VerificationToken(ctx.User, 0) + token := asymkey_model.VerificationToken(ctx.Doer, 1) + lastToken := asymkey_model.VerificationToken(ctx.Doer, 0) - _, err := asymkey_model.VerifyGPGKey(ctx.User.ID, form.KeyID, token, form.Signature) + _, err := asymkey_model.VerifyGPGKey(ctx.Doer.ID, form.KeyID, token, form.Signature) if err != nil && asymkey_model.IsErrGPGInvalidTokenSignature(err) { - _, err = asymkey_model.VerifyGPGKey(ctx.User.ID, form.KeyID, lastToken, form.Signature) + _, err = asymkey_model.VerifyGPGKey(ctx.Doer.ID, form.KeyID, lastToken, form.Signature) } if err != nil { @@ -230,7 +230,7 @@ func CreateGPGKey(ctx *context.APIContext) { // "$ref": "#/responses/validationError" form := web.GetForm(ctx).(*api.CreateGPGKeyOption) - CreateUserGPGKey(ctx, *form, ctx.User.ID) + CreateUserGPGKey(ctx, *form, ctx.Doer.ID) } // DeleteGPGKey remove a GPG key belonging to the authenticated user @@ -255,7 +255,7 @@ func DeleteGPGKey(ctx *context.APIContext) { // "404": // "$ref": "#/responses/notFound" - if err := asymkey_model.DeleteGPGKey(ctx.User, ctx.ParamsInt64(":id")); err != nil { + if err := asymkey_model.DeleteGPGKey(ctx.Doer, ctx.ParamsInt64(":id")); err != nil { if asymkey_model.IsErrGPGKeyAccessDenied(err) { ctx.Error(http.StatusForbidden, "", "You do not have access to this key") } else { diff --git a/routers/api/v1/user/key.go b/routers/api/v1/user/key.go index e8cc2035e5..67ffec723d 100644 --- a/routers/api/v1/user/key.go +++ b/routers/api/v1/user/key.go @@ -86,7 +86,7 @@ func listPublicKeys(ctx *context.APIContext, user *user_model.User) { apiKeys := make([]*api.PublicKey, len(keys)) for i := range keys { apiKeys[i] = convert.ToPublicKey(apiLink, keys[i]) - if ctx.User.IsAdmin || ctx.User.ID == keys[i].OwnerID { + if ctx.Doer.IsAdmin || ctx.Doer.ID == keys[i].OwnerID { apiKeys[i], _ = appendPrivateInformation(apiKeys[i], keys[i], user) } } @@ -119,7 +119,7 @@ func ListMyPublicKeys(ctx *context.APIContext) { // "200": // "$ref": "#/responses/PublicKeyList" - listPublicKeys(ctx, ctx.User) + listPublicKeys(ctx, ctx.Doer) } // ListPublicKeys list the given user's public keys @@ -190,8 +190,8 @@ func GetPublicKey(ctx *context.APIContext) { apiLink := composePublicKeysAPILink() apiKey := convert.ToPublicKey(apiLink, key) - if ctx.User.IsAdmin || ctx.User.ID == key.OwnerID { - apiKey, _ = appendPrivateInformation(apiKey, key, ctx.User) + if ctx.Doer.IsAdmin || ctx.Doer.ID == key.OwnerID { + apiKey, _ = appendPrivateInformation(apiKey, key, ctx.Doer) } ctx.JSON(http.StatusOK, apiKey) } @@ -211,8 +211,8 @@ func CreateUserPublicKey(ctx *context.APIContext, form api.CreateKeyOption, uid } apiLink := composePublicKeysAPILink() apiKey := convert.ToPublicKey(apiLink, key) - if ctx.User.IsAdmin || ctx.User.ID == key.OwnerID { - apiKey, _ = appendPrivateInformation(apiKey, key, ctx.User) + if ctx.Doer.IsAdmin || ctx.Doer.ID == key.OwnerID { + apiKey, _ = appendPrivateInformation(apiKey, key, ctx.Doer) } ctx.JSON(http.StatusCreated, apiKey) } @@ -238,7 +238,7 @@ func CreatePublicKey(ctx *context.APIContext) { // "$ref": "#/responses/validationError" form := web.GetForm(ctx).(*api.CreateKeyOption) - CreateUserPublicKey(ctx, *form, ctx.User.ID) + CreateUserPublicKey(ctx, *form, ctx.Doer.ID) } // DeletePublicKey delete one public key @@ -272,7 +272,7 @@ func DeletePublicKey(ctx *context.APIContext) { ctx.Error(http.StatusForbidden, "", "SSH Key is externally managed for this user") } - if err := asymkey_service.DeletePublicKey(ctx.User, id); err != nil { + if err := asymkey_service.DeletePublicKey(ctx.Doer, id); err != nil { if asymkey_model.IsErrKeyNotExist(err) { ctx.NotFound() } else if asymkey_model.IsErrKeyAccessDenied(err) { diff --git a/routers/api/v1/user/repo.go b/routers/api/v1/user/repo.go index 109548ec76..2b933bea15 100644 --- a/routers/api/v1/user/repo.go +++ b/routers/api/v1/user/repo.go @@ -39,12 +39,12 @@ func listUserRepos(ctx *context.APIContext, u *user_model.User, private bool) { apiRepos := make([]*api.Repository, 0, len(repos)) for i := range repos { - access, err := models.AccessLevel(ctx.User, repos[i]) + access, err := models.AccessLevel(ctx.Doer, repos[i]) if err != nil { ctx.Error(http.StatusInternalServerError, "AccessLevel", err) return } - if ctx.IsSigned && ctx.User.IsAdmin || access >= perm.AccessModeRead { + if ctx.IsSigned && ctx.Doer.IsAdmin || access >= perm.AccessModeRead { apiRepos = append(apiRepos, convert.ToRepo(repos[i], access)) } } @@ -109,8 +109,8 @@ func ListMyRepos(ctx *context.APIContext) { opts := &models.SearchRepoOptions{ ListOptions: utils.GetListOptions(ctx), - Actor: ctx.User, - OwnerID: ctx.User.ID, + Actor: ctx.Doer, + OwnerID: ctx.Doer.ID, Private: ctx.IsSigned, IncludeDescription: true, } @@ -128,7 +128,7 @@ func ListMyRepos(ctx *context.APIContext) { ctx.Error(http.StatusInternalServerError, "GetOwner", err) return } - accessMode, err := models.AccessLevel(ctx.User, repo) + accessMode, err := models.AccessLevel(ctx.Doer, repo) if err != nil { ctx.Error(http.StatusInternalServerError, "AccessLevel", err) } diff --git a/routers/api/v1/user/settings.go b/routers/api/v1/user/settings.go index 5f4d76ed72..dc7e7f1160 100644 --- a/routers/api/v1/user/settings.go +++ b/routers/api/v1/user/settings.go @@ -24,7 +24,7 @@ func GetUserSettings(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/UserSettings" - ctx.JSON(http.StatusOK, convert.User2UserSettings(ctx.User)) + ctx.JSON(http.StatusOK, convert.User2UserSettings(ctx.Doer)) } // UpdateUserSettings returns user settings @@ -46,38 +46,38 @@ func UpdateUserSettings(ctx *context.APIContext) { form := web.GetForm(ctx).(*api.UserSettingsOptions) if form.FullName != nil { - ctx.User.FullName = *form.FullName + ctx.Doer.FullName = *form.FullName } if form.Description != nil { - ctx.User.Description = *form.Description + ctx.Doer.Description = *form.Description } if form.Website != nil { - ctx.User.Website = *form.Website + ctx.Doer.Website = *form.Website } if form.Location != nil { - ctx.User.Location = *form.Location + ctx.Doer.Location = *form.Location } if form.Language != nil { - ctx.User.Language = *form.Language + ctx.Doer.Language = *form.Language } if form.Theme != nil { - ctx.User.Theme = *form.Theme + ctx.Doer.Theme = *form.Theme } if form.DiffViewStyle != nil { - ctx.User.DiffViewStyle = *form.DiffViewStyle + ctx.Doer.DiffViewStyle = *form.DiffViewStyle } if form.HideEmail != nil { - ctx.User.KeepEmailPrivate = *form.HideEmail + ctx.Doer.KeepEmailPrivate = *form.HideEmail } if form.HideActivity != nil { - ctx.User.KeepActivityPrivate = *form.HideActivity + ctx.Doer.KeepActivityPrivate = *form.HideActivity } - if err := user_model.UpdateUser(ctx.User, false); err != nil { + if err := user_model.UpdateUser(ctx.Doer, false); err != nil { ctx.InternalServerError(err) return } - ctx.JSON(http.StatusOK, convert.User2UserSettings(ctx.User)) + ctx.JSON(http.StatusOK, convert.User2UserSettings(ctx.Doer)) } diff --git a/routers/api/v1/user/star.go b/routers/api/v1/user/star.go index cc527d9213..95d3785a82 100644 --- a/routers/api/v1/user/star.go +++ b/routers/api/v1/user/star.go @@ -63,7 +63,7 @@ func GetStarredRepos(ctx *context.APIContext) { // "$ref": "#/responses/RepositoryList" user := GetUserByParams(ctx) - private := user.ID == ctx.User.ID + private := user.ID == ctx.Doer.ID repos, err := getStarredRepos(user, private, utils.GetListOptions(ctx)) if err != nil { ctx.Error(http.StatusInternalServerError, "getStarredRepos", err) @@ -94,12 +94,12 @@ func GetMyStarredRepos(ctx *context.APIContext) { // "200": // "$ref": "#/responses/RepositoryList" - repos, err := getStarredRepos(ctx.User, true, utils.GetListOptions(ctx)) + repos, err := getStarredRepos(ctx.Doer, true, utils.GetListOptions(ctx)) if err != nil { ctx.Error(http.StatusInternalServerError, "getStarredRepos", err) } - ctx.SetTotalCountHeader(int64(ctx.User.NumStars)) + ctx.SetTotalCountHeader(int64(ctx.Doer.NumStars)) ctx.JSON(http.StatusOK, &repos) } @@ -125,7 +125,7 @@ func IsStarring(ctx *context.APIContext) { // "404": // "$ref": "#/responses/notFound" - if repo_model.IsStaring(ctx.User.ID, ctx.Repo.Repository.ID) { + if repo_model.IsStaring(ctx.Doer.ID, ctx.Repo.Repository.ID) { ctx.Status(http.StatusNoContent) } else { ctx.NotFound() @@ -152,7 +152,7 @@ func Star(ctx *context.APIContext) { // "204": // "$ref": "#/responses/empty" - err := repo_model.StarRepo(ctx.User.ID, ctx.Repo.Repository.ID, true) + err := repo_model.StarRepo(ctx.Doer.ID, ctx.Repo.Repository.ID, true) if err != nil { ctx.Error(http.StatusInternalServerError, "StarRepo", err) return @@ -180,7 +180,7 @@ func Unstar(ctx *context.APIContext) { // "204": // "$ref": "#/responses/empty" - err := repo_model.StarRepo(ctx.User.ID, ctx.Repo.Repository.ID, false) + err := repo_model.StarRepo(ctx.Doer.ID, ctx.Repo.Repository.ID, false) if err != nil { ctx.Error(http.StatusInternalServerError, "StarRepo", err) return diff --git a/routers/api/v1/user/user.go b/routers/api/v1/user/user.go index bba7b7a5d1..56e6ad8879 100644 --- a/routers/api/v1/user/user.go +++ b/routers/api/v1/user/user.go @@ -56,7 +56,7 @@ func Search(ctx *context.APIContext) { listOptions := utils.GetListOptions(ctx) users, maxResults, err := user_model.SearchUsers(&user_model.SearchUserOptions{ - Actor: ctx.User, + Actor: ctx.Doer, Keyword: ctx.FormTrim("q"), UID: ctx.FormInt64("uid"), Type: user_model.UserTypeIndividual, @@ -75,7 +75,7 @@ func Search(ctx *context.APIContext) { ctx.JSON(http.StatusOK, map[string]interface{}{ "ok": true, - "data": convert.ToUsers(ctx.User, users), + "data": convert.ToUsers(ctx.Doer, users), }) } @@ -104,12 +104,12 @@ func GetInfo(ctx *context.APIContext) { return } - if !models.IsUserVisibleToViewer(u, ctx.User) { + if !models.IsUserVisibleToViewer(u, ctx.Doer) { // fake ErrUserNotExist error message to not leak information about existence ctx.NotFound("GetUserByName", user_model.ErrUserNotExist{Name: ctx.Params(":username")}) return } - ctx.JSON(http.StatusOK, convert.ToUser(u, ctx.User)) + ctx.JSON(http.StatusOK, convert.ToUser(u, ctx.Doer)) } // GetAuthenticatedUser get current user's information @@ -123,7 +123,7 @@ func GetAuthenticatedUser(ctx *context.APIContext) { // "200": // "$ref": "#/responses/User" - ctx.JSON(http.StatusOK, convert.ToUser(ctx.User, ctx.User)) + ctx.JSON(http.StatusOK, convert.ToUser(ctx.Doer, ctx.Doer)) } // GetUserHeatmapData is the handler to get a users heatmap @@ -150,7 +150,7 @@ func GetUserHeatmapData(ctx *context.APIContext) { return } - heatmap, err := models.GetUserHeatmapDataByUser(user, ctx.User) + heatmap, err := models.GetUserHeatmapDataByUser(user, ctx.Doer) if err != nil { ctx.Error(http.StatusInternalServerError, "GetUserHeatmapDataByUser", err) return diff --git a/routers/api/v1/user/watch.go b/routers/api/v1/user/watch.go index 49b1d47d95..718a9282ed 100644 --- a/routers/api/v1/user/watch.go +++ b/routers/api/v1/user/watch.go @@ -61,7 +61,7 @@ func GetWatchedRepos(ctx *context.APIContext) { // "$ref": "#/responses/RepositoryList" user := GetUserByParams(ctx) - private := user.ID == ctx.User.ID + private := user.ID == ctx.Doer.ID repos, total, err := getWatchedRepos(user, private, utils.GetListOptions(ctx)) if err != nil { ctx.Error(http.StatusInternalServerError, "getWatchedRepos", err) @@ -91,7 +91,7 @@ func GetMyWatchedRepos(ctx *context.APIContext) { // "200": // "$ref": "#/responses/RepositoryList" - repos, total, err := getWatchedRepos(ctx.User, true, utils.GetListOptions(ctx)) + repos, total, err := getWatchedRepos(ctx.Doer, true, utils.GetListOptions(ctx)) if err != nil { ctx.Error(http.StatusInternalServerError, "getWatchedRepos", err) } @@ -123,7 +123,7 @@ func IsWatching(ctx *context.APIContext) { // "404": // description: User is not watching this repo or repo do not exist - if repo_model.IsWatching(ctx.User.ID, ctx.Repo.Repository.ID) { + if repo_model.IsWatching(ctx.Doer.ID, ctx.Repo.Repository.ID) { ctx.JSON(http.StatusOK, api.WatchInfo{ Subscribed: true, Ignored: false, @@ -157,7 +157,7 @@ func Watch(ctx *context.APIContext) { // "200": // "$ref": "#/responses/WatchInfo" - err := repo_model.WatchRepo(ctx.User.ID, ctx.Repo.Repository.ID, true) + err := repo_model.WatchRepo(ctx.Doer.ID, ctx.Repo.Repository.ID, true) if err != nil { ctx.Error(http.StatusInternalServerError, "WatchRepo", err) return @@ -192,7 +192,7 @@ func Unwatch(ctx *context.APIContext) { // "204": // "$ref": "#/responses/empty" - err := repo_model.WatchRepo(ctx.User.ID, ctx.Repo.Repository.ID, false) + err := repo_model.WatchRepo(ctx.Doer.ID, ctx.Repo.Repository.ID, false) if err != nil { ctx.Error(http.StatusInternalServerError, "UnwatchRepo", err) return |