1
0
mirror of https://github.com/go-gitea/gitea.git synced 2024-10-30 08:27:32 -04:00

Fix SQL condition bug in GetFeeds(..) (#2360)

This commit is contained in:
Ethan Koenig 2017-08-22 22:51:58 -07:00 committed by Lauris BH
parent 9413b48a0b
commit fd6e91077a

View File

@ -733,12 +733,13 @@ func GetFeeds(opts GetFeedsOptions) ([]*Action, error) {
cond = cond.And(builder.In("repo_id", repoIDs)) cond = cond.And(builder.In("repo_id", repoIDs))
} }
var userIDCond builder.Cond = builder.Eq{"user_id": opts.RequestedUser.ID}
if opts.Collaborate { if opts.Collaborate {
cond = builder.Eq{"user_id": opts.RequestedUser.ID}.Or( userIDCond = userIDCond.Or(builder.Expr(
builder.Expr(`repo_id IN (SELECT repo_id FROM "access" WHERE access.user_id = ?)`, opts.RequestedUser.ID)) `repo_id IN (SELECT repo_id FROM "access" WHERE access.user_id = ?)`,
} else { opts.RequestedUser.ID))
cond = builder.Eq{"user_id": opts.RequestedUser.ID}
} }
cond = cond.And(userIDCond)
if opts.OnlyPerformedBy { if opts.OnlyPerformedBy {
cond = cond.And(builder.Eq{"act_user_id": opts.RequestedUser.ID}) cond = cond.And(builder.Eq{"act_user_id": opts.RequestedUser.ID})