Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite Discord group sync to use v5 Nameless-Link API #3222

Merged
merged 12 commits into from
Jan 28, 2023
Prev Previous commit
Next Next commit
Style
  • Loading branch information
tadhgboyle committed Jan 28, 2023
commit 2e68d814e41d840ae928e06e2391cc719148ab9c
6 changes: 3 additions & 3 deletions modules/Core/includes/endpoints/ServerInfoEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ public function execute(Nameless2API $api): void {
$api->throwError(Nameless2API::ERROR_INVALID_POST_CONTENTS, 'players');
}

$serverId = $_POST['server-id'];
$server_id = $_POST['server-id'];
// Ensure server exists
$server_query = $api->getDb()->get('mc_servers', ['id', $serverId]);
$server_query = $api->getDb()->get('mc_servers', ['id', $server_id]);

if (!$server_query->count() || $server_query->first()->bedrock) {
$api->throwError(CoreApiErrors::ERROR_INVALID_SERVER_ID, $serverId);
$api->throwError(CoreApiErrors::ERROR_INVALID_SERVER_ID, $server_id);
}

if (isset($_POST['verify_command'])) {
Expand Down
6 changes: 3 additions & 3 deletions modules/Core/includes/endpoints/UpdateGroupsEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ public function __construct() {
public function execute(Nameless2API $api): void {
$api->validateParams($_POST, ['server_id', 'player_groups']);

$serverId = $_POST['server_id'];
$server_id = $_POST['server_id'];
$group_sync_log = [];

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

Expand All @@ -35,7 +35,7 @@ public function execute(Nameless2API $api): void {
$api->returnArray(array_merge(['message' => $api->getLanguage()->get('api', 'groups_updates_successfully')], ['log' => $group_sync_log]));
}

$api->throwError(CoreApiErrors::ERROR_INVALID_SERVER_ID, $serverId);
$api->throwError(CoreApiErrors::ERROR_INVALID_SERVER_ID, $server_id);
}

private function updateGroups(IntegrationUser $integrationUser, array $groups): array {
Expand Down