feat(triage): implement Quick Dump notes, direct task/list assignment, and fix stale JWT user resolution
MindSift CI & Docker Release / Build, Test in Container & Push (push) Successful in 53s
MindSift CI & Docker Release / Build, Test in Container & Push (push) Successful in 53s
This commit is contained in:
1 parent
2d4a2bde41
commit
d6bc2976d9
7 files changed
+695
-196
No files matched your search
+31
-6
@@ -149,7 +149,13 @@ func (s *Server) authMiddleware(next http.Handler) http.Handler {
|
||||
}
|
||||
claims, err := auth.ValidateToken(s.cfg.JWTSecret, tokenStr)
|
||||
if err == nil && claims != nil {
|
||||
next.ServeHTTP(w, r.WithContext(auth.WithUserID(r.Context(), claims.UserID)))
|
||||
userID := claims.UserID
|
||||
if _, userErr := s.store.GetUserByID(userID); userErr != nil {
|
||||
if defUser, defErr := s.store.EnsureDefaultUser(); defErr == nil && defUser != nil {
|
||||
userID = defUser.ID
|
||||
}
|
||||
}
|
||||
next.ServeHTTP(w, r.WithContext(auth.WithUserID(r.Context(), userID)))
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -304,11 +310,14 @@ func (s *Server) handleStats(w http.ResponseWriter, r *http.Request) {
|
||||
func (s *Server) handleCaptureInbox(w http.ResponseWriter, r *http.Request) {
|
||||
userID := auth.GetUserID(r.Context())
|
||||
var req struct {
|
||||
Content string `json:"content"`
|
||||
Priority string `json:"priority"`
|
||||
Source string `json:"source"`
|
||||
DueDate string `json:"dueDate"`
|
||||
DueDate2 string `json:"due_date"` // Compatibility with snake_case README example
|
||||
Content string `json:"content"`
|
||||
Priority string `json:"priority"`
|
||||
Source string `json:"source"`
|
||||
DueDate string `json:"dueDate"`
|
||||
DueDate2 string `json:"due_date"` // Compatibility with snake_case README example
|
||||
Target string `json:"target"` // inbox | task | list_item | document
|
||||
TargetListID string `json:"targetListId"`
|
||||
TargetList2 string `json:"target_list_id"`
|
||||
}
|
||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||
writeError(w, http.StatusBadRequest, "Ungültiges JSON")
|
||||
@@ -318,6 +327,10 @@ func (s *Server) handleCaptureInbox(w http.ResponseWriter, r *http.Request) {
|
||||
if dueDate == "" {
|
||||
dueDate = req.DueDate2
|
||||
}
|
||||
targetListID := req.TargetListID
|
||||
if targetListID == "" {
|
||||
targetListID = req.TargetList2
|
||||
}
|
||||
|
||||
thought, err := s.store.CreateThought(userID, req.Content, req.Priority, req.Source, dueDate)
|
||||
if err != nil {
|
||||
@@ -325,6 +338,18 @@ func (s *Server) handleCaptureInbox(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
target := strings.TrimSpace(req.Target)
|
||||
if target == "task" || target == "document" || (target == "list_item" && targetListID != "") {
|
||||
if converted, convErr := s.store.UpdateThoughtTriage(userID, thought.ID, "keep", target, targetListID, dueDate); convErr == nil && converted != nil {
|
||||
thought = converted
|
||||
if target == "list_item" && targetListID != "" {
|
||||
if lst, lErr := s.store.GetListByID(targetListID); lErr == nil && lst != nil {
|
||||
s.wsHub.Broadcast(lst.SpaceID, lst.ID, "ITEM_CREATED", lst)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
writeJSON(w, http.StatusCreated, thought)
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user