Use cloned grants. (#2586)
To ensure no pointer (i. e. mutable object) is held in returned proto.
This commit is contained in:
@@ -503,19 +503,20 @@ func (p *ParticipantImpl) ToProtoWithVersion() (*livekit.ParticipantInfo, utils.
|
|||||||
p.timedVersion.Update(&piv)
|
p.timedVersion.Update(&piv)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
grants := p.ClaimGrants()
|
||||||
p.lock.RLock()
|
p.lock.RLock()
|
||||||
pi := &livekit.ParticipantInfo{
|
pi := &livekit.ParticipantInfo{
|
||||||
Sid: string(p.params.SID),
|
Sid: string(p.params.SID),
|
||||||
Identity: string(p.params.Identity),
|
Identity: string(p.params.Identity),
|
||||||
Name: p.grants.Name,
|
Name: grants.Name,
|
||||||
State: p.State(),
|
State: p.State(),
|
||||||
JoinedAt: p.ConnectedAt().Unix(),
|
JoinedAt: p.ConnectedAt().Unix(),
|
||||||
Version: v,
|
Version: v,
|
||||||
Permission: p.grants.Video.ToPermission(),
|
Permission: grants.Video.ToPermission(),
|
||||||
Metadata: p.grants.Metadata,
|
Metadata: grants.Metadata,
|
||||||
Region: p.params.Region,
|
Region: p.params.Region,
|
||||||
IsPublisher: p.IsPublisher(),
|
IsPublisher: p.IsPublisher(),
|
||||||
Kind: p.grants.GetParticipantKind(),
|
Kind: grants.GetParticipantKind(),
|
||||||
}
|
}
|
||||||
p.lock.RUnlock()
|
p.lock.RUnlock()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user