Commit 34657cd973
Verified · cmc
Layout: unified · split
internal/httpd/page.go +1 −17
| @@ -3,21 +3,13 @@ package httpd | |||
| 3 | import ( | 3 | import ( |
| 4 | "net/http" | 4 | "net/http" |
| 5 | 5 | ||
| 6 | "gitbay.org/gitbay/internal/policy" | ||
| 7 | "gitbay.org/gitbay/internal/store" | 6 | "gitbay.org/gitbay/internal/store" |
| 8 | ) | 7 | ) |
| 9 | 8 | ||
| 10 | // railRepo is one pinned repository in the rail. | ||
| 11 | type railRepo struct { | ||
| 12 | Owner string | ||
| 13 | Name string | ||
| 14 | } | ||
| 15 | |||
| 16 | // rail is the viewer's cross-repo state the layout needs. The rail itself | 9 | // rail is the viewer's cross-repo state the layout needs. The rail itself |
| 17 | // is icons only, so what is left is the unread count on its bell; the | 10 | // is icons only, so what is left is the unread count on its bell; the |
| 18 | // pinned repositories it used to list are rendered by the dashboard. | 11 | // pinned repositories it used to list are rendered by the dashboard. |
| 19 | type rail struct { | 12 | type rail struct { |
| 20 | Pinned []railRepo | ||
| 21 | Unread int | 13 | Unread int |
| 22 | } | 14 | } |
| 23 | 15 | ||
| @@ -61,17 +53,9 @@ func (s *Server) baseFor(viewer store.User) basePage { | |||
| 61 | return b | 53 | return b |
| 62 | } | 54 | } |
| 63 | 55 | ||
| 64 | // railFor collects the viewer's pinned repositories and unread count, | 56 | // railFor collects the viewer's unread count. |
| 65 | // dropping anything they may no longer read. | ||
| 66 | func (s *Server) railFor(viewer store.User) rail { | 57 | func (s *Server) railFor(viewer store.User) rail { |
| 67 | var rl rail | 58 | var rl rail |
| 68 | pinned, _ := s.st.PinnedRepos(viewer.ID) | ||
| 69 | for _, rp := range pinned { | ||
| 70 | grant, _ := s.st.AccessRole(rp.ID, viewer.ID) | ||
| 71 | if policy.CanRead(viewer, rp, grant) { | ||
| 72 | rl.Pinned = append(rl.Pinned, railRepo{Owner: rp.OwnerName, Name: rp.Name}) | ||
| 73 | } | ||
| 74 | } | ||
| 75 | rl.Unread = s.st.UnreadNotices(viewer.ID) | 59 | rl.Unread = s.st.UnreadNotices(viewer.ID) |
| 76 | return rl | 60 | return rl |
| 77 | } | 61 | } |