feat(call): implement group calling and enhance call management
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:
@@ -9,11 +9,12 @@ import (
|
||||
)
|
||||
|
||||
type GradeRepository interface {
|
||||
ListByUserAndSemester(userID, semester string) ([]*model.Grade, error)
|
||||
DeleteByUserAndSemester(ctx context.Context, userID, semester string) error
|
||||
ListByUser(userID string) ([]*model.Grade, error)
|
||||
DeleteByUser(ctx context.Context, userID string) error
|
||||
BatchCreate(ctx context.Context, grades []*model.Grade) error
|
||||
GetGpaSummary(userID, semester string) (*model.GpaSummary, error)
|
||||
GetLatestGpaSummary(userID string) (*model.GpaSummary, error)
|
||||
SaveGpaSummary(ctx context.Context, summary *model.GpaSummary) error
|
||||
DeleteGpaSummaryByUser(ctx context.Context, userID string) error
|
||||
}
|
||||
|
||||
type gradeRepository struct {
|
||||
@@ -24,17 +25,17 @@ func NewGradeRepository(db *gorm.DB) GradeRepository {
|
||||
return &gradeRepository{db: db}
|
||||
}
|
||||
|
||||
func (r *gradeRepository) ListByUserAndSemester(userID, semester string) ([]*model.Grade, error) {
|
||||
func (r *gradeRepository) ListByUser(userID string) ([]*model.Grade, error) {
|
||||
var grades []*model.Grade
|
||||
err := r.db.Where("user_id = ? AND term = ?", userID, semester).
|
||||
Order("created_at ASC").
|
||||
err := r.db.Where("user_id = ?", userID).
|
||||
Order("term DESC, created_at ASC").
|
||||
Find(&grades).Error
|
||||
return grades, err
|
||||
}
|
||||
|
||||
func (r *gradeRepository) DeleteByUserAndSemester(ctx context.Context, userID, semester string) error {
|
||||
func (r *gradeRepository) DeleteByUser(ctx context.Context, userID string) error {
|
||||
return r.db.WithContext(ctx).
|
||||
Where("user_id = ? AND term = ?", userID, semester).
|
||||
Where("user_id = ?", userID).
|
||||
Delete(&model.Grade{}).Error
|
||||
}
|
||||
|
||||
@@ -42,9 +43,11 @@ func (r *gradeRepository) BatchCreate(ctx context.Context, grades []*model.Grade
|
||||
return r.db.WithContext(ctx).CreateInBatches(grades, 100).Error
|
||||
}
|
||||
|
||||
func (r *gradeRepository) GetGpaSummary(userID, semester string) (*model.GpaSummary, error) {
|
||||
func (r *gradeRepository) GetLatestGpaSummary(userID string) (*model.GpaSummary, error) {
|
||||
var summary model.GpaSummary
|
||||
err := r.db.Where("user_id = ? AND semester = ?", userID, semester).First(&summary).Error
|
||||
err := r.db.Where("user_id = ?", userID).
|
||||
Order("updated_at DESC").
|
||||
First(&summary).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -54,3 +57,9 @@ func (r *gradeRepository) GetGpaSummary(userID, semester string) (*model.GpaSumm
|
||||
func (r *gradeRepository) SaveGpaSummary(ctx context.Context, summary *model.GpaSummary) error {
|
||||
return r.db.WithContext(ctx).Save(summary).Error
|
||||
}
|
||||
|
||||
func (r *gradeRepository) DeleteGpaSummaryByUser(ctx context.Context, userID string) error {
|
||||
return r.db.WithContext(ctx).
|
||||
Where("user_id = ?", userID).
|
||||
Delete(&model.GpaSummary{}).Error
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user