Commit 5253543a authored by hujiebin's avatar hujiebin

fix:forbid传入

parent 19ce63ce
......@@ -269,7 +269,7 @@ func (mic *Mic) In(userId uint64, externalId string) error {
//上麦(自己),
//规则:1:加锁了不能上麦 2:麦上有人,不能上麦
//cpUserId如果有
func (mic *Mic) Update(userId uint64, externalId string, cpUserId uint64) (err error) {
func (mic *Mic) Update(userId uint64, externalId string, cpUserId uint64, forbid bool) (err error) {
defer func() {
if err != nil {
mic.model.Log.Errorf("MicUpdate fail,userId:%v,cpUserId:%v,err:%v", userId, cpUserId, err)
......@@ -300,7 +300,7 @@ func (mic *Mic) Update(userId uint64, externalId string, cpUserId uint64) (err e
ExternalId: externalId,
UserId: userId,
CpUserId: cpUserId,
Forbid: false,
Forbid: forbid,
Timestamp: time.Now().Unix(),
})
if err != nil {
......
......@@ -346,9 +346,11 @@ func (s *GroupMicService) CheckCpOnMic(groupUuid string) {
// userId->micIndex
var userMicIndex = make(map[uint64]int)
var userIds []uint64
forbidMap := make(map[uint64]bool)
for _, u := range micUsers {
userMicIndex[u.UserId] = u.I
userIds = append(userIds, u.UserId)
forbidMap[u.UserId] = u.Forbid
}
cpPairs, err := rpc.MGetUserCpPairs(model, userIds)
// 更新麦上cp的信息
......@@ -374,7 +376,7 @@ func (s *GroupMicService) CheckCpOnMic(groupUuid string) {
if err != nil {
return err
}
return mic.Update(userId, users[userId].ExternalId, cpUserId)
return mic.Update(userId, users[userId].ExternalId, cpUserId, forbidMap[userId])
})
redisLock(redis_key.GetPrefixGroupMicUserInLock(cpUserId), uuid.NewV4().String(), time.Second*2, func() error {
model := domain.CreateModel(s.svc.CtxAndDb)
......@@ -382,7 +384,7 @@ func (s *GroupMicService) CheckCpOnMic(groupUuid string) {
if err != nil {
return err
}
return mic.Update(cpUserId, users[cpUserId].ExternalId, userId)
return mic.Update(cpUserId, users[cpUserId].ExternalId, userId, forbidMap[cpUserId])
})
}
return
......@@ -403,11 +405,13 @@ func (s *GroupMicService) CheckCpLeaveMic(groupUuid string, leaveUid uint64) {
// userId->micIndex
var userMicIndex = make(map[uint64]int)
var cpUserId uint64
forbidMap := make(map[uint64]bool)
for _, u := range micUsers {
if u.UserId == leaveUid {
cpUserId = u.CpUserId
}
userMicIndex[u.UserId] = u.I
forbidMap[u.UserId] = u.Forbid
}
if cpUserId <= 0 {
return
......@@ -423,7 +427,7 @@ func (s *GroupMicService) CheckCpLeaveMic(groupUuid string, leaveUid uint64) {
if err != nil {
return err
}
return mic.Update(cpUserId, user.ExternalId, 0)
return mic.Update(cpUserId, user.ExternalId, 0, forbidMap[cpUserId])
})
return
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment