Files
backend/internal/handler/call_handler.go
lan 14114db68d
All checks were successful
Build Backend / build (push) Successful in 3m47s
Build Backend / build-docker (push) Successful in 5m9s
feat(call): integrate LiveKit for voice and video calling
Replace the manual WebRTC signaling implementation with LiveKit SFU. This includes:
- Adding LiveKit service, handler, and configuration.
- Updating Docker Compose to include LiveKit server, Redis, and PostgreSQL.
- Refactoring `CallService` and `WSHandler` to support LiveKit room readiness instead of raw SDP/ICE relaying.
- Adding new API endpoints for LiveKit token generation and webhooks.
- Removing deprecated WebRTC configuration and manual signaling DTOs.
2026-06-01 13:41:02 +08:00

52 lines
1.1 KiB
Go

package handler
import (
"strconv"
"github.com/gin-gonic/gin"
"with_you/internal/pkg/response"
"with_you/internal/service"
)
// CallHandler 通话记录处理器
type CallHandler struct {
callService service.CallService
}
// NewCallHandler 创建通话处理器
func NewCallHandler(callService service.CallService) *CallHandler {
return &CallHandler{callService: callService}
}
// GetCallHistory 获取通话记录
// GET /api/v1/calls/history?page=1&page_size=20
func (h *CallHandler) GetCallHistory(c *gin.Context) {
userID, exists := c.Get("user_id")
if !exists {
response.Unauthorized(c, "unauthorized")
return
}
page, _ := strconv.Atoi(c.DefaultQuery("page", "1"))
pageSize, _ := strconv.Atoi(c.DefaultQuery("page_size", "20"))
if page < 1 {
page = 1
}
if pageSize < 1 || pageSize > 50 {
pageSize = 20
}
calls, total, err := h.callService.GetCallHistory(c.Request.Context(), userID.(string), page, pageSize)
if err != nil {
response.InternalServerError(c, "failed to get call history")
return
}
response.Success(c, gin.H{
"items": calls,
"total": total,
"page": page,
})
}