Renamed ctx.User to ctx.Doer. (#19161)

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
KN4CK3R 2022-03-22 08:03:22 +01:00 committed by GitHub
parent 5495ba7660
commit 80fd25524e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
129 changed files with 881 additions and 881 deletions

View file

@ -22,7 +22,7 @@ func NewAvailable(ctx *context.APIContext) {
// responses:
// "200":
// "$ref": "#/responses/NotificationCount"
ctx.JSON(http.StatusOK, api.NotificationCount{New: models.CountUnread(ctx.User)})
ctx.JSON(http.StatusOK, api.NotificationCount{New: models.CountUnread(ctx.Doer)})
}
func getFindNotificationOptions(ctx *context.APIContext) *models.FindNotificationOptions {
@ -33,7 +33,7 @@ func getFindNotificationOptions(ctx *context.APIContext) *models.FindNotificatio
}
opts := &models.FindNotificationOptions{
ListOptions: utils.GetListOptions(ctx),
UserID: ctx.User.ID,
UserID: ctx.Doer.ID,
UpdatedBeforeUnix: before,
UpdatedAfterUnix: since,
}

View file

@ -193,7 +193,7 @@ func ReadRepoNotifications(ctx *context.APIContext) {
}
opts := &models.FindNotificationOptions{
UserID: ctx.User.ID,
UserID: ctx.Doer.ID,
RepoID: ctx.Repo.Repository.ID,
UpdatedBeforeUnix: lastRead,
}
@ -217,7 +217,7 @@ func ReadRepoNotifications(ctx *context.APIContext) {
changed := make([]*structs.NotificationThread, len(nl))
for _, n := range nl {
notif, err := models.SetNotificationStatus(n.ID, ctx.User, targetStatus)
notif, err := models.SetNotificationStatus(n.ID, ctx.Doer, targetStatus)
if err != nil {
ctx.InternalServerError(err)
return

View file

@ -87,7 +87,7 @@ func ReadThread(ctx *context.APIContext) {
targetStatus = models.NotificationStatusRead
}
notif, err := models.SetNotificationStatus(n.ID, ctx.User, targetStatus)
notif, err := models.SetNotificationStatus(n.ID, ctx.Doer, targetStatus)
if err != nil {
ctx.InternalServerError(err)
return
@ -109,7 +109,7 @@ func getThread(ctx *context.APIContext) *models.Notification {
}
return nil
}
if n.UserID != ctx.User.ID && !ctx.User.IsAdmin {
if n.UserID != ctx.Doer.ID && !ctx.Doer.IsAdmin {
ctx.Error(http.StatusForbidden, "GetNotificationByID", fmt.Errorf("only user itself and admin are allowed to read/change this thread %d", n.ID))
return nil
}

View file

@ -141,7 +141,7 @@ func ReadNotifications(ctx *context.APIContext) {
}
}
opts := &models.FindNotificationOptions{
UserID: ctx.User.ID,
UserID: ctx.Doer.ID,
UpdatedBeforeUnix: lastRead,
}
if !ctx.FormBool("all") {
@ -162,7 +162,7 @@ func ReadNotifications(ctx *context.APIContext) {
changed := make([]*structs.NotificationThread, 0, len(nl))
for _, n := range nl {
notif, err := models.SetNotificationStatus(n.ID, ctx.User, targetStatus)
notif, err := models.SetNotificationStatus(n.ID, ctx.Doer, targetStatus)
if err != nil {
ctx.InternalServerError(err)
return