Browse Source

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

for-closed-social
Ethan Koenig 7 years ago
committed by Lauris BH
parent
commit
fd6e91077a
1 changed files with 5 additions and 4 deletions
  1. +5
    -4
      models/action.go

+ 5
- 4
models/action.go View File

@ -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})

Loading…
Cancel
Save