Skip to content

Commit 073181a

Browse files
committed
fix duplicate on add members
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
1 parent 40dcd4f commit 073181a

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

lib/Service/GlobalScaleService.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ public function __construct(
124124
* @param GSEvent $event
125125
*
126126
* @return string
127+
* @throws NoUserException
127128
*/
128129
public function asyncBroadcast(GSEvent $event): string {
129130
$wrapper = new GSWrapper();
@@ -148,6 +149,8 @@ public function asyncBroadcast(GSEvent $event): string {
148149
try {
149150
$this->doRequest($request);
150151
} catch (RequestContentException | RequestNetworkException | RequestResultSizeException | RequestServerException $e) {
152+
OC::$server->getLogger()
153+
->logException($e, ['app' => 'circles']);
151154
}
152155

153156
return $wrapper->getToken();

lib/Service/MembersService.php

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ public function addMember($circleUniqueId, $ident, $type, string $instance, bool
168168
$new = [$this->addSingleMember($circle, $ident, $type, $instance, $force)];
169169
}
170170

171-
return array_merge($curr, $new);
171+
return $this->filterDuplicate($curr, $new);
172172
}
173173

174174

@@ -640,5 +640,29 @@ public function onUserRemoved(string $userId) {
640640
}
641641

642642

643+
/**
644+
* @param Member[] $curr
645+
* @param Member[] $new
646+
*
647+
* @return array
648+
*/
649+
private function filterDuplicate(array $curr, array $new): array {
650+
$base = [];
651+
foreach ($curr as $currMember) {
652+
$known = false;
653+
foreach ($new as $newMember) {
654+
if ($newMember->getMemberId() === $currMember->getMemberId()) {
655+
$known = true;
656+
}
657+
}
658+
if (!$known) {
659+
$base[] = $currMember;
660+
}
661+
}
662+
663+
return array_merge($base, $new);
664+
}
665+
666+
643667
}
644668

0 commit comments

Comments
 (0)