mirror of
https://github.com/go-gitea/gitea
synced 2024-11-19 16:19:25 +01:00
migration
This commit is contained in:
parent
d1e3a6ce77
commit
18e74749ab
@ -487,14 +487,17 @@ func activityQueryCondition(ctx context.Context, opts GetFeedsOptions) (builder.
|
||||
if opts.Actor == nil {
|
||||
cond = cond.And(builder.In("act_user_id",
|
||||
builder.Select("`user`.id").Where(
|
||||
builder.Eq{"keep_activity_private": false, "visibility": structs.VisibleTypePublic},
|
||||
builder.Eq{"visibility": structs.VisibleTypePublic},
|
||||
).Where(
|
||||
builder.Neq{"actions_visibility": structs.ActionsVisibilityNone},
|
||||
).From("`user`"),
|
||||
))
|
||||
} else if !opts.Actor.IsAdmin {
|
||||
uidCond := builder.Select("`user`.id").From("`user`").Where(
|
||||
builder.Eq{"keep_activity_private": false}.
|
||||
And(builder.In("visibility", structs.VisibleTypePublic, structs.VisibleTypeLimited))).
|
||||
Or(builder.Eq{"id": opts.Actor.ID})
|
||||
builder.Neq{"actions_visibility": structs.ActionsVisibilityNone},
|
||||
).Where(
|
||||
builder.In("visibility", structs.VisibleTypePublic, structs.VisibleTypeLimited),
|
||||
).Or(builder.Eq{"id": opts.Actor.ID})
|
||||
|
||||
if opts.RequestedUser != nil {
|
||||
if opts.RequestedUser.IsOrganization() {
|
||||
|
@ -558,6 +558,8 @@ var migrations = []Migration{
|
||||
NewMigration("Add PreviousDuration to ActionRun", v1_22.AddPreviousDurationToActionRun),
|
||||
// v286 -> v287
|
||||
NewMigration("Add support for SHA256 git repositories", v1_22.AdjustDBForSha256),
|
||||
// v287 -> v288
|
||||
NewMigration("Add change KeepActivityPrivate to AddActionsVisibility", v1_22.AddActionsVisibility),
|
||||
}
|
||||
|
||||
// GetCurrentDBVersion returns the current db version
|
||||
|
36
models/migrations/v1_22/v287.go
Normal file
36
models/migrations/v1_22/v287.go
Normal file
@ -0,0 +1,36 @@
|
||||
// Copyright 2023 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package v1_22 //nolint
|
||||
|
||||
import (
|
||||
"code.gitea.io/gitea/models/migrations/base"
|
||||
"code.gitea.io/gitea/modules/structs"
|
||||
|
||||
"code.gitea.io/gitea/models/user"
|
||||
|
||||
"xorm.io/builder"
|
||||
"xorm.io/xorm"
|
||||
)
|
||||
|
||||
func AddActionsVisibility(x *xorm.Engine) error {
|
||||
sess := x.NewSession()
|
||||
defer sess.Close()
|
||||
|
||||
if err := sess.Begin(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if _, err := sess.
|
||||
Where(builder.Eq{"keep_activity_private": 1}).
|
||||
Cols("actions_visibility").
|
||||
Update(user.User{ActionsVisibility: structs.ActionsVisibilityNone}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := base.DropTableColumns(sess, "user", "keep_activity_private"); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return sess.Commit()
|
||||
}
|
Loading…
Reference in New Issue
Block a user