feat(call): implement group calling and enhance call management
All checks were successful
Build Backend / build (push) Successful in 2m14s
Build Backend / build-docker (push) Successful in 1m15s

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.
This commit is contained in:
2026-06-07 00:11:47 +08:00
parent c741a7d61d
commit 60654bc0f4
11 changed files with 394 additions and 69 deletions

View File

@@ -81,7 +81,7 @@ func (s *gradeSyncService) SyncUserGrades(ctx context.Context, userID string, re
}
grades := s.convertGrades(userID, &resultData)
if err := s.saveGrades(ctx, userID, resultData.Semester, grades); err != nil {
if err := s.saveGrades(ctx, userID, grades); err != nil {
s.logger.Error("failed to save grades",
zap.String("user_id", userID),
zap.Error(err))
@@ -89,7 +89,12 @@ func (s *gradeSyncService) SyncUserGrades(ctx context.Context, userID string, re
}
if resultData.GpaSummary != nil {
summary := s.convertGpaSummary(userID, resultData.Semester, resultData.GpaSummary)
if err := s.gradeRepo.DeleteGpaSummaryByUser(ctx, userID); err != nil {
s.logger.Warn("failed to delete old gpa summary",
zap.String("user_id", userID),
zap.Error(err))
}
summary := s.convertGpaSummary(userID, resultData.GpaSummary)
if err := s.gradeRepo.SaveGpaSummary(ctx, summary); err != nil {
s.logger.Warn("failed to save gpa summary",
zap.String("user_id", userID),
@@ -128,11 +133,11 @@ func (s *gradeSyncService) convertGrades(userID string, data *pb.GradesResultDat
return grades
}
func (s *gradeSyncService) convertGpaSummary(userID, semester string, gpa *pb.GpaSummary) *model.GpaSummary {
func (s *gradeSyncService) convertGpaSummary(userID string, gpa *pb.GpaSummary) *model.GpaSummary {
return &model.GpaSummary{
ID: uuid.New().String(),
UserID: userID,
Semester: semester,
Semester: gpa.Semesters,
AverageGpa: gpa.AverageGpa,
Rank: gpa.Rank,
ExamTotalGpa: gpa.ExamTotalGpa,
@@ -142,8 +147,8 @@ func (s *gradeSyncService) convertGpaSummary(userID, semester string, gpa *pb.Gp
}
}
func (s *gradeSyncService) saveGrades(ctx context.Context, userID, semester string, grades []*model.Grade) error {
if err := s.gradeRepo.DeleteByUserAndSemester(ctx, userID, semester); err != nil {
func (s *gradeSyncService) saveGrades(ctx context.Context, userID string, grades []*model.Grade) error {
if err := s.gradeRepo.DeleteByUser(ctx, userID); err != nil {
return fmt.Errorf("failed to delete old grades: %w", err)
}
if len(grades) == 0 {