feat(call): add media type support to call invite functionality
All checks were successful
Build Backend / build (push) Successful in 12m57s
Build Backend / build-docker (push) Successful in 1m15s

- Updated the WSHandler to include a media type field in the call invite request, allowing differentiation between voice and video calls.
- Modified the CallService interface and implementation to accept the media type parameter during call invitations, enhancing call handling capabilities.
This commit is contained in:
lafay
2026-03-28 01:01:22 +08:00
parent bac3cbbf60
commit 63cfbad65c
2 changed files with 11 additions and 3 deletions

View File

@@ -450,6 +450,7 @@ func (h *WSHandler) handleCallInvite(ctx context.Context, client *ws.Client, pay
var req struct {
CalleeID string `json:"callee_id"`
ConversationID string `json:"conversation_id"`
MediaType string `json:"call_type"` // voice 或 video
}
if err := json.Unmarshal(payload, &req); err != nil {
h.wsHub.SendError(client, "parse_error", "invalid call_invite format")
@@ -460,7 +461,13 @@ func (h *WSHandler) handleCallInvite(ctx context.Context, client *ws.Client, pay
return
}
call, err := h.callService.Invite(ctx, client.UserID, req.CalleeID, req.ConversationID)
// 前端传的 call_type 是 voice/video默认为 voice
mediaType := req.MediaType
if mediaType != "video" {
mediaType = "voice"
}
call, err := h.callService.Invite(ctx, client.UserID, req.CalleeID, req.ConversationID, mediaType)
if err != nil {
zap.L().Warn("Failed to invite call",
zap.String("caller_id", client.UserID),