Skip to content

Commit

Permalink
Respect the isBlocked param in `UserRelationshipService#queryRelate…
Browse files Browse the repository at this point in the history
…dUserIds` #1589
  • Loading branch information
JamesChenX committed Dec 9, 2024
1 parent 448225a commit 58309a3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,30 @@ public static <T> Set<T> newSetWithExpectedSize(int expectedSize) {
return UnifiedSet.newSet(expectedSize);
}

public static <T> Set<T> newSetIntersection(Collection<T> c1, Collection<T> c2) {
int count;
Collection<T> smaller;
Collection<T> larger;
int c1Size = c1.size();
int c2Size = c2.size();
if (c1Size < c2Size) {
count = c1Size;
smaller = c1;
larger = c2;
} else {
count = c2Size;
smaller = c2;
larger = c1;
}
Set<T> set = newSetWithExpectedSize(count);
for (T value : smaller) {
if (larger.contains(value)) {
set.add(value);
}
}
return set;
}

public static <T> SequencedSet<T> newSequencedSet(Collection<T> values) {
LinkedHashSet<T> set = LinkedHashSet.newLinkedHashSet(values.size());
set.addAll(values);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -423,8 +423,8 @@ public Flux<Long> queryRelatedUserIds(
Mono<List<Long>> queryRelatedUserIds = queryRelatedUserIds(ownerIds, isBlocked)
.collect(Collectors.toCollection(recyclableList2::getValue));
return Mono.zip(queryRelationshipGroupMemberIds, queryRelatedUserIds)
.flatMapMany(tuple -> Flux
.fromIterable(CollectionUtil.newSet(tuple.getT1(), tuple.getT2())))
.flatMapMany(tuple -> Flux.fromIterable(
CollectionUtil.newSetIntersection(tuple.getT1(), tuple.getT2())))
.doFinally(signalType -> {
recyclableList1.recycle();
recyclableList2.recycle();
Expand Down

0 comments on commit 58309a3

Please sign in to comment.