Introduces group calling capabilities, including group invites and participant lifecycle management. Enhances the existing call system with support for media types (voice/video) and improved participant tracking. - Add `GroupInvite` and `ParticipantJoin/Leave` to `CallService`. - Implement WebSocket handlers for `call_group_invite` and `call_participant_join`. - Update `CallSession` model to support group IDs, media types, and tracking who ended the call. - Integrate `GroupService` into `CallService` via dependency injection. - Add error constants for group call limitations and participant capacity. - Update LiveKit webhook handling to process participant leave events. Refactor grade synchronization to remove semester-based filtering in favor of a more flexible user-based approach and improve GPA summary updates.
79 lines
1.7 KiB
Go
79 lines
1.7 KiB
Go
package handler
|
|
|
|
import (
|
|
"github.com/gin-gonic/gin"
|
|
|
|
"with_you/internal/pkg/response"
|
|
"with_you/internal/repository"
|
|
"with_you/internal/service"
|
|
)
|
|
|
|
type GradeHandler struct {
|
|
gradeSyncService service.GradeSyncService
|
|
gradeRepo repository.GradeRepository
|
|
}
|
|
|
|
func NewGradeHandler(gradeSyncService service.GradeSyncService, gradeRepo repository.GradeRepository) *GradeHandler {
|
|
return &GradeHandler{
|
|
gradeSyncService: gradeSyncService,
|
|
gradeRepo: gradeRepo,
|
|
}
|
|
}
|
|
|
|
type syncGradesRequest struct {
|
|
Username string `json:"username" binding:"required"`
|
|
Password string `json:"password" binding:"required"`
|
|
Semester string `json:"semester"`
|
|
}
|
|
|
|
func (h *GradeHandler) SyncGrades(c *gin.Context) {
|
|
userID := c.GetString("user_id")
|
|
if userID == "" {
|
|
response.Unauthorized(c, "")
|
|
return
|
|
}
|
|
|
|
var req syncGradesRequest
|
|
if err := c.ShouldBindJSON(&req); err != nil {
|
|
response.BadRequest(c, "invalid request: "+err.Error())
|
|
return
|
|
}
|
|
|
|
result, err := h.gradeSyncService.SyncUserGrades(c.Request.Context(), userID, &service.SyncGradesRequest{
|
|
Username: req.Username,
|
|
Password: req.Password,
|
|
Semester: req.Semester,
|
|
})
|
|
if err != nil {
|
|
response.HandleError(c, err, "failed to sync grades")
|
|
return
|
|
}
|
|
|
|
if !result.Success {
|
|
response.Success(c, result)
|
|
return
|
|
}
|
|
response.SuccessWithMessage(c, result.Message, result)
|
|
}
|
|
|
|
func (h *GradeHandler) ListGrades(c *gin.Context) {
|
|
userID := c.GetString("user_id")
|
|
if userID == "" {
|
|
response.Unauthorized(c, "")
|
|
return
|
|
}
|
|
|
|
grades, err := h.gradeRepo.ListByUser(userID)
|
|
if err != nil {
|
|
response.HandleError(c, err, "failed to list grades")
|
|
return
|
|
}
|
|
|
|
gpaSummary, _ := h.gradeRepo.GetLatestGpaSummary(userID)
|
|
|
|
response.Success(c, gin.H{
|
|
"grades": grades,
|
|
"gpa_summary": gpaSummary,
|
|
})
|
|
}
|