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
This commit is contained in:
kyle
2026-06-12 18:30:12 -07:00
parent 98e044ede7
commit 19241c842d
14 changed files with 138 additions and 138 deletions
+21 -21
View File
@@ -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/<room-token>/<auth-token>
https://your-nextcloud-server/apps/nc_bot_webhooks/discord-webhook/<room-token>/<auth-token>
```
Replace `<room-token>` and `<auth-token>` 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/<room-token>/<auth-token>
-d '{"content":"Test message from NCbotwebhooks","username":"CI Bot"}' \
https://your-nextcloud-server/apps/nc_bot_webhooks/discord-webhook/<room-token>/<auth-token>
```
## 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/<room-token>/notify/<auth-token>
https://your-nextcloud-server/apps/nc_bot_webhooks/apprise-webhook/<room-token>/notify/<auth-token>
```
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
```
+13 -13
View File
@@ -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/<room-token>/<auth-token>
https://your-server.com/apps/nc_bot_webhooks/discord-webhook/<room-token>/<auth-token>
```
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/<room-token>/notify/<auth-token>
https://your-server.com/apps/nc_bot_webhooks/apprise-webhook/<room-token>/notify/<auth-token>
```
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/<room-token>/`
- Images are uploaded to the bot user's files at `/nc_bot_webhooks-images/<room-token>/`
- 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
+1 -1
View File
@@ -1,6 +1,6 @@
<?php
return [
'jobs' => [
\OCA\NCdiscordhook\Cron\ImageCleanup::class,
\OCA\Ncbotwebhooks\Cron\ImageCleanup::class,
],
];
+6 -6
View File
@@ -1,14 +1,14 @@
<?xml version="1.0"?>
<info xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://apps.nextcloud.com/schema/apps/info.xsd">
<id>ncdiscordhook</id>
<name>NCdiscordhook</name>
<id>nc_bot_webhooks</id>
<name>NCbotwebhooks</name>
<summary>Discord webhook bridge for Nextcloud Talk with image support</summary>
<description>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.</description>
<version>1.1.0</version>
<licence>AGPL-3.0-or-later</licence>
<author homepage="https://github.com/Mr-Newlove/nc_bot_webhooks/kyle">Kyle</author>
<namespace>NCdiscordhook</namespace>
<namespace>Ncbotwebhooks</namespace>
<category>integration</category>
<dependencies>
@@ -17,15 +17,15 @@
</dependencies>
<background-jobs>
OCA\NCdiscordhook\Cron\ImageCleanup
OCA\Ncbotwebhooks\Cron\ImageCleanup
</background-jobs>
<settings>
<admin>OCA\NCdiscordhook\Settings\Admin</admin>
<admin>OCA\Ncbotwebhooks\Settings\Admin</admin>
</settings>
<commands>
<command>OCA\NCdiscordhook\Command\DebugToggle</command>
<command>OCA\Ncbotwebhooks\Command\DebugToggle</command>
</commands>
<bugs>https://github.com/Mr-Newlove/nc_bot_webhooks/issues</bugs>
+2 -2
View File
@@ -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/"
}
}
}
+4 -4
View File
@@ -1,13 +1,13 @@
<?php
// Generated autoload file for ncdiscordhook
// Provides PSR-4 autoloading for OCA\NCdiscordhook\
// Generated autoload file for nc_bot_webhooks
// Provides PSR-4 autoloading for OCA\Ncbotwebhooks\
$baseDir = dirname(__DIR__);
spl_autoload_register(function ($class) use ($baseDir) {
// OCA\NCdiscordhook\ prefix
$prefix = 'OCA\\NCdiscordhook\\';
// OCA\Ncbotwebhooks\ prefix
$prefix = 'OCA\\Ncbotwebhooks\\';
$prefixLen = strlen($prefix);
if (strncmp($class, $prefix, $prefixLen) !== 0) {
return;
+1 -1
View File
@@ -6,5 +6,5 @@ $vendorDir = '';
$baseDir = dirname(__DIR__);
return [
'OCA\\NCdiscordhook\\' => [$baseDir . '/lib'],
'OCA\\Ncbotwebhooks\\' => [$baseDir . '/lib'],
];
+1 -1
View File
@@ -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) {
+9 -9
View File
@@ -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;
}
+41 -41
View File
@@ -1,8 +1,8 @@
<?php
namespace OCA\NCdiscordhook\Controller;
namespace OCA\Ncbotwebhooks\Controller;
use OCA\NCdiscordhook\Service\TalkService;
use OCA\Ncbotwebhooks\Service\TalkService;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataResponse;
@@ -30,7 +30,7 @@ class WebhookController extends Controller {
private IClientService $clientService;
public function __construct(IRequest $request, TalkService $talkService, LoggerInterface $logger, IAppManager $appManager, IUserSession $userSession, IGroupManager $groupManager, IConfig $config, IAppConfig $appConfig, IClientService $clientService) {
parent::__construct('ncdiscordhook', $request);
parent::__construct('nc_bot_webhooks', $request);
$this->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,
+5 -5
View File
@@ -1,8 +1,8 @@
<?php
namespace OCA\NCdiscordhook\Cron;
namespace OCA\Ncbotwebhooks\Cron;
use OCA\NCdiscordhook\Service\TalkService;
use OCA\Ncbotwebhooks\Service\TalkService;
use OCP\BackgroundJob\IJob;
use OCP\Files\IRootFolder;
use OCP\IConfig;
@@ -37,7 +37,7 @@ class ImageCleanup implements IJob {
// Check if images directory exists
try {
$userFolder = $this->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'],
);
}
}
+5 -5
View File
@@ -1,6 +1,6 @@
<?php
namespace OCA\NCdiscordhook;
namespace OCA\Ncbotwebhooks;
use OCP\IConfig;
use OCP\IL10N;
@@ -24,12 +24,12 @@ class NavigationProvider implements INavigationProvider {
return [
[
'id' => '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,
],
];
+23 -23
View File
@@ -1,6 +1,6 @@
<?php
namespace OCA\NCdiscordhook\Service;
namespace OCA\Ncbotwebhooks\Service;
use OCP\AppFramework\Http;
use OCP\Files\File;
@@ -21,8 +21,8 @@ use OCP\AppFramework\Db\DoesNotExistException;
use Psr\Log\LoggerInterface;
class TalkService {
private const APP_ID = 'ncdiscordhook';
private const IMAGES_DIR = 'NCdiscordhook-images';
private const APP_ID = 'nc_bot_webhooks';
private const IMAGES_DIR = 'nc_bot_webhooks-images';
private IDBConnection $db;
private IRootFolder $rootFolder;
@@ -213,7 +213,7 @@ class TalkService {
if ($roomTable === null) {
$sysPrefix = $this->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(),
]);
+6 -6
View File
@@ -1,8 +1,8 @@
<?php
namespace OCA\NCdiscordhook\Settings;
namespace OCA\Ncbotwebhooks\Settings;
use OCA\NCdiscordhook\Service\TalkService;
use OCA\Ncbotwebhooks\Service\TalkService;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IL10N;
use OCP\Settings\ISettings;
@@ -17,8 +17,8 @@ class Admin implements ISettings {
}
public function getForm(): TemplateResponse {
\OCP\Util::addStyle('ncdiscordhook', 'adminSettings');
\OCP\Util::addScript('ncdiscordhook', 'settings');
\OCP\Util::addStyle('nc_bot_webhooks', 'adminSettings');
\OCP\Util::addScript('nc_bot_webhooks', 'settings');
$params = [
'hasBotPassword' => $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'),
];
}
}