|
@@ -9,6 +9,7 @@ import com.ym.common.BaseResponse;
|
|
|
import com.ym.mec.biz.dal.dto.TencentData;
|
|
|
import com.ym.mec.biz.dal.dto.TencentImCallbackResult;
|
|
|
import com.ym.mec.biz.dal.enums.ETencentImCallbackCommand;
|
|
|
+import com.ym.mec.biz.service.ImGroupService;
|
|
|
import com.ym.mec.biz.service.ImLiveBroadcastRoomService;
|
|
|
import com.ym.mec.common.entity.ImUserState;
|
|
|
import com.ym.service.LiveRoomService;
|
|
@@ -48,6 +49,9 @@ public class UserController {
|
|
|
@Autowired
|
|
|
private RoomService roomService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ImGroupService imGroupService;
|
|
|
+
|
|
|
@RequestMapping(value = "/register", method = RequestMethod.POST)
|
|
|
public Object register(@RequestBody UserModel userModel) throws Exception {
|
|
|
return userService.register(userModel);
|
|
@@ -140,6 +144,10 @@ public class UserController {
|
|
|
// 学生编号
|
|
|
String userId = callbackOnMemberStateChange.getMemberList().get(0).getMemberAccount();
|
|
|
|
|
|
+ if (!imGroupService.checkImUserId(userId)) {
|
|
|
+ return new TencentImCallbackResult();
|
|
|
+ }
|
|
|
+
|
|
|
String eventType = callbackOnMemberStateChange.getEventType();
|
|
|
// 学生离线消息通知
|
|
|
if ("Offline".equals(eventType)) {
|
|
@@ -188,6 +196,10 @@ public class UserController {
|
|
|
|
|
|
// 学生编号
|
|
|
String userId = callbackAfterMemberExit.getExitMemberList().get(0).getMemberAccount();
|
|
|
+
|
|
|
+ if (!imGroupService.checkImUserId(userId)) {
|
|
|
+ return new TencentImCallbackResult();
|
|
|
+ }
|
|
|
try {
|
|
|
roomService.leaveRoomSuccess(roomId, userId, null);
|
|
|
} catch (Exception e) {
|
|
@@ -220,6 +232,10 @@ public class UserController {
|
|
|
|
|
|
// 学生编号
|
|
|
String userId = callbackAfterNewMemberJoin.getNewMemberList().get(0).getMemberAccount();
|
|
|
+
|
|
|
+ if (!imGroupService.checkImUserId(userId)) {
|
|
|
+ return new TencentImCallbackResult();
|
|
|
+ }
|
|
|
try {
|
|
|
roomService.joinRoomSuccess(roomId, userId, null);
|
|
|
} catch (Exception e) {
|
|
@@ -233,7 +249,9 @@ public class UserController {
|
|
|
|
|
|
return new TencentImCallbackResult();
|
|
|
}
|
|
|
-
|
|
|
+ private boolean checkStream(String streamId) {
|
|
|
+ return imGroupService.checkImUserId(streamId.split("_",2)[1]);
|
|
|
+ }
|
|
|
|
|
|
@ApiOperation("腾讯云直播-推流 回调接口")
|
|
|
@PostMapping(value = "/tencentStreamEventCallback")
|
|
@@ -242,7 +260,10 @@ public class UserController {
|
|
|
log.info("tencentStreamEventCallback body:{}", body);
|
|
|
|
|
|
TencentData.CallbackStreamStateEvent event = TencentData.CallbackStreamStateEvent.from(body);
|
|
|
-
|
|
|
+ boolean b = checkStream(event.getStreamId());
|
|
|
+ if (!b) {
|
|
|
+ return TencentData.StreamEventCallbackResult.builder().code(0).build();
|
|
|
+ }
|
|
|
// 直播间推流事件
|
|
|
if (event.getStreamId().startsWith("LIVE")) {
|
|
|
|
|
@@ -293,7 +314,10 @@ public class UserController {
|
|
|
log.info("tencentStreamRecordCallback body:{}", body);
|
|
|
|
|
|
TencentData.CallbackSteamRecordEvent event = TencentData.CallbackSteamRecordEvent.from(body);
|
|
|
-
|
|
|
+ boolean b = checkStream(event.getStreamId());
|
|
|
+ if (!b) {
|
|
|
+ return TencentData.StreamEventCallbackResult.builder().code(0).build();
|
|
|
+ }
|
|
|
// 直播录制事件通知
|
|
|
if (event.getStreamId().startsWith("LIVE")) {
|
|
|
log.info("taskId={}, url={}", event.getTaskId(), event.getVideoUrl());
|