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