fix(tasks): recover deleted captures without reviving tombstones
This commit is contained in:
1 parent
43a2d8c5a1
commit
4049acf76e
10 files changed
+594
-28
No files matched your search
@@ -56,20 +56,21 @@ func applyTaskReminderDefaults(item *store.TaskRecord, p store.TaskPreferences)
|
||||
}
|
||||
|
||||
type taskCaptureInput struct {
|
||||
RequestID string `json:"request_id"`
|
||||
Title string `json:"title"`
|
||||
Notes string `json:"notes"`
|
||||
ProjectUUID *string `json:"project_uuid"`
|
||||
AssigneeUUID *string `json:"assignee_uuid"`
|
||||
DueOn *string `json:"due_on"`
|
||||
StartOn *string `json:"start_on"`
|
||||
PlannedOn *string `json:"planned_on"`
|
||||
ReviewOn *string `json:"review_on"`
|
||||
Estimate *int `json:"estimate_minutes"`
|
||||
Complexity *int `json:"complexity"`
|
||||
WikiBody *string `json:"wiki_body,omitempty"`
|
||||
WikiPrefix *string `json:"wiki_prefix,omitempty"`
|
||||
WikiSuffix *string `json:"wiki_suffix,omitempty"`
|
||||
ReplacesDeleted string `json:"replaces_deleted,omitempty"`
|
||||
RequestID string `json:"request_id"`
|
||||
Title string `json:"title"`
|
||||
Notes string `json:"notes"`
|
||||
ProjectUUID *string `json:"project_uuid"`
|
||||
AssigneeUUID *string `json:"assignee_uuid"`
|
||||
DueOn *string `json:"due_on"`
|
||||
StartOn *string `json:"start_on"`
|
||||
PlannedOn *string `json:"planned_on"`
|
||||
ReviewOn *string `json:"review_on"`
|
||||
Estimate *int `json:"estimate_minutes"`
|
||||
Complexity *int `json:"complexity"`
|
||||
WikiBody *string `json:"wiki_body,omitempty"`
|
||||
WikiPrefix *string `json:"wiki_prefix,omitempty"`
|
||||
WikiSuffix *string `json:"wiki_suffix,omitempty"`
|
||||
}
|
||||
|
||||
func (s *Server) handleTaskProductivity(w http.ResponseWriter, r *http.Request, actor string, active bool, kind string) {
|
||||
@@ -197,6 +198,13 @@ func (s *Server) handleTaskProductivity(w http.ResponseWriter, r *http.Request,
|
||||
taskError(w, store.ErrTaskInvalid)
|
||||
return
|
||||
}
|
||||
if input.ReplacesDeleted != "" {
|
||||
id, err := uuid.Parse(input.ReplacesDeleted)
|
||||
if err != nil || id.String() != input.ReplacesDeleted || input.RequestID != store.TaskRecreationID(input.ReplacesDeleted) {
|
||||
taskError(w, store.ErrTaskInvalid)
|
||||
return
|
||||
}
|
||||
}
|
||||
raw, _ := json.Marshal(input)
|
||||
hash := sha256.Sum256(raw)
|
||||
requestHash := hex.EncodeToString(hash[:])
|
||||
@@ -261,7 +269,11 @@ func (s *Server) handleTaskProductivity(w http.ResponseWriter, r *http.Request,
|
||||
taskError(w, store.ErrTaskInvalid)
|
||||
return
|
||||
}
|
||||
target = store.TaskCaptureWikiPath(prefix, item.Title, input.RequestID)
|
||||
pathID := input.RequestID
|
||||
if input.ReplacesDeleted != "" {
|
||||
pathID = input.ReplacesDeleted
|
||||
}
|
||||
target = store.TaskCaptureWikiPath(prefix, item.Title, pathID)
|
||||
if input.WikiSuffix != nil {
|
||||
if !store.ValidTaskMailSuffix(*input.WikiSuffix) {
|
||||
taskError(w, store.ErrTaskInvalid)
|
||||
@@ -280,7 +292,11 @@ func (s *Server) handleTaskProductivity(w http.ResponseWriter, r *http.Request,
|
||||
taskError(w, store.ErrTaskInvalid)
|
||||
return
|
||||
}
|
||||
item, err = s.store.CaptureTaskWithWiki(r.Context(), domain, actor, input.RequestID, requestHash, item, target, body)
|
||||
if input.ReplacesDeleted != "" {
|
||||
item, err = s.store.RecreateCapturedTask(r.Context(), domain, actor, input.RequestID, requestHash, item, target, body, input.ReplacesDeleted)
|
||||
} else {
|
||||
item, err = s.store.CaptureTaskWithWiki(r.Context(), domain, actor, input.RequestID, requestHash, item, target, body)
|
||||
}
|
||||
if err != nil {
|
||||
taskError(w, err)
|
||||
return
|
||||
|
||||
Reference in new issue
Block a user