diff options
author | Joe Chen <jc@unknwon.io> | 2022-06-25 18:07:39 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-25 18:07:39 +0800 |
commit | 083c3ee659c6c5542687f3bafae68cbc24dbc90f (patch) | |
tree | 0103bf3b5c5ebfccd368a7cb6a425a521fd669d9 /internal/route/user/home.go | |
parent | 9df4e3ae3c555a86f691f0d78a43834842e77d8b (diff) |
db: refactor "action" table to use GORM (#7054)
Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
Diffstat (limited to 'internal/route/user/home.go')
-rw-r--r-- | internal/route/user/home.go | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/internal/route/user/home.go b/internal/route/user/home.go index a7892075..a14572ed 100644 --- a/internal/route/user/home.go +++ b/internal/route/user/home.go @@ -53,9 +53,17 @@ func getDashboardContextUser(c *context.Context) *db.User { // The user could be organization so it is not always the logged in user, // which is why we have to explicitly pass the context user ID. func retrieveFeeds(c *context.Context, ctxUser *db.User, userID int64, isProfile bool) { - actions, err := db.GetFeeds(ctxUser, userID, c.QueryInt64("after_id"), isProfile) + afterID := c.QueryInt64("after_id") + + var err error + var actions []*db.Action + if ctxUser.IsOrganization() { + actions, err = db.Actions.ListByOrganization(c.Req.Context(), ctxUser.ID, userID, afterID) + } else { + actions, err = db.Actions.ListByUser(c.Req.Context(), ctxUser.ID, userID, afterID, isProfile) + } if err != nil { - c.Error(err, "get feeds") + c.Error(err, "list actions") return } |