Skip to content

Commit

Permalink
Remove unable to update groups catch (NamelessMC#3360)
Browse files Browse the repository at this point in the history
  • Loading branch information
Derkades authored May 10, 2023
1 parent 37d698b commit c555b41
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
1 change: 0 additions & 1 deletion modules/Core/classes/Misc/CoreApiErrors.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ class CoreApiErrors {
public const ERROR_USER_ALREADY_ACTIVE = 'core:user_already_active';

public const ERROR_UNABLE_TO_UPDATE_USERNAME = 'core:unable_to_update_username';
public const ERROR_UNABLE_TO_UPDATE_GROUPS = 'core:unable_to_update_groups';

public const ERROR_INTEGRATION_IDENTIFIER_ERRORS = 'core:integration_identifier_errors';
public const ERROR_INTEGRATION_USERNAME_ERRORS = 'core:integration_username_errors';
Expand Down
20 changes: 8 additions & 12 deletions modules/Core/includes/endpoints/UpdateGroupsEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,16 @@ public function execute(Nameless2API $api): void {
$group_sync_log = [];

if (Util::getSetting('mc_integration') && $server_id == Util::getSetting('group_sync_mc_server')) {
try {
$integration = Integrations::getInstance()->getIntegration('Minecraft');

foreach ($_POST['player_groups'] as $uuid => $groups) {
$integrationUser = new IntegrationUser($integration, str_replace('-', '', $uuid), 'identifier');
if ($integrationUser->exists()) {
$log = $this->updateGroups($integrationUser, $groups['groups']);
if (count($log)) {
$group_sync_log[] = $log;
}
$integration = Integrations::getInstance()->getIntegration('Minecraft');

foreach ($_POST['player_groups'] as $uuid => $groups) {
$integrationUser = new IntegrationUser($integration, str_replace('-', '', $uuid), 'identifier');
if ($integrationUser->exists()) {
$log = $this->updateGroups($integrationUser, $groups['groups']);
if (count($log)) {
$group_sync_log[] = $log;
}
}
} catch (Exception $e) {
$api->throwError(CoreApiErrors::ERROR_UNABLE_TO_UPDATE_GROUPS, $e->getMessage(), 500);
}

$api->returnArray(array_merge(['message' => $api->getLanguage()->get('api', 'groups_updates_successfully')], ['log' => $group_sync_log]));
Expand Down

0 comments on commit c555b41

Please sign in to comment.