增加客户绑定的客户端id去重,避免同一个用户发送多条的情况

This commit is contained in:
qiaoqinzheng 2024-01-31 16:00:28 +08:00
parent 9e8935c9d4
commit c892a339e0
2 changed files with 5 additions and 1 deletions

View File

@ -9,6 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class AppMessageServiceImpl implements IAppMessageService {
@ -27,6 +28,7 @@ public class AppMessageServiceImpl implements IAppMessageService {
//根据用户id查询出用户关联的app客户端id
List<String> userClientId = appMessageMapper.findUserClientId(groupUserIds);
if (CollectionUtils.isNotEmpty(userClientId)) {
userClientId = userClientId.stream().distinct().collect(Collectors.toList());
//调用app推送方法
pushAppUtil.pushToList(messageDTO, userClientId);
}

View File

@ -22,6 +22,7 @@ import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Component
public class PushAppUtil {
@ -43,6 +44,7 @@ public class PushAppUtil {
//根据用户id查询出用户关联的app客户端id
List<String> userClientId = appMessageMapper.findUserClientId(groupUserIds);
if (CollectionUtils.isNotEmpty(userClientId)) {
userClientId = userClientId.stream().distinct().collect(Collectors.toList());
//调用app推送方法
pushToList(messageDTO, userClientId);
}
@ -127,7 +129,7 @@ public class PushAppUtil {
//华为手机配置厂商参数
ups.addOption("HW", "/message/android/notification/badge/add_num", 1);
ups.addOption("HW", "/message/android/notification/importance", "HIGH");
ups.addOption("HW", "/message/android/ttl", "86400s");
ups.addOption("HW", "/message/android/category", "WORK");
//OPPO手机配置厂商参数
ups.addOption("OP", "/off_line", true);
ups.addOption("OP", "/show_ttl", 86400);