完善已读逻辑

This commit is contained in:
easonzhu 2025-02-20 09:50:42 +08:00
parent 349c6948fb
commit 9bb59f448f
2 changed files with 6 additions and 2 deletions

View File

@ -162,10 +162,11 @@ public class AppGroupMessageService {
if (StrUtil.isEmpty(userId)) {
throw new BizException(ResponseStatus.PARM_ERROR, "用户ID错误:" + userId);
}
String messageIds = (String) attributes.get("messageIds");
String messageIds = accessor.getFirstNativeHeader("messageIds");
if (StrUtil.isEmpty(messageIds)) {
throw new BizException(ResponseStatus.PARM_ERROR, "消息ID错误:" + messageIds);
}
LoggerUtil.info("readMessage:userId=" + userId + ",messageIds=" + messageIds);
String[] ids = messageIds.split(",");
List<Integer> list = new ArrayList<>(ids.length);
for (String id : ids) {
@ -187,7 +188,7 @@ public class AppGroupMessageService {
QueryGroupMessageType msgType = QueryGroupMessageType.fromValue(type);
NavigableSet<Integer> sortedSet = groupCacheService.getMessageIdSet(groupId, userId, msgType);
if (lastId != null) {
sortedSet = sortedSet.tailSet(lastId, false);
sortedSet = sortedSet.headSet(lastId, false);
}
return sortedSet.size();
}

View File

@ -195,6 +195,7 @@ public class CollectTask {
Map<String, VideoUserWatchCollect> map = new HashMap<>();
liveWatchList.forEach(liveWatch -> {
liveWatch.setVodSeconds(0);
liveWatch.setVodMinutes(0);
map.put(liveWatch.getUserId(), liveWatch);
});
@ -202,8 +203,10 @@ public class CollectTask {
VideoUserWatchCollect liveWatch = map.get(vodWatch.getUserId());
if (liveWatch != null) {
liveWatch.setVodSeconds(vodWatch.getVodSeconds());
liveWatch.setVodMinutes(vodWatch.getVodMinutes());
} else {
vodWatch.setLiveSeconds(0);
vodWatch.setLiveMinutes(0);
map.put(vodWatch.getUserId(), vodWatch);
}
});