Commit 34657cd973
Verified · cmc
internal/httpd/page.go +1 −17
| @@ -3,21 +3,13 @@ package httpd | ||
| 3 | 3 | import ( |
| 4 | 4 | "net/http" |
| 5 | 5 | |
| 6 | "gitbay.org/gitbay/internal/policy" | |
| 7 | 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 | 9 | // rail is the viewer's cross-repo state the layout needs. The rail itself |
| 17 | 10 | // is icons only, so what is left is the unread count on its bell; the |
| 18 | 11 | // pinned repositories it used to list are rendered by the dashboard. |
| 19 | 12 | type rail struct { |
| 20 | Pinned []railRepo | |
| 21 | 13 | Unread int |
| 22 | 14 | } |
| 23 | 15 | |
| @@ -61,17 +53,9 @@ func (s *Server) baseFor(viewer store.User) basePage { | ||
| 61 | 53 | return b |
| 62 | 54 | } |
| 63 | 55 | |
| 64 | // railFor collects the viewer's pinned repositories and unread count, | |
| 65 | // dropping anything they may no longer read. | |
| 56 | // railFor collects the viewer's unread count. | |
| 66 | 57 | func (s *Server) railFor(viewer store.User) rail { |
| 67 | 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 | 59 | rl.Unread = s.st.UnreadNotices(viewer.ID) |
| 76 | 60 | return rl |
| 77 | 61 | } |