Skip to content

Commit

Permalink
Merge pull request #38 from brilliancenw/v4-user-patch
Browse files Browse the repository at this point in the history
Algolia Sync User Patch
  • Loading branch information
markmiddleton authored Dec 8, 2023
2 parents 4f31732 + 60cde99 commit c5e73ec
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/services/AlgoliaSyncService.php
Original file line number Diff line number Diff line change
Expand Up @@ -532,16 +532,19 @@ public function getEventElementInfo($element, $processRecords = true) {
// this will get the current user's groups (may be multiple indexes to update)
// lets only upsert records that match the configured groups in algolia sync
$algoliaSettings = AlgoliaSync::$plugin->getSettings();
$syncedGroups = $algoliaSettings['algoliaElements']['user'];

$userGroups = Craft::$app->userGroups->getGroupsByUserId($element->id);
$deleteFromAlgolia = true;

foreach ($userGroups AS $group) {
if (isset($syncedGroups[$group->id]) && $syncedGroups[$group->id]['sync'] == 1) {
$info['sectionHandle'][] = $group->handle;
$info['sectionId'][] = $group->id;
$deleteFromAlgolia = false;
if (isset($algoliaSettings['algoliaElements']['user'])) {
$syncedGroups = $algoliaSettings['algoliaElements']['user'];

$userGroups = Craft::$app->userGroups->getGroupsByUserId($element->id);
$deleteFromAlgolia = true;

foreach ($userGroups AS $group) {
if (isset($syncedGroups[$group->id]) && $syncedGroups[$group->id]['sync'] == 1) {
$info['sectionHandle'][] = $group->handle;
$info['sectionId'][] = $group->id;
$deleteFromAlgolia = false;
}
}
}

Expand Down

0 comments on commit c5e73ec

Please sign in to comment.