Skip to content

Commit

Permalink
sp
Browse files Browse the repository at this point in the history
  • Loading branch information
nkonev committed Jan 12, 2024
1 parent 537b28a commit 2521d40
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion video/handlers/invite.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ func (vh *InviteHandler) ProcessAsOwnerLeave(c echo.Context) error {
return c.NoContent(http.StatusInternalServerError)
}

vh.dialRedisRepository.RemoveAllDials(c.Request().Context(), chatId, usersToDial)
vh.dialRedisRepository.RemoveAllDials(c.Request().Context(), chatId)

err = vh.dialStatusPublisher.Publish(chatId, usersToDial, false, ownerId)

Expand Down
14 changes: 10 additions & 4 deletions video/services/dial_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func chatIdFromKey(key string) (int64, error) {
return parseInt64, nil
}

// TODO here and in RemoveAllDials() not to remove immediately, but switch status and set expiration equal to room is closing timeout
// TODO here and in RemoveAllDials() not to remove immediately, but switch status and set expiration on user_call_status key equal to "room is closing" timeout
func (s *DialRedisRepository) RemoveFromDialList(ctx context.Context, userId, chatId int64) error {
_, err := s.redisClient.SRem(ctx, dialChatMembersKey(chatId), userId).Result()
if err != nil {
Expand All @@ -112,7 +112,7 @@ func (s *DialRedisRepository) RemoveFromDialList(ctx context.Context, userId, ch
logger.GetLogEntry(ctx).Errorf("Error during performing SCARD %v", err)
return err
}
if card == 0 {
if card == 0 { // TODO paraphrase this logic (most probably put it in scheduler) to run periodically, and if all the clients were removed - then run...
// remove "dialchat" on zero members
err = s.redisClient.Del(ctx, dialChatMembersKey(chatId)).Err()
if err != nil {
Expand All @@ -139,9 +139,15 @@ func (s *DialRedisRepository) RemoveFromDialList(ctx context.Context, userId, ch
}

// aka remove all dials or close call
func (s *DialRedisRepository) RemoveAllDials(ctx context.Context, chatId int64, usersOfDial []int64) {
func (s *DialRedisRepository) RemoveAllDials(ctx context.Context, chatId int64) {
usersOfDial, err := s.GetUsersToDial(ctx, chatId)
if err != nil {
logger.GetLogEntry(ctx).Errorf("Error %v", err)
return
}

// remove "dialchat"
err := s.redisClient.Del(ctx, dialChatMembersKey(chatId)).Err()
err = s.redisClient.Del(ctx, dialChatMembersKey(chatId)).Err()
if err != nil {
logger.GetLogEntry(ctx).Errorf("Error during performing SREM %v", err)
return
Expand Down

0 comments on commit 2521d40

Please sign in to comment.