|
@@ -188,13 +188,13 @@ public class BlacklistContainer {
|
|
|
LOG.info("同步本地标签ID与视频列表的缓存任务结束");
|
|
|
}
|
|
|
|
|
|
- public List<Long> filterUnsafeVideoByUser(List<Long> videoIds, String uid, Long hotSceneType, String cityCode, String clientIP, String mid, String usedScene) {
|
|
|
+ public List<Long> filterUnsafeVideoByUser(List<Long> videoIds, String uid, Long hotSceneType, String cityCode, String clientIP, String mid, String usedScene, Integer appType) {
|
|
|
if (CollectionUtils.isEmpty(videoIds)) {
|
|
|
return videoIds;
|
|
|
}
|
|
|
|
|
|
- String userType = this.matchUserBlacklistTypeEnum(uid, hotSceneType, cityCode, clientIP, mid, usedScene);
|
|
|
- Collection<Long> tagIdSet = this.findExcludeTagIds(userType);
|
|
|
+ String userType = this.matchUserBlacklistTypeEnum(uid, hotSceneType, cityCode, clientIP, mid, usedScene, appType);
|
|
|
+ Collection<Long> tagIdSet = this.findRecommendExcludeTagIds(userType, appType);
|
|
|
if (CollectionUtils.isEmpty(tagIdSet)) {
|
|
|
return videoIds;
|
|
|
}
|
|
@@ -210,15 +210,16 @@ public class BlacklistContainer {
|
|
|
}
|
|
|
|
|
|
public String matchUserBlacklistTypeEnum(String uid, Long hotSceneType, String cityCode, String clientIP, String mid,
|
|
|
- String usedScene) {
|
|
|
+ String usedScene, Integer appType) {
|
|
|
try {
|
|
|
- LOG.info("计算用户黑名单类型,判断参数: uid={}, hotSceneType={}, cityCode={}, clientIP={}, mid={}", uid, hotSceneType, cityCode, clientIP, mid);
|
|
|
+ LOG.info("计算用户黑名单类型,判断参数: uid={}, hotSceneType={}, cityCode={}, clientIP={}, mid={}, appType={}",
|
|
|
+ uid, hotSceneType, cityCode, clientIP, mid, appType);
|
|
|
if (StringUtils.isNotBlank(uid)) {
|
|
|
String key = this.calcUserRedisKey(uid);
|
|
|
Map<String, String> uidBlacklistMap = blacklistCache.get(key);
|
|
|
if (uidBlacklistMap.containsKey(uid)) {
|
|
|
String userType = uidBlacklistMap.get(uid);
|
|
|
- this.filterLogUpload(uid, cityCode, hotSceneType, clientIP, userType, "UID", mid, usedScene);
|
|
|
+ this.filterLogUpload(uid, cityCode, hotSceneType, clientIP, userType, "UID", mid, usedScene, appType);
|
|
|
LOG.info("用户 {} 在UID黑名单中命中 {}", uid, userType);
|
|
|
return userType;
|
|
|
}
|
|
@@ -228,7 +229,7 @@ public class BlacklistContainer {
|
|
|
Map<String, String> ipBlacklistMap = blacklistCache.get(IP_VISIO_BLACKLIST_HASH_KEY);
|
|
|
if (ipBlacklistMap.containsKey(clientIP)) {
|
|
|
String userType = ipBlacklistMap.get(clientIP);
|
|
|
- this.filterLogUpload(uid, cityCode, hotSceneType, clientIP, userType, "IP", mid, usedScene);
|
|
|
+ this.filterLogUpload(uid, cityCode, hotSceneType, clientIP, userType, "IP", mid, usedScene, appType);
|
|
|
LOG.info("用户 {} 在IP黑名单中命中 {}, 参数为: clientIP为: {}", uid, userType, clientIP);
|
|
|
return userType;
|
|
|
}
|
|
@@ -237,7 +238,7 @@ public class BlacklistContainer {
|
|
|
|
|
|
String userType = this.matchGeneralizationUserType(uid, cityCode, hotSceneType);
|
|
|
if (StringUtils.isNotBlank(userType)) {
|
|
|
- this.filterLogUpload(uid, cityCode, hotSceneType, clientIP, userType, "RegionAndHotSceneType", mid, usedScene);
|
|
|
+ this.filterLogUpload(uid, cityCode, hotSceneType, clientIP, userType, "RegionAndHotSceneType", mid, usedScene, appType);
|
|
|
}
|
|
|
return userType;
|
|
|
} catch (
|
|
@@ -294,11 +295,20 @@ public class BlacklistContainer {
|
|
|
return USER_VISIO_BLACKLIST_HASH_KEY + (uid % USER_REDIS_KEY_PARTITION_COUNT);
|
|
|
}
|
|
|
|
|
|
- private Collection<Long> findExcludeTagIds(String userType) {
|
|
|
+ private Collection<Long> findRecommendExcludeTagIds(String userType, Integer appType) {
|
|
|
if (StringUtils.isBlank(userType) || MapUtils.isEmpty(tagFilterConfigMap)) {
|
|
|
return Collections.emptySet();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ if (Objects.nonNull(appType)) {
|
|
|
+ TagFilterConfig tagFilterConfig = tagFilterConfigMap.get(userType + USER_TYPE_SUB_TYPE_CONNECTOR + appType);
|
|
|
+ if (Objects.nonNull(tagFilterConfig)) {
|
|
|
+ return tagFilterConfig.getRecommendExcludeTag();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
TagFilterConfig tagFilterConfig = tagFilterConfigMap.get(userType);
|
|
|
if (Objects.isNull(tagFilterConfig)) {
|
|
|
return Collections.emptySet();
|
|
@@ -306,18 +316,9 @@ public class BlacklistContainer {
|
|
|
return tagFilterConfig.getRecommendExcludeTag();
|
|
|
}
|
|
|
|
|
|
- private void filterLogUpload(String uid, String cityCode, Long hotSceneType, String clientIp, String fullUserType, String blacklistType, String mid, String usedScene) {
|
|
|
+ private void filterLogUpload(String uid, String cityCode, Long hotSceneType, String clientIp, String fullUserType, String blacklistType, String mid, String usedScene, Integer appType) {
|
|
|
try {
|
|
|
String[] split = fullUserType.split(USER_TYPE_SUB_TYPE_CONNECTOR);
|
|
|
- this.filterLogUpload(uid, cityCode, hotSceneType, clientIp, split[0], split[1], blacklistType, mid, usedScene);
|
|
|
- } catch (
|
|
|
- Exception e) {
|
|
|
- LOG.error("filterLogUpload error: ", e);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void filterLogUpload(String uid, String cityCode, Long hotSceneType, String clientIp, String userType, String userSubType, String blacklistType, String mid, String usedScene) {
|
|
|
- try {
|
|
|
Map<String, String> logMap = new HashMap<>();
|
|
|
logMap.put("uid", StringUtils.isNotBlank(uid) ? uid : "");
|
|
|
logMap.put("mid", StringUtils.isNotBlank(mid) ? mid : "");
|
|
@@ -325,8 +326,9 @@ public class BlacklistContainer {
|
|
|
logMap.put("hotSceneType", Objects.nonNull(hotSceneType) ? hotSceneType.toString() : "");
|
|
|
logMap.put("clientIp", StringUtils.isNotBlank(clientIp) ? clientIp : "");
|
|
|
logMap.put("usedScene", StringUtils.isNotBlank(usedScene) ? usedScene : "");
|
|
|
- logMap.put("userType", userType);
|
|
|
- logMap.put("userSubType", userSubType);
|
|
|
+ logMap.put("appType", Objects.nonNull(appType) ? appType.toString() : "");
|
|
|
+ logMap.put("userType", split[0]);
|
|
|
+ logMap.put("userSubType", split[1]);
|
|
|
logMap.put("env", activeProfile);
|
|
|
logMap.put("blacklistType", blacklistType);
|
|
|
logMap.put("uploadService", "recommend-server");
|