Add subtask model and repository, implement webhook notification handling
fix Issue with Scheduler Support NotificationPlatformWebhook support Discord as notification target
This commit is contained in:
parent
8db572f1ec
commit
81acbd8eba
8 changed files with 136 additions and 11 deletions
|
@ -243,7 +243,6 @@ func (h *Handler) createChore(c *gin.Context) {
|
|||
stringLabels = &labels
|
||||
}
|
||||
createdChore := &chModel.Chore{
|
||||
|
||||
Name: choreReq.Name,
|
||||
FrequencyType: choreReq.FrequencyType,
|
||||
Frequency: choreReq.Frequency,
|
||||
|
@ -264,6 +263,7 @@ func (h *Handler) createChore(c *gin.Context) {
|
|||
CompletionWindow: choreReq.CompletionWindow,
|
||||
Description: choreReq.Description,
|
||||
SubTasks: choreReq.SubTasks,
|
||||
Priority: choreReq.Priority,
|
||||
}
|
||||
id, err := h.choreRepo.CreateChore(c, createdChore)
|
||||
createdChore.ID = id
|
||||
|
@ -547,6 +547,7 @@ func (h *Handler) editChore(c *gin.Context) {
|
|||
if choreReq.SubTasks == nil {
|
||||
choreReq.SubTasks = &[]stModel.SubTask{}
|
||||
}
|
||||
// check what subtask needed to be removed:
|
||||
for _, existedSubTask := range *oldChore.SubTasks {
|
||||
found := false
|
||||
for _, newSubTask := range *choreReq.SubTasks {
|
||||
|
@ -559,14 +560,16 @@ func (h *Handler) editChore(c *gin.Context) {
|
|||
ToBeRemoved = append(ToBeRemoved, existedSubTask)
|
||||
}
|
||||
}
|
||||
|
||||
// check what subtask needed to be added or updated:
|
||||
for _, newSubTask := range *choreReq.SubTasks {
|
||||
found := false
|
||||
newSubTask.ChoreID = oldChore.ID
|
||||
|
||||
for _, existedSubTask := range *oldChore.SubTasks {
|
||||
if existedSubTask.ID == newSubTask.ID {
|
||||
if existedSubTask.Name != newSubTask.Name || existedSubTask.OrderID != newSubTask.OrderID {
|
||||
if existedSubTask.Name != newSubTask.Name ||
|
||||
existedSubTask.OrderID != newSubTask.OrderID ||
|
||||
existedSubTask.ParentId != newSubTask.ParentId {
|
||||
// there is a change in the subtask, update it
|
||||
break
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue