From 19241c842d6ffe9ae561c5f11ed1026f781bffa7 Mon Sep 17 00:00:00 2001 From: kyle Date: Fri, 12 Jun 2026 18:30:12 -0700 Subject: [PATCH] refactor: rename app from ncdiscordhook to nc_bot_webhooks - Update namespace from OCA\NCdiscordhook to OCA\Ncbotwebhooks - Update app ID, name, and namespace in appinfo/info.xml - Update composer.json and autoload files - Update CLI command names from ncdiscordhook:* to nc_bot_webhooks:* - Update image directory name to nc_bot_webhooks-images - Update documentation in README.md and INSTALL.md - Update JavaScript APP_ID and navigation provider paths - Update admin settings and controller app references --- INSTALL.md | 42 +++++++------- README.md | 26 ++++----- appinfo/cron.php | 2 +- appinfo/info.xml | 12 ++-- composer.json | 4 +- composer/autoload.php | 8 +-- composer/autoload_psr4.php | 2 +- js/settings.js | 2 +- lib/Command/DebugToggle.php | 18 +++--- lib/Controller/WebhookController.php | 82 ++++++++++++++-------------- lib/Cron/ImageCleanup.php | 10 ++-- lib/NavigationProvider.php | 10 ++-- lib/Service/TalkService.php | 46 ++++++++-------- lib/Settings/Admin.php | 12 ++-- 14 files changed, 138 insertions(+), 138 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 0d8fd0c..6bfee27 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -1,4 +1,4 @@ -# NCdiscordhook — Installation Guide +# NCbotwebhooks — Installation Guide ## Prerequisites @@ -33,24 +33,24 @@ The bot must have admin privileges to list all Talk rooms. Grant admin access: 1. Log in to Nextcloud as **admin** 2. Go to **Settings → talk-bot → Devices & sessions** -3. Click **Add device** and give it a name (e.g., "NCdiscordhook") +3. Click **Add device** and give it a name (e.g., "NCbotwebhooks") 4. Copy the generated device password — you'll need this in Step 3 ## Step 2: Install the app ### Option A: From the web UI (recommended) -1. ZIP only the `ncdiscordhook` directory (not the parent folder): +1. ZIP only the `nc_bot_webhooks` directory (not the parent folder): ```bash -cd /path/to/ncdiscordhook -zip -r ../ncdiscdhook.zip . +cd /path/to/nc_bot_webhooks +zip -r ../nc_bot_webhooks.zip . ``` 2. Upload via web UI: - Go to **Apps → Apps management** (or **Administration → Apps**) - Click **Upload app** (or **Download and enable** → upload the ZIP) - - Select `ncdiscdhook.zip` + - Select `nc_bot_webhooks.zip` - The app will install and enable automatically ### Option B: From the command line @@ -59,20 +59,20 @@ zip -r ../ncdiscdhook.zip . cd /path/to/nextcloud/apps git clone https://github.com/Mr-Newlove/nc_bot_webhooks.git # or copy the directory manually: -# cp -r /path/to/ncdiscordhook /path/to/nextcloud/apps/ncdiscordhook +# cp -r /path/to/nc_bot_webhooks /path/to/nextcloud/apps/nc_bot_webhooks ``` Enable the app: ```bash cd /path/to/nextcloud -php occ app:enable ncdiscordhook +php occ app:enable nc_bot_webhooks ``` ## Step 3: Configure the app 1. Log in to Nextcloud as **admin** -2. Go to **Settings → Admin → NCdiscordhook** +2. Go to **Settings → Admin → NCbotwebhooks** 3. **Bot App Password** — Paste the device password you generated in Step 1 4. **Default Sender Name** — Set the name that appears as the message sender (default: "Webhook Bot") 5. **Image Retention** — Set how many days to keep uploaded images (default: 90) @@ -86,7 +86,7 @@ php occ app:enable ncdiscordhook 1. For Discord: go to **Channel Settings → Integrations → Webhooks**, create a new webhook, and set the Webhook URL to: ``` -https://your-nextcloud-server/apps/ncdiscordhook/discord-webhook// +https://your-nextcloud-server/apps/nc_bot_webhooks/discord-webhook// ``` Replace `` and `` with the values shown in the Nextcloud admin settings for the selected room. @@ -102,8 +102,8 @@ Test with curl: ```bash curl -X POST \ -H "Content-Type: application/json" \ - -d '{"content":"Test message from NCdiscordhook","username":"CI Bot"}' \ - https://your-nextcloud-server/apps/ncdiscordhook/discord-webhook// + -d '{"content":"Test message from NCbotwebhooks","username":"CI Bot"}' \ + https://your-nextcloud-server/apps/nc_bot_webhooks/discord-webhook// ``` ## Apprise webhook @@ -111,7 +111,7 @@ curl -X POST \ For Apprise integrations, use the `/apprise-webhook/` endpoint with the same room-token and auth-token: ``` -https://your-nextcloud-server/apps/ncdiscordhook/apprise-webhook//notify/ +https://your-nextcloud-server/apps/nc_bot_webhooks/apprise-webhook//notify/ ``` Note: the `notify` segment is required — Apprise's `apprises://` URL scheme inserts it in the path. @@ -122,8 +122,8 @@ Apprise sends a different JSON format (`title`, `body`, `type`, `attachments`) - **"talk-bot user not found"** — The `talk-bot` user doesn't exist. Re-run Step 1. - **"Bot password not configured"** — You haven't entered the bot password in the admin settings, or it was cleared. Re-enter it in Step 3. -- **Messages not appearing** — Check the Nextcloud log (`data/nextcloud.log` or Settings → Admin → Logging) for errors from the `ncdiscordhook` app. -- **Image upload fails** — Verify the bot user has file storage quota and the `NCdiscordhook-images` folder can be created. +- **Messages not appearing** — Check the Nextcloud log (`data/nextcloud.log` or Settings → Admin → Logging) for errors from the `nc_bot_webhooks` app. +- **Image upload fails** — Verify the bot user has file storage quota and the `NCbotwebhooks-images` folder can be created. ## Security Notes @@ -138,25 +138,25 @@ Apprise sends a different JSON format (`title`, `body`, `type`, `attachments`) ### Debug endpoint -The `/apps/ncdiscordhook/debug` endpoint exposes internal configuration, +The `/apps/nc_bot_webhooks/debug` endpoint exposes internal configuration, database schema, and bot credentials. It is **disabled by default**. ```bash # Check status -php occ ncdiscordhook:debug:status +php occ nc_bot_webhooks:debug:status # Enable (WARNING: exposes sensitive data) -php occ ncdiscordhook:debug:enable +php occ nc_bot_webhooks:debug:enable # Disable (default) -php occ ncdiscordhook:debug:disable +php occ nc_bot_webhooks:debug:disable # Toggle current state -php occ ncdiscordhook:debug:toggle +php occ nc_bot_webhooks:debug:toggle ``` After troubleshooting, disable it immediately: ```bash -php occ ncdiscordhook:debug:disable +php occ nc_bot_webhooks:debug:disable ``` diff --git a/README.md b/README.md index d7cb0c0..0e7c828 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# NCdiscordhook +# NCbotwebhooks Discord webhook bridge for Nextcloud Talk with image attachment support. @@ -10,8 +10,8 @@ Accepts Discord webhook-style JSON payloads and posts them into Nextcloud Talk r ```bash cd /path/to/nextcloud/apps -cp -r /path/to/ncdiscordhook . -php occ app:enable ncdiscordhook +cp -r /path/to/nc_bot_webhooks . +php occ app:enable nc_bot_webhooks ``` ### 2. Create the bot user @@ -28,7 +28,7 @@ php occ user:add --password-from-env --display-name="Webhook Bot" talk-bot ### 4. Configure the app -Go to **Settings → Admin → NCdiscordhook**: +Go to **Settings → Admin → NCbotwebhooks**: 1. **Bot Configuration** — paste the app password from step 3 2. **Image Retention** — set how long to keep uploaded images (default: 90 days) @@ -39,7 +39,7 @@ Go to **Settings → Admin → NCdiscordhook**: Each configured room gets **two** webhook URLs (Discord and Apprise formats): ``` -https://your-server.com/apps/ncdiscordhook/discord-webhook// +https://your-server.com/apps/nc_bot_webhooks/discord-webhook// ``` Copy the auth token from the app settings for each room. @@ -105,7 +105,7 @@ Multiple auth tokens can be created per room — useful if you need to rotate ke For Apprise integrations, each room also gets an Apprise webhook URL: ``` -https://your-server.com/apps/ncdiscordhook/apprise-webhook//notify/ +https://your-server.com/apps/nc_bot_webhooks/apprise-webhook//notify/ ``` Note: the `notify` segment is required — Apprise's `apprises://` URL scheme inserts it in the path. @@ -127,7 +127,7 @@ The apprise webhook maps `title`, `body`, and `attachments` to the same Talk mes ## Image management -- Images are uploaded to the bot user's files at `/NCdiscordhook-images//` +- Images are uploaded to the bot user's files at `/nc_bot_webhooks-images//` - Cron job purges images older than the configured retention period (default: 90 days) - Images are stored in the bot user's storage — they count toward the bot user's quota @@ -141,29 +141,29 @@ The apprise webhook maps `title`, `body`, and `attachments` to the same Talk mes ### Debug endpoint -The `/apps/ncdiscordhook/debug` endpoint exposes internal configuration, +The `/apps/nc_bot_webhooks/debug` endpoint exposes internal configuration, database schema, and bot credentials. It is **disabled by default** and must be explicitly enabled via the CLI: ```bash # Check current status -php occ ncdiscordhook:debug:status +php occ nc_bot_webhooks:debug:status # Enable (WARNING: exposes sensitive data) -php occ ncdiscordhook:debug:enable +php occ nc_bot_webhooks:debug:enable # Disable (default) -php occ ncdiscordhook:debug:disable +php occ nc_bot_webhooks:debug:disable # Toggle current state -php occ ncdiscordhook:debug:toggle +php occ nc_bot_webhooks:debug:toggle ``` Never leave the debug endpoint enabled in production. After troubleshooting, disable it immediately: ```bash -php occ ncdiscordhook:debug:disable +php occ nc_bot_webhooks:debug:disable ``` ## Logging diff --git a/appinfo/cron.php b/appinfo/cron.php index 2fb6d3a..c1c9536 100644 --- a/appinfo/cron.php +++ b/appinfo/cron.php @@ -1,6 +1,6 @@ [ - \OCA\NCdiscordhook\Cron\ImageCleanup::class, + \OCA\Ncbotwebhooks\Cron\ImageCleanup::class, ], ]; diff --git a/appinfo/info.xml b/appinfo/info.xml index 64f461b..e3b0988 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -1,14 +1,14 @@ - ncdiscordhook - NCdiscordhook + nc_bot_webhooks + NCbotwebhooks Discord webhook bridge for Nextcloud Talk with image support Accepts Discord webhook-style JSON payloads and posts them into Nextcloud Talk rooms, preserving image attachments. Each room gets its own webhook URL with an auth token for security. 1.1.0 AGPL-3.0-or-later Kyle - NCdiscordhook + Ncbotwebhooks integration @@ -17,15 +17,15 @@ - OCA\NCdiscordhook\Cron\ImageCleanup + OCA\Ncbotwebhooks\Cron\ImageCleanup - OCA\NCdiscordhook\Settings\Admin + OCA\Ncbotwebhooks\Settings\Admin - OCA\NCdiscordhook\Command\DebugToggle + OCA\Ncbotwebhooks\Command\DebugToggle https://github.com/Mr-Newlove/nc_bot_webhooks/issues diff --git a/composer.json b/composer.json index 0dcfbc9..f6a5374 100644 --- a/composer.json +++ b/composer.json @@ -1,10 +1,10 @@ { - "name": "ncdiscordhook/app", + "name": "nc_bot_webhooks/app", "description": "Discord webhook bridge for Nextcloud Talk", "type": "nextcloud-app", "autoload": { "psr-4": { - "OCA\\NCdiscordhook\\": "../lib/" + "OCA\\Ncbotwebhooks\\": "../lib/" } } } diff --git a/composer/autoload.php b/composer/autoload.php index fd1843e..f772b8a 100644 --- a/composer/autoload.php +++ b/composer/autoload.php @@ -1,13 +1,13 @@ [$baseDir . '/lib'], + 'OCA\\Ncbotwebhooks\\' => [$baseDir . '/lib'], ]; diff --git a/js/settings.js b/js/settings.js index 42a9b82..ff3b2f4 100644 --- a/js/settings.js +++ b/js/settings.js @@ -1,5 +1,5 @@ document.addEventListener('DOMContentLoaded', function () { - const APP_ID = 'ncdiscordhook'; + const APP_ID = 'nc_bot_webhooks'; // Read config passed via data attributes on the page function parseData(el, key) { diff --git a/lib/Command/DebugToggle.php b/lib/Command/DebugToggle.php index 1696cb4..73e251b 100644 --- a/lib/Command/DebugToggle.php +++ b/lib/Command/DebugToggle.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace OCA\NCdiscordhook\Command; +namespace OCA\Ncbotwebhooks\Command; use OCP\AppFramework\Controller; use OCP\AppFramework\Http; @@ -33,19 +33,19 @@ use Symfony\Component\Console\Style\SymfonyStyle; * * Usage: * # Enable debug - * php occ ncdiscordhook:debug:enable + * php occ nc_bot_webhooks:debug:enable * * # Disable debug - * php occ ncdiscordhook:debug:disable + * php occ nc_bot_webhooks:debug:disable * * # Toggle (disable if enabled, enable if disabled) - * php occ ncdiscordhook:debug:toggle + * php occ nc_bot_webhooks:debug:toggle * * # Check current status - * php occ ncdiscordhook:debug:status + * php occ nc_bot_webhooks:debug:status */ class DebugToggle extends Command { - private const APP_ID = 'ncdiscordhook'; + private const APP_ID = 'nc_bot_webhooks'; private const DEBUG_KEY = 'debug_enabled'; private IAppConfig $appConfig; @@ -57,7 +57,7 @@ class DebugToggle extends Command { protected function configure(): void { $this - ->setName('ncdiscordhook:debug:toggle') + ->setName('nc_bot_webhooks:debug:toggle') ->setDescription('Enable or disable the debug endpoint') ->addOption('enable', 'e', InputOption::VALUE_NONE, 'Enable the debug endpoint') ->addOption('disable', 'd', InputOption::VALUE_NONE, 'Disable the debug endpoint') @@ -80,8 +80,8 @@ class DebugToggle extends Command { if ($input->getOption('enable')) { $this->appConfig->setValueBool(self::APP_ID, self::DEBUG_KEY, true); - $io->warning('Debug endpoint is now ENABLED. Anyone can access /apps/ncdiscordhook/debug.'); - $io->note('To disable later, run: php occ ncdiscordhook:debug:disable'); + $io->warning('Debug endpoint is now ENABLED. Anyone can access /apps/nc_bot_webhooks/debug.'); + $io->note('To disable later, run: php occ nc_bot_webhooks:debug:disable'); return Command::SUCCESS; } diff --git a/lib/Controller/WebhookController.php b/lib/Controller/WebhookController.php index adc8b66..0f04ec7 100644 --- a/lib/Controller/WebhookController.php +++ b/lib/Controller/WebhookController.php @@ -1,8 +1,8 @@ talkService = $talkService; $this->logger = $logger; $this->appManager = $appManager; @@ -44,15 +44,15 @@ class WebhookController extends Controller { /** * Receive Discord webhook payload for a room. * - * URL: POST /apps/ncdiscordhook/discord-webhook/{roomToken}/{token} + * URL: POST /apps/nc_bot_webhooks/discord-webhook/{roomToken}/{token} */ #[PublicPage] #[NoCSRFRequired] public function receive(string $roomToken, string $token): DataResponse { // Validate auth token if (!$this->talkService->validateAuthToken($roomToken, $token)) { - $this->logger->warning('NCdiscordhook: invalid auth token for room', [ - 'app' => 'ncdiscordhook', + $this->logger->warning('NCbotwebhooks: invalid auth token for room', [ + 'app' => 'nc_bot_webhooks', 'room_token' => $roomToken, ]); return new DataResponse( @@ -66,8 +66,8 @@ class WebhookController extends Controller { $body = file_get_contents('php://input'); $data = @json_decode($body, true); if (json_last_error() !== JSON_ERROR_NONE || !is_array($data)) { - $this->logger->warning('NCdiscordhook: invalid JSON from webhook', [ - 'app' => 'ncdiscordhook', + $this->logger->warning('NCbotwebhooks: invalid JSON from webhook', [ + 'app' => 'nc_bot_webhooks', 'room_token' => $roomToken, ]); return new DataResponse( @@ -133,8 +133,8 @@ class WebhookController extends Controller { $success = $this->talkService->postToRoom($roomToken, $message, $senderName, $richObjects); if ($success) { - $this->logger->info('NCdiscordhook: webhook processed successfully', [ - 'app' => 'ncdiscordhook', + $this->logger->info('NCbotwebhooks: webhook processed successfully', [ + 'app' => 'nc_bot_webhooks', 'room_token' => $roomToken, ]); return new DataResponse( @@ -144,8 +144,8 @@ class WebhookController extends Controller { ); } - $this->logger->error('NCdiscordhook: failed to post webhook message to Talk', [ - 'app' => 'ncdiscordhook', + $this->logger->error('NCbotwebhooks: failed to post webhook message to Talk', [ + 'app' => 'nc_bot_webhooks', 'room_token' => $roomToken, ]); return new DataResponse( @@ -158,7 +158,7 @@ class WebhookController extends Controller { /** * Receive Apprise webhook payload for a room. * - * URL: POST /apps/ncdiscordhook/apprise-webhook/{roomToken}/{token} + * URL: POST /apps/nc_bot_webhooks/apprise-webhook/{roomToken}/{token} * Also handles Apprise's notify URL format: /apprise-webhook/{roomToken}/notify/{token} * * Apprise sends JSON like: @@ -175,8 +175,8 @@ class WebhookController extends Controller { public function receiveApprise(string $roomToken, string $token): DataResponse { // Validate auth token if (!$this->talkService->validateAuthToken($roomToken, $token)) { - $this->logger->warning('NCdiscordhook: invalid auth token for room', [ - 'app' => 'ncdiscordhook', + $this->logger->warning('NCbotwebhooks: invalid auth token for room', [ + 'app' => 'nc_bot_webhooks', 'room_token' => $roomToken, ]); return new DataResponse( @@ -215,8 +215,8 @@ class WebhookController extends Controller { } if (empty($data) || !is_array($data)) { - $this->logger->warning('NCdiscordhook: invalid payload from apprise webhook', [ - 'app' => 'ncdiscordhook', + $this->logger->warning('NCbotwebhooks: invalid payload from apprise webhook', [ + 'app' => 'nc_bot_webhooks', 'room_token' => $roomToken, 'content_type' => $contentType, 'body_length' => strlen($body), @@ -272,8 +272,8 @@ class WebhookController extends Controller { $success = $this->talkService->postToRoom($roomToken, $message, $senderName, $richObjects); if ($success) { - $this->logger->info('NCdiscordhook: apprise webhook processed successfully', [ - 'app' => 'ncdiscordhook', + $this->logger->info('NCbotwebhooks: apprise webhook processed successfully', [ + 'app' => 'nc_bot_webhooks', 'room_token' => $roomToken, ]); return new DataResponse( @@ -283,8 +283,8 @@ class WebhookController extends Controller { ); } - $this->logger->error('NCdiscordhook: failed to post apprise message to Talk', [ - 'app' => 'ncdiscordhook', + $this->logger->error('NCbotwebhooks: failed to post apprise message to Talk', [ + 'app' => 'nc_bot_webhooks', 'room_token' => $roomToken, ]); return new DataResponse( @@ -301,7 +301,7 @@ class WebhookController extends Controller { * Apprise's apprise:// URL scheme inserts 'notify' in the path. * Delegates to receiveApprise() for processing. * - * URL: POST /apps/ncdiscordhook/apprise-webhook/{roomToken}/notify/{token} + * URL: POST /apps/nc_bot_webhooks/apprise-webhook/{roomToken}/notify/{token} */ #[PublicPage] #[NoCSRFRequired] @@ -312,7 +312,7 @@ class WebhookController extends Controller { /** * Save bot password from the settings UI. * - * URL: POST /apps/ncdiscordhook/save-bot-password + * URL: POST /apps/nc_bot_webhooks/save-bot-password */ #[AdminRequired] #[NoCSRFRequired] @@ -334,7 +334,7 @@ class WebhookController extends Controller { /** * Save configuration from the settings UI. * - * URL: POST /apps/ncdiscordhook/save-config + * URL: POST /apps/nc_bot_webhooks/save-config */ #[AdminRequired] #[NoCSRFRequired] @@ -351,8 +351,8 @@ class WebhookController extends Controller { try { $this->talkService->saveConfig($config); } catch (\Exception $e) { - $this->logger->error('NCdiscordhook: saveConfig failed: ' . $e->getMessage(), [ - 'app' => 'ncdiscordhook', + $this->logger->error('NCbotwebhooks: saveConfig failed: ' . $e->getMessage(), [ + 'app' => 'nc_bot_webhooks', 'exception' => (string)$e, ]); return new DataResponse( @@ -370,13 +370,13 @@ class WebhookController extends Controller { /** * Debug endpoint to verify the app is working. * - * URL: GET /apps/ncdiscordhook/debug + * URL: GET /apps/nc_bot_webhooks/debug * Query params: - * - webhook_url: Full webhook URL to diagnose (e.g. /apps/ncdiscordhook/discord-webhook/{room}/{token}) + * - webhook_url: Full webhook URL to diagnose (e.g. /apps/nc_bot_webhooks/discord-webhook/{room}/{token}) * - test_post=1: Actually POST a test message to the room * * This endpoint is disabled by default. Enable it via: - * php occ ncdiscordhook:debug:enable + * php occ nc_bot_webhooks:debug:enable * * SECURITY: Never leave debug enabled in production. It exposes internal * configuration, database schema, and bot credentials. @@ -386,10 +386,10 @@ class WebhookController extends Controller { #[NoAdminRequired] public function debug(): DataResponse { // Debug endpoint must be explicitly enabled via OCC command - $debugEnabled = $this->appConfig->getValueBool('ncdiscordhook', 'debug_enabled', false); + $debugEnabled = $this->appConfig->getValueBool('nc_bot_webhooks', 'debug_enabled', false); if (!$debugEnabled) { return new DataResponse( - ['error' => 'Debug endpoint is disabled. Enable it with: php occ ncdiscordhook:debug:enable'], + ['error' => 'Debug endpoint is disabled. Enable it with: php occ nc_bot_webhooks:debug:enable'], Http::STATUS_FORBIDDEN, ); } @@ -399,7 +399,7 @@ class WebhookController extends Controller { $isAdmin = $user !== null && $this->groupManager->isAdmin($uid); $info = [ - 'app_enabled' => $this->appManager->isInstalled('ncdiscordhook'), + 'app_enabled' => $this->appManager->isInstalled('nc_bot_webhooks'), 'user' => $uid, 'user_is_admin' => $isAdmin, 'bot_user' => null, @@ -432,7 +432,7 @@ class WebhookController extends Controller { $knownKeys = ['bot_password', 'rooms', 'auth_tokens', 'retention_days', 'sender_name']; $appConfigKeys = []; foreach ($knownKeys as $key) { - $val = $this->appConfig->getValueString('ncdiscordhook', $key, ''); + $val = $this->appConfig->getValueString('nc_bot_webhooks', $key, ''); $appConfigKeys[$key] = $val !== '' ? '[set]' : '[empty]'; } $info['app_config_keys'] = $appConfigKeys; @@ -544,8 +544,8 @@ class WebhookController extends Controller { $path = $parsed['path'] ?? ''; $segments = explode('/', trim($path, '/')); - // Expected: apps/ncdiscordhook/discord-webhook/{roomToken}/{token} - if (count($segments) >= 5 && $segments[0] === 'apps' && $segments[1] === 'ncdiscordhook' && $segments[2] === 'discord-webhook') { + // Expected: apps/nc_bot_webhooks/discord-webhook/{roomToken}/{token} + if (count($segments) >= 5 && $segments[0] === 'apps' && $segments[1] === 'nc_bot_webhooks' && $segments[2] === 'discord-webhook') { $roomToken = $segments[3]; $token = $segments[4]; $result['room_token'] = $roomToken; @@ -697,7 +697,7 @@ class WebhookController extends Controller { } else { $result['url_valid'] = false; - $result['parse_error'] = 'URL does not match expected pattern: /apps/ncdiscordhook/discord-webhook/{roomToken}/{token}'; + $result['parse_error'] = 'URL does not match expected pattern: /apps/nc_bot_webhooks/discord-webhook/{roomToken}/{token}'; } return $result; @@ -714,7 +714,7 @@ class WebhookController extends Controller { $path = $parsed['path'] ?? ''; $segments = explode('/', trim($path, '/')); - if (!(count($segments) >= 5 && $segments[0] === 'apps' && $segments[1] === 'ncdiscordhook' && $segments[2] === 'discord-webhook')) { + if (!(count($segments) >= 5 && $segments[0] === 'apps' && $segments[1] === 'nc_bot_webhooks' && $segments[2] === 'discord-webhook')) { return ['error' => 'Invalid webhook URL format']; } @@ -733,14 +733,14 @@ class WebhookController extends Controller { // Step 2: Build a realistic Discord-style test payload $testPayload = [ - 'content' => '🔧 **Test message from ncdiscordhook debug**\n\nThis is a test message sent via the debug endpoint. If you see this, the webhook pipeline is working!', + 'content' => '🔧 **Test message from nc_bot_webhooks debug**\n\nThis is a test message sent via the debug endpoint. If you see this, the webhook pipeline is working!', 'embeds' => [ [ 'title' => 'Webhook Test', 'description' => 'Sent at ' . date('Y-m-d H:i:s T'), 'color' => 3066993, 'footer' => [ - 'text' => 'ncdiscordhook debug endpoint', + 'text' => 'nc_bot_webhooks debug endpoint', ], ], ], @@ -852,7 +852,7 @@ class WebhookController extends Controller { /** * Get available Talk rooms. * - * URL: GET /apps/ncdiscordhook/rooms + * URL: GET /apps/nc_bot_webhooks/rooms */ #[AdminRequired] #[NoCSRFRequired] @@ -902,7 +902,7 @@ class WebhookController extends Controller { return new DataResponse($result); } catch (\Exception $e) { - $this->logger->error('NCdiscordhook getRooms failed: ' . $e->getMessage(), ['app' => 'ncdiscordhook', 'exception' => (string)$e]); + $this->logger->error('NCbotwebhooks getRooms failed: ' . $e->getMessage(), ['app' => 'nc_bot_webhooks', 'exception' => (string)$e]); return new DataResponse( ['error' => 'Server error: ' . $e->getMessage()], Http::STATUS_INTERNAL_SERVER_ERROR, diff --git a/lib/Cron/ImageCleanup.php b/lib/Cron/ImageCleanup.php index 23c2a56..8204244 100644 --- a/lib/Cron/ImageCleanup.php +++ b/lib/Cron/ImageCleanup.php @@ -1,8 +1,8 @@ rootFolder->getUserFolder($bot->getUID()); - $imagesDir = $userFolder->getFolder('NCdiscordhook-images'); + $imagesDir = $userFolder->getFolder('nc_bot_webhooks-images'); } catch (\Exception $e) { return; } @@ -46,8 +46,8 @@ class ImageCleanup implements IJob { if ($count > 0) { $this->logger->info( - 'NCdiscordhook: purged ' . $count . ' old image files', - ['app' => 'ncdiscordhook'], + 'NCbotwebhooks: purged ' . $count . ' old image files', + ['app' => 'nc_bot_webhooks'], ); } } diff --git a/lib/NavigationProvider.php b/lib/NavigationProvider.php index ca606c7..a97103c 100644 --- a/lib/NavigationProvider.php +++ b/lib/NavigationProvider.php @@ -1,6 +1,6 @@ 'ncdiscordhook', - 'app_id' => 'ncdiscordhook', + 'id' => 'nc_bot_webhooks', + 'app_id' => 'nc_bot_webhooks', 'type' => 'settings', - 'name' => $this->l10n->t('NCdiscordhook'), + 'name' => $this->l10n->t('NCbotwebhooks'), 'href' => $this->urlGenerator->linkToRoute('settings.AdminSettings#index'), - 'icon' => $this->urlGenerator->imagePath('ncdiscordhook', 'app.svg'), + 'icon' => $this->urlGenerator->imagePath('nc_bot_webhooks', 'app.svg'), 'order' => 0, ], ]; diff --git a/lib/Service/TalkService.php b/lib/Service/TalkService.php index 47280fd..b39a838 100644 --- a/lib/Service/TalkService.php +++ b/lib/Service/TalkService.php @@ -1,6 +1,6 @@ config->getSystemValueString('dbtableprefix', ''); $talkPrefix = $this->config->getAppValue('spreed', 'databaseprefix', $sysPrefix); - $this->logger->warning('NCdiscordhook: Talk tables not found', [ + $this->logger->warning('NCbotwebhooks: Talk tables not found', [ 'app' => self::APP_ID, 'sysPrefix' => $sysPrefix, 'talkPrefix' => $talkPrefix, @@ -235,7 +235,7 @@ class TalkService { AND name NOT LIKE \'["%\''; $result = $this->db->executeQuery($sql); } catch (\Exception $e) { - $this->logger->warning('NCdiscordhook: room name query failed, using token fallback', [ + $this->logger->warning('NCbotwebhooks: room name query failed, using token fallback', [ 'app' => self::APP_ID, 'error' => $e->getMessage(), ]); @@ -249,7 +249,7 @@ class TalkService { $result = $this->db->executeQuery($sql); } - $this->logger->info('NCdiscordhook: getAvailableTalkRooms', [ + $this->logger->info('NCbotwebhooks: getAvailableTalkRooms', [ 'app' => self::APP_ID, 'room_table' => $roomTable, ]); @@ -261,14 +261,14 @@ class TalkService { } $result->closeCursor(); - $this->logger->info('NCdiscordhook: found ' . count($rooms) . ' rooms', [ + $this->logger->info('NCbotwebhooks: found ' . count($rooms) . ' rooms', [ 'app' => self::APP_ID, 'rooms' => array_keys($rooms), ]); return $rooms; } catch (\Exception $e) { - $this->logger->error('NCdiscordhook: room listing exception', [ + $this->logger->error('NCbotwebhooks: room listing exception', [ 'app' => self::APP_ID, 'error' => $e->getMessage(), 'file' => $e->getFile(), @@ -365,7 +365,7 @@ class TalkService { } $result->closeCursor(); } catch (\Exception $e) { - $this->logger->warning('NCdiscordhook: information_schema query failed', [ + $this->logger->warning('NCbotwebhooks: information_schema query failed', [ 'app' => self::APP_ID, 'error' => $e->getMessage(), ]); @@ -783,7 +783,7 @@ class TalkService { /** * Upload an image to the bot user's files. - * Returns the file path (e.g. NCdiscordhook-images/roomToken/filename.png) or null on failure. + * Returns the file path (e.g. nc_bot_webhooks-images/roomToken/filename.png) or null on failure. */ public function uploadImage(string $roomToken, string $filename, string $data, string $mimeType): ?string { $bot = $this->userManager->get('talk-bot'); @@ -878,13 +878,13 @@ class TalkService { ): bool { $botPassword = $this->getBotPassword(); if ($botPassword === null) { - $this->logger->error('NCdiscordhook: bot password not configured', ['app' => self::APP_ID]); + $this->logger->error('NCbotwebhooks: bot password not configured', ['app' => self::APP_ID]); return false; } // Check bot is enabled for this room (via AppConfig) if (!$this->isBotEnabledForRoom($roomToken)) { - $this->logger->warning('NCdiscordhook: bot not enabled for room', [ + $this->logger->warning('NCbotwebhooks: bot not enabled for room', [ 'app' => self::APP_ID, 'room_token' => $roomToken, ]); @@ -893,7 +893,7 @@ class TalkService { $baseUrl = $this->getBaseUrl(); if ($baseUrl === '') { - $this->logger->error('NCdiscordhook: base URL not configured', ['app' => self::APP_ID]); + $this->logger->error('NCbotwebhooks: base URL not configured', ['app' => self::APP_ID]); return false; } @@ -947,21 +947,21 @@ class TalkService { $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 300) { - $this->logger->info('NCdiscordhook: message posted to room ' . $roomToken, [ + $this->logger->info('NCbotwebhooks: message posted to room ' . $roomToken, [ 'app' => self::APP_ID, ]); return true; } $responseBody = $response->getBody(); - $this->logger->error('NCdiscordhook: chat API returned ' . $statusCode . ': ' . $responseBody, [ + $this->logger->error('NCbotwebhooks: chat API returned ' . $statusCode . ': ' . $responseBody, [ 'app' => self::APP_ID, 'room_token' => $roomToken, 'status' => $statusCode, ]); return false; } catch (\Exception $e) { - $this->logger->error('NCdiscordhook: chat API request failed: ' . $e->getMessage(), [ + $this->logger->error('NCbotwebhooks: chat API request failed: ' . $e->getMessage(), [ 'app' => self::APP_ID, 'room_token' => $roomToken, ]); @@ -1005,7 +1005,7 @@ class TalkService { } catch (DoesNotExistException $e) { return 'talk-bot'; } catch (\Exception $e) { - $this->logger->warning('NCdiscordhook: failed to get bot display name for room ' . $roomToken, [ + $this->logger->warning('NCbotwebhooks: failed to get bot display name for room ' . $roomToken, [ 'app' => self::APP_ID, 'error' => $e->getMessage(), ]); @@ -1125,7 +1125,7 @@ class TalkService { // Get the talk-bot user $botUser = $this->userManager->get('talk-bot'); if ($botUser === null) { - $this->logger->warning('NCdiscordhook: talk-bot user not found', ['app' => self::APP_ID]); + $this->logger->warning('NCbotwebhooks: talk-bot user not found', ['app' => self::APP_ID]); return; } @@ -1137,7 +1137,7 @@ class TalkService { // Detect Talk rooms table name $roomTable = $this->detectTalkTableFromCatalog('talk_rooms', 'spreed_room'); if ($roomTable === null) { - $this->logger->warning('NCdiscordhook: Talk rooms table not found, skipping participant setup', [ + $this->logger->warning('NCbotwebhooks: Talk rooms table not found, skipping participant setup', [ 'app' => self::APP_ID, ]); return; @@ -1154,7 +1154,7 @@ class TalkService { $stmt->closeCursor(); if ($roomId === 0) { - $this->logger->warning('NCdiscordhook: room token not found in database', [ + $this->logger->warning('NCbotwebhooks: room token not found in database', [ 'app' => self::APP_ID, 'token' => $token, ]); @@ -1184,18 +1184,18 @@ class TalkService { try { $this->attendeeMapper->insert($newAttendee); - $this->logger->info('NCdiscordhook: added talk-bot as participant in room ' . $token, [ + $this->logger->info('NCbotwebhooks: added talk-bot as participant in room ' . $token, [ 'app' => self::APP_ID, 'room_id' => $roomId, ]); } catch (\Exception $e) { - $this->logger->warning('NCdiscordhook: failed to insert attendee for room ' . $token, [ + $this->logger->warning('NCbotwebhooks: failed to insert attendee for room ' . $token, [ 'app' => self::APP_ID, 'error' => $e->getMessage(), ]); } } catch (\Exception $e) { - $this->logger->warning('NCdiscordhook: failed to add talk-bot to room ' . $token, [ + $this->logger->warning('NCbotwebhooks: failed to add talk-bot to room ' . $token, [ 'app' => self::APP_ID, 'error' => $e->getMessage(), ]); diff --git a/lib/Settings/Admin.php b/lib/Settings/Admin.php index 11dbe21..a8e8511 100644 --- a/lib/Settings/Admin.php +++ b/lib/Settings/Admin.php @@ -1,8 +1,8 @@ $this->talkService->hasBotPassword(), @@ -53,7 +53,7 @@ class Admin implements ISettings { ], ]; - $response = new TemplateResponse('ncdiscordhook', 'adminSettings', $params); + $response = new TemplateResponse('nc_bot_webhooks', 'adminSettings', $params); return $response; } @@ -68,7 +68,7 @@ class Admin implements ISettings { public function getIcons(): array { $urlGenerator = \OC::$server->get(\OCP\IURLGenerator::class); return [ - $urlGenerator->imagePath('ncdiscordhook', 'app.svg'), + $urlGenerator->imagePath('nc_bot_webhooks', 'app.svg'), ]; } }