package com.red.circle.other.app.listener.strategy;

import com.red.circle.mq.business.model.event.approval.ApprovalEvent;
import com.red.circle.other.infra.database.mongo.service.live.ActiveVoiceRoomService;
import com.red.circle.other.infra.database.mongo.service.live.RoomProfileManagerService;
import com.red.circle.tool.core.text.StringUtils;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * 房间头像审核.
 *
 * @author pengliang on 2020/12/10
 */
@Slf4j
@Component("ROOM_AVATAR_APPROVAL")
@RequiredArgsConstructor
public class RoomAvatarStrategy implements ApprovalStrategy {

  private final ActiveVoiceRoomService activeVoiceRoomService;
  private final RoomProfileManagerService roomProfileManagerService;

  @Override
  public void doOperation(ApprovalEvent param) {
    if (param.approvalNotPass()) {
      activeVoiceRoomService.removeByIds(param.waitApprovalUserContentIds());
      roomProfileManagerService.updateRoomCoverByIds(param.waitApprovalUserContentIds(),
          StringUtils.EMPTY);
    }
  }
}
