diff options
author | Ethan Koenig <ethantkoenig@gmail.com> | 2017-08-22 22:51:58 -0700 |
---|---|---|
committer | Lauris BH <lauris@nix.lv> | 2017-08-23 08:51:58 +0300 |
commit | fd6e91077a0ee91621871441ab0de2cf08d8d77f (patch) | |
tree | cf3b91120d8e9de50c7d449ba5f0b224c456a4fd | |
parent | 9413b48a0b89fe2639378ca75bf1810c4a076374 (diff) | |
download | gitea-fd6e91077a0ee91621871441ab0de2cf08d8d77f.tar.gz gitea-fd6e91077a0ee91621871441ab0de2cf08d8d77f.zip |
Fix SQL condition bug in GetFeeds(..) (#2360)
-rw-r--r-- | models/action.go | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/models/action.go b/models/action.go index 595be92f76..43ed9cc1da 100644 --- a/models/action.go +++ b/models/action.go @@ -733,12 +733,13 @@ func GetFeeds(opts GetFeedsOptions) ([]*Action, error) { cond = cond.And(builder.In("repo_id", repoIDs)) } + var userIDCond builder.Cond = builder.Eq{"user_id": opts.RequestedUser.ID} if opts.Collaborate { - cond = builder.Eq{"user_id": opts.RequestedUser.ID}.Or( - builder.Expr(`repo_id IN (SELECT repo_id FROM "access" WHERE access.user_id = ?)`, opts.RequestedUser.ID)) - } else { - cond = builder.Eq{"user_id": opts.RequestedUser.ID} + userIDCond = userIDCond.Or(builder.Expr( + `repo_id IN (SELECT repo_id FROM "access" WHERE access.user_id = ?)`, + opts.RequestedUser.ID)) } + cond = cond.And(userIDCond) if opts.OnlyPerformedBy { cond = cond.And(builder.Eq{"act_user_id": opts.RequestedUser.ID}) |