Send error response when update metadata fails. (#2849)
Keeping it simple for the first implementation. - Send error response only if request_id != 0 - Two kinds of errors notified o does not have permissions - NOT_ALLOWED o attributes exceeds size limits - INVALID_ARGUMENT
This commit is contained in:
@@ -92,6 +92,7 @@ func HandleParticipantSignal(room types.Room, participant types.LocalParticipant
|
||||
}
|
||||
|
||||
case *livekit.SignalRequest_UpdateMetadata:
|
||||
var errorResponse *livekit.ErrorResponse
|
||||
if participant.ClaimGrants().Video.GetCanUpdateOwnMetadata() {
|
||||
err := room.UpdateParticipantMetadata(
|
||||
participant,
|
||||
@@ -101,7 +102,25 @@ func HandleParticipantSignal(room types.Room, participant types.LocalParticipant
|
||||
)
|
||||
if err != nil {
|
||||
pLogger.Warnw("could not update metadata", err)
|
||||
|
||||
switch err {
|
||||
case ErrAttributeExceedsLimits:
|
||||
errorResponse = &livekit.ErrorResponse{
|
||||
Reason: livekit.ErrorResponse_INVALID_ARGUMENT,
|
||||
Message: "exceeds attributes size limit",
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
errorResponse = &livekit.ErrorResponse{
|
||||
Reason: livekit.ErrorResponse_NOT_ALLOWED,
|
||||
Message: "does not have permission to update own metadata",
|
||||
}
|
||||
}
|
||||
if errorResponse != nil {
|
||||
errorResponse.RequestId = msg.UpdateMetadata.RequestId
|
||||
participant.SendErrorResponse(errorResponse)
|
||||
}
|
||||
|
||||
case *livekit.SignalRequest_UpdateAudioTrack:
|
||||
|
||||
Reference in New Issue
Block a user