課題作成時にもTelegram/LINEに通知する機能を追加
This commit is contained in:
@@ -14,12 +14,14 @@ import (
|
||||
)
|
||||
|
||||
type AssignmentHandler struct {
|
||||
assignmentService *service.AssignmentService
|
||||
assignmentService *service.AssignmentService
|
||||
notificationService *service.NotificationService
|
||||
}
|
||||
|
||||
func NewAssignmentHandler() *AssignmentHandler {
|
||||
func NewAssignmentHandler(notificationService *service.NotificationService) *AssignmentHandler {
|
||||
return &AssignmentHandler{
|
||||
assignmentService: service.NewAssignmentService(),
|
||||
assignmentService: service.NewAssignmentService(),
|
||||
notificationService: notificationService,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -229,7 +231,7 @@ func (h *AssignmentHandler) Create(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
_, err = h.assignmentService.Create(userID, title, description, subject, priority, dueDate, reminderEnabled, reminderAt, urgentReminderEnabled)
|
||||
assignment, err := h.assignmentService.Create(userID, title, description, subject, priority, dueDate, reminderEnabled, reminderAt, urgentReminderEnabled)
|
||||
if err != nil {
|
||||
role, _ := c.Get(middleware.UserRoleKey)
|
||||
name, _ := c.Get(middleware.UserNameKey)
|
||||
@@ -245,6 +247,10 @@ func (h *AssignmentHandler) Create(c *gin.Context) {
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if h.notificationService != nil {
|
||||
go h.notificationService.SendAssignmentCreatedNotification(userID, assignment)
|
||||
}
|
||||
}
|
||||
|
||||
c.Redirect(http.StatusFound, "/assignments")
|
||||
|
||||
Reference in New Issue
Block a user