- #{{ $oneIndexedRound }}
+ #{{ .RoundNumber }}
@@ -93,7 +92,7 @@
{{$re}}submitted
by
{{ $owner }}
-
+
{{ $s := "s" }}
{{ if eq (len .Comments) 1 }}
diff --git a/appview/state/pull.go b/appview/state/pull.go
index 4bd8e6f..3d37ecd 100644
--- a/appview/state/pull.go
+++ b/appview/state/pull.go
@@ -221,6 +221,37 @@ func (s *State) RepoPullPatch(w http.ResponseWriter, r *http.Request) {
}
+func (s *State) RepoPullPatchRaw(w http.ResponseWriter, r *http.Request) {
+ pull, ok := r.Context().Value("pull").(*db.Pull)
+ if !ok {
+ log.Println("failed to get pull")
+ s.pages.Notice(w, "pull-error", "Failed to edit patch. Try again later.")
+ return
+ }
+
+ roundId := chi.URLParam(r, "round")
+ roundIdInt, err := strconv.Atoi(roundId)
+ if err != nil || roundIdInt >= len(pull.Submissions) {
+ http.Error(w, "bad round id", http.StatusBadRequest)
+ log.Println("failed to parse round id", err)
+ return
+ }
+
+ identsToResolve := []string{pull.OwnerDid}
+ resolvedIds := s.resolver.ResolveIdents(r.Context(), identsToResolve)
+ didHandleMap := make(map[string]string)
+ for _, identity := range resolvedIds {
+ if !identity.Handle.IsInvalidHandle() {
+ didHandleMap[identity.DID.String()] = fmt.Sprintf("@%s", identity.Handle.String())
+ } else {
+ didHandleMap[identity.DID.String()] = identity.DID.String()
+ }
+ }
+
+ w.Header().Set("Content-Type", "text/plain")
+ w.Write([]byte(pull.Submissions[roundIdInt].Patch))
+}
+
func (s *State) RepoPulls(w http.ResponseWriter, r *http.Request) {
user := s.auth.GetUser(r)
params := r.URL.Query()
diff --git a/appview/state/router.go b/appview/state/router.go
index 92bf574..a19b750 100644
--- a/appview/state/router.go
+++ b/appview/state/router.go
@@ -98,6 +98,10 @@ func (s *State) UserRouter() http.Handler {
})
})
+ r.Route("/round/{round}.patch", func(r chi.Router) {
+ r.Get("/", s.RepoPullPatchRaw)
+ })
+
// authorized requests below this point
r.Group(func(r chi.Router) {
r.Use(AuthMiddleware(s))