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:
+21
-21
@@ -1,4 +1,4 @@
|
|||||||
# NCdiscordhook — Installation Guide
|
# NCbotwebhooks — Installation Guide
|
||||||
|
|
||||||
## Prerequisites
|
## 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**
|
1. Log in to Nextcloud as **admin**
|
||||||
2. Go to **Settings → talk-bot → Devices & sessions**
|
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
|
4. Copy the generated device password — you'll need this in Step 3
|
||||||
|
|
||||||
## Step 2: Install the app
|
## Step 2: Install the app
|
||||||
|
|
||||||
### Option A: From the web UI (recommended)
|
### 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
|
```bash
|
||||||
cd /path/to/ncdiscordhook
|
cd /path/to/nc_bot_webhooks
|
||||||
zip -r ../ncdiscdhook.zip .
|
zip -r ../nc_bot_webhooks.zip .
|
||||||
```
|
```
|
||||||
|
|
||||||
2. Upload via web UI:
|
2. Upload via web UI:
|
||||||
- Go to **Apps → Apps management** (or **Administration → Apps**)
|
- Go to **Apps → Apps management** (or **Administration → Apps**)
|
||||||
- Click **Upload app** (or **Download and enable** → upload the ZIP)
|
- 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
|
- The app will install and enable automatically
|
||||||
|
|
||||||
### Option B: From the command line
|
### Option B: From the command line
|
||||||
@@ -59,20 +59,20 @@ zip -r ../ncdiscdhook.zip .
|
|||||||
cd /path/to/nextcloud/apps
|
cd /path/to/nextcloud/apps
|
||||||
git clone https://github.com/Mr-Newlove/nc_bot_webhooks.git
|
git clone https://github.com/Mr-Newlove/nc_bot_webhooks.git
|
||||||
# or copy the directory manually:
|
# 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:
|
Enable the app:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd /path/to/nextcloud
|
cd /path/to/nextcloud
|
||||||
php occ app:enable ncdiscordhook
|
php occ app:enable nc_bot_webhooks
|
||||||
```
|
```
|
||||||
|
|
||||||
## Step 3: Configure the app
|
## Step 3: Configure the app
|
||||||
|
|
||||||
1. Log in to Nextcloud as **admin**
|
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
|
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")
|
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)
|
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:
|
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.
|
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
|
```bash
|
||||||
curl -X POST \
|
curl -X POST \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d '{"content":"Test message from NCdiscordhook","username":"CI Bot"}' \
|
-d '{"content":"Test message from NCbotwebhooks","username":"CI Bot"}' \
|
||||||
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>
|
||||||
```
|
```
|
||||||
|
|
||||||
## Apprise 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:
|
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.
|
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.
|
- **"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.
|
- **"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.
|
- **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 `NCdiscordhook-images` folder can be created.
|
- **Image upload fails** — Verify the bot user has file storage quota and the `NCbotwebhooks-images` folder can be created.
|
||||||
|
|
||||||
## Security Notes
|
## Security Notes
|
||||||
|
|
||||||
@@ -138,25 +138,25 @@ Apprise sends a different JSON format (`title`, `body`, `type`, `attachments`)
|
|||||||
|
|
||||||
### Debug endpoint
|
### 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**.
|
database schema, and bot credentials. It is **disabled by default**.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Check status
|
# Check status
|
||||||
php occ ncdiscordhook:debug:status
|
php occ nc_bot_webhooks:debug:status
|
||||||
|
|
||||||
# Enable (WARNING: exposes sensitive data)
|
# Enable (WARNING: exposes sensitive data)
|
||||||
php occ ncdiscordhook:debug:enable
|
php occ nc_bot_webhooks:debug:enable
|
||||||
|
|
||||||
# Disable (default)
|
# Disable (default)
|
||||||
php occ ncdiscordhook:debug:disable
|
php occ nc_bot_webhooks:debug:disable
|
||||||
|
|
||||||
# Toggle current state
|
# Toggle current state
|
||||||
php occ ncdiscordhook:debug:toggle
|
php occ nc_bot_webhooks:debug:toggle
|
||||||
```
|
```
|
||||||
|
|
||||||
After troubleshooting, disable it immediately:
|
After troubleshooting, disable it immediately:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
php occ ncdiscordhook:debug:disable
|
php occ nc_bot_webhooks:debug:disable
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# NCdiscordhook
|
# NCbotwebhooks
|
||||||
|
|
||||||
Discord webhook bridge for Nextcloud Talk with image attachment support.
|
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
|
```bash
|
||||||
cd /path/to/nextcloud/apps
|
cd /path/to/nextcloud/apps
|
||||||
cp -r /path/to/ncdiscordhook .
|
cp -r /path/to/nc_bot_webhooks .
|
||||||
php occ app:enable ncdiscordhook
|
php occ app:enable nc_bot_webhooks
|
||||||
```
|
```
|
||||||
|
|
||||||
### 2. Create the bot user
|
### 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
|
### 4. Configure the app
|
||||||
|
|
||||||
Go to **Settings → Admin → NCdiscordhook**:
|
Go to **Settings → Admin → NCbotwebhooks**:
|
||||||
|
|
||||||
1. **Bot Configuration** — paste the app password from step 3
|
1. **Bot Configuration** — paste the app password from step 3
|
||||||
2. **Image Retention** — set how long to keep uploaded images (default: 90 days)
|
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):
|
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.
|
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:
|
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.
|
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
|
## 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)
|
- 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
|
- 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
|
### 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
|
database schema, and bot credentials. It is **disabled by default** and must
|
||||||
be explicitly enabled via the CLI:
|
be explicitly enabled via the CLI:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Check current status
|
# Check current status
|
||||||
php occ ncdiscordhook:debug:status
|
php occ nc_bot_webhooks:debug:status
|
||||||
|
|
||||||
# Enable (WARNING: exposes sensitive data)
|
# Enable (WARNING: exposes sensitive data)
|
||||||
php occ ncdiscordhook:debug:enable
|
php occ nc_bot_webhooks:debug:enable
|
||||||
|
|
||||||
# Disable (default)
|
# Disable (default)
|
||||||
php occ ncdiscordhook:debug:disable
|
php occ nc_bot_webhooks:debug:disable
|
||||||
|
|
||||||
# Toggle current state
|
# 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,
|
Never leave the debug endpoint enabled in production. After troubleshooting,
|
||||||
disable it immediately:
|
disable it immediately:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
php occ ncdiscordhook:debug:disable
|
php occ nc_bot_webhooks:debug:disable
|
||||||
```
|
```
|
||||||
|
|
||||||
## Logging
|
## Logging
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
return [
|
return [
|
||||||
'jobs' => [
|
'jobs' => [
|
||||||
\OCA\NCdiscordhook\Cron\ImageCleanup::class,
|
\OCA\Ncbotwebhooks\Cron\ImageCleanup::class,
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|||||||
+6
-6
@@ -1,14 +1,14 @@
|
|||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<info xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<info xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:noNamespaceSchemaLocation="https://apps.nextcloud.com/schema/apps/info.xsd">
|
xsi:noNamespaceSchemaLocation="https://apps.nextcloud.com/schema/apps/info.xsd">
|
||||||
<id>ncdiscordhook</id>
|
<id>nc_bot_webhooks</id>
|
||||||
<name>NCdiscordhook</name>
|
<name>NCbotwebhooks</name>
|
||||||
<summary>Discord webhook bridge for Nextcloud Talk with image support</summary>
|
<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>
|
<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>
|
<version>1.1.0</version>
|
||||||
<licence>AGPL-3.0-or-later</licence>
|
<licence>AGPL-3.0-or-later</licence>
|
||||||
<author homepage="https://github.com/Mr-Newlove/nc_bot_webhooks/kyle">Kyle</author>
|
<author homepage="https://github.com/Mr-Newlove/nc_bot_webhooks/kyle">Kyle</author>
|
||||||
<namespace>NCdiscordhook</namespace>
|
<namespace>Ncbotwebhooks</namespace>
|
||||||
<category>integration</category>
|
<category>integration</category>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@@ -17,15 +17,15 @@
|
|||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<background-jobs>
|
<background-jobs>
|
||||||
OCA\NCdiscordhook\Cron\ImageCleanup
|
OCA\Ncbotwebhooks\Cron\ImageCleanup
|
||||||
</background-jobs>
|
</background-jobs>
|
||||||
|
|
||||||
<settings>
|
<settings>
|
||||||
<admin>OCA\NCdiscordhook\Settings\Admin</admin>
|
<admin>OCA\Ncbotwebhooks\Settings\Admin</admin>
|
||||||
</settings>
|
</settings>
|
||||||
|
|
||||||
<commands>
|
<commands>
|
||||||
<command>OCA\NCdiscordhook\Command\DebugToggle</command>
|
<command>OCA\Ncbotwebhooks\Command\DebugToggle</command>
|
||||||
</commands>
|
</commands>
|
||||||
|
|
||||||
<bugs>https://github.com/Mr-Newlove/nc_bot_webhooks/issues</bugs>
|
<bugs>https://github.com/Mr-Newlove/nc_bot_webhooks/issues</bugs>
|
||||||
|
|||||||
+2
-2
@@ -1,10 +1,10 @@
|
|||||||
{
|
{
|
||||||
"name": "ncdiscordhook/app",
|
"name": "nc_bot_webhooks/app",
|
||||||
"description": "Discord webhook bridge for Nextcloud Talk",
|
"description": "Discord webhook bridge for Nextcloud Talk",
|
||||||
"type": "nextcloud-app",
|
"type": "nextcloud-app",
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"OCA\\NCdiscordhook\\": "../lib/"
|
"OCA\\Ncbotwebhooks\\": "../lib/"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
// Generated autoload file for ncdiscordhook
|
// Generated autoload file for nc_bot_webhooks
|
||||||
// Provides PSR-4 autoloading for OCA\NCdiscordhook\
|
// Provides PSR-4 autoloading for OCA\Ncbotwebhooks\
|
||||||
|
|
||||||
$baseDir = dirname(__DIR__);
|
$baseDir = dirname(__DIR__);
|
||||||
|
|
||||||
spl_autoload_register(function ($class) use ($baseDir) {
|
spl_autoload_register(function ($class) use ($baseDir) {
|
||||||
// OCA\NCdiscordhook\ prefix
|
// OCA\Ncbotwebhooks\ prefix
|
||||||
$prefix = 'OCA\\NCdiscordhook\\';
|
$prefix = 'OCA\\Ncbotwebhooks\\';
|
||||||
$prefixLen = strlen($prefix);
|
$prefixLen = strlen($prefix);
|
||||||
if (strncmp($class, $prefix, $prefixLen) !== 0) {
|
if (strncmp($class, $prefix, $prefixLen) !== 0) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -6,5 +6,5 @@ $vendorDir = '';
|
|||||||
$baseDir = dirname(__DIR__);
|
$baseDir = dirname(__DIR__);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'OCA\\NCdiscordhook\\' => [$baseDir . '/lib'],
|
'OCA\\Ncbotwebhooks\\' => [$baseDir . '/lib'],
|
||||||
];
|
];
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
document.addEventListener('DOMContentLoaded', function () {
|
document.addEventListener('DOMContentLoaded', function () {
|
||||||
const APP_ID = 'ncdiscordhook';
|
const APP_ID = 'nc_bot_webhooks';
|
||||||
|
|
||||||
// Read config passed via data attributes on the page
|
// Read config passed via data attributes on the page
|
||||||
function parseData(el, key) {
|
function parseData(el, key) {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace OCA\NCdiscordhook\Command;
|
namespace OCA\Ncbotwebhooks\Command;
|
||||||
|
|
||||||
use OCP\AppFramework\Controller;
|
use OCP\AppFramework\Controller;
|
||||||
use OCP\AppFramework\Http;
|
use OCP\AppFramework\Http;
|
||||||
@@ -33,19 +33,19 @@ use Symfony\Component\Console\Style\SymfonyStyle;
|
|||||||
*
|
*
|
||||||
* Usage:
|
* Usage:
|
||||||
* # Enable debug
|
* # Enable debug
|
||||||
* php occ ncdiscordhook:debug:enable
|
* php occ nc_bot_webhooks:debug:enable
|
||||||
*
|
*
|
||||||
* # Disable debug
|
* # Disable debug
|
||||||
* php occ ncdiscordhook:debug:disable
|
* php occ nc_bot_webhooks:debug:disable
|
||||||
*
|
*
|
||||||
* # Toggle (disable if enabled, enable if disabled)
|
* # Toggle (disable if enabled, enable if disabled)
|
||||||
* php occ ncdiscordhook:debug:toggle
|
* php occ nc_bot_webhooks:debug:toggle
|
||||||
*
|
*
|
||||||
* # Check current status
|
* # Check current status
|
||||||
* php occ ncdiscordhook:debug:status
|
* php occ nc_bot_webhooks:debug:status
|
||||||
*/
|
*/
|
||||||
class DebugToggle extends Command {
|
class DebugToggle extends Command {
|
||||||
private const APP_ID = 'ncdiscordhook';
|
private const APP_ID = 'nc_bot_webhooks';
|
||||||
private const DEBUG_KEY = 'debug_enabled';
|
private const DEBUG_KEY = 'debug_enabled';
|
||||||
|
|
||||||
private IAppConfig $appConfig;
|
private IAppConfig $appConfig;
|
||||||
@@ -57,7 +57,7 @@ class DebugToggle extends Command {
|
|||||||
|
|
||||||
protected function configure(): void {
|
protected function configure(): void {
|
||||||
$this
|
$this
|
||||||
->setName('ncdiscordhook:debug:toggle')
|
->setName('nc_bot_webhooks:debug:toggle')
|
||||||
->setDescription('Enable or disable the debug endpoint')
|
->setDescription('Enable or disable the debug endpoint')
|
||||||
->addOption('enable', 'e', InputOption::VALUE_NONE, 'Enable the debug endpoint')
|
->addOption('enable', 'e', InputOption::VALUE_NONE, 'Enable the debug endpoint')
|
||||||
->addOption('disable', 'd', InputOption::VALUE_NONE, 'Disable 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')) {
|
if ($input->getOption('enable')) {
|
||||||
$this->appConfig->setValueBool(self::APP_ID, self::DEBUG_KEY, true);
|
$this->appConfig->setValueBool(self::APP_ID, self::DEBUG_KEY, true);
|
||||||
$io->warning('Debug endpoint is now ENABLED. Anyone can access /apps/ncdiscordhook/debug.');
|
$io->warning('Debug endpoint is now ENABLED. Anyone can access /apps/nc_bot_webhooks/debug.');
|
||||||
$io->note('To disable later, run: php occ ncdiscordhook:debug:disable');
|
$io->note('To disable later, run: php occ nc_bot_webhooks:debug:disable');
|
||||||
return Command::SUCCESS;
|
return Command::SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?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\Controller;
|
||||||
use OCP\AppFramework\Http;
|
use OCP\AppFramework\Http;
|
||||||
use OCP\AppFramework\Http\DataResponse;
|
use OCP\AppFramework\Http\DataResponse;
|
||||||
@@ -30,7 +30,7 @@ class WebhookController extends Controller {
|
|||||||
private IClientService $clientService;
|
private IClientService $clientService;
|
||||||
|
|
||||||
public function __construct(IRequest $request, TalkService $talkService, LoggerInterface $logger, IAppManager $appManager, IUserSession $userSession, IGroupManager $groupManager, IConfig $config, IAppConfig $appConfig, 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->talkService = $talkService;
|
||||||
$this->logger = $logger;
|
$this->logger = $logger;
|
||||||
$this->appManager = $appManager;
|
$this->appManager = $appManager;
|
||||||
@@ -44,15 +44,15 @@ class WebhookController extends Controller {
|
|||||||
/**
|
/**
|
||||||
* Receive Discord webhook payload for a room.
|
* 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]
|
#[PublicPage]
|
||||||
#[NoCSRFRequired]
|
#[NoCSRFRequired]
|
||||||
public function receive(string $roomToken, string $token): DataResponse {
|
public function receive(string $roomToken, string $token): DataResponse {
|
||||||
// Validate auth token
|
// Validate auth token
|
||||||
if (!$this->talkService->validateAuthToken($roomToken, $token)) {
|
if (!$this->talkService->validateAuthToken($roomToken, $token)) {
|
||||||
$this->logger->warning('NCdiscordhook: invalid auth token for room', [
|
$this->logger->warning('NCbotwebhooks: invalid auth token for room', [
|
||||||
'app' => 'ncdiscordhook',
|
'app' => 'nc_bot_webhooks',
|
||||||
'room_token' => $roomToken,
|
'room_token' => $roomToken,
|
||||||
]);
|
]);
|
||||||
return new DataResponse(
|
return new DataResponse(
|
||||||
@@ -66,8 +66,8 @@ class WebhookController extends Controller {
|
|||||||
$body = file_get_contents('php://input');
|
$body = file_get_contents('php://input');
|
||||||
$data = @json_decode($body, true);
|
$data = @json_decode($body, true);
|
||||||
if (json_last_error() !== JSON_ERROR_NONE || !is_array($data)) {
|
if (json_last_error() !== JSON_ERROR_NONE || !is_array($data)) {
|
||||||
$this->logger->warning('NCdiscordhook: invalid JSON from webhook', [
|
$this->logger->warning('NCbotwebhooks: invalid JSON from webhook', [
|
||||||
'app' => 'ncdiscordhook',
|
'app' => 'nc_bot_webhooks',
|
||||||
'room_token' => $roomToken,
|
'room_token' => $roomToken,
|
||||||
]);
|
]);
|
||||||
return new DataResponse(
|
return new DataResponse(
|
||||||
@@ -133,8 +133,8 @@ class WebhookController extends Controller {
|
|||||||
$success = $this->talkService->postToRoom($roomToken, $message, $senderName, $richObjects);
|
$success = $this->talkService->postToRoom($roomToken, $message, $senderName, $richObjects);
|
||||||
|
|
||||||
if ($success) {
|
if ($success) {
|
||||||
$this->logger->info('NCdiscordhook: webhook processed successfully', [
|
$this->logger->info('NCbotwebhooks: webhook processed successfully', [
|
||||||
'app' => 'ncdiscordhook',
|
'app' => 'nc_bot_webhooks',
|
||||||
'room_token' => $roomToken,
|
'room_token' => $roomToken,
|
||||||
]);
|
]);
|
||||||
return new DataResponse(
|
return new DataResponse(
|
||||||
@@ -144,8 +144,8 @@ class WebhookController extends Controller {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->logger->error('NCdiscordhook: failed to post webhook message to Talk', [
|
$this->logger->error('NCbotwebhooks: failed to post webhook message to Talk', [
|
||||||
'app' => 'ncdiscordhook',
|
'app' => 'nc_bot_webhooks',
|
||||||
'room_token' => $roomToken,
|
'room_token' => $roomToken,
|
||||||
]);
|
]);
|
||||||
return new DataResponse(
|
return new DataResponse(
|
||||||
@@ -158,7 +158,7 @@ class WebhookController extends Controller {
|
|||||||
/**
|
/**
|
||||||
* Receive Apprise webhook payload for a room.
|
* 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}
|
* Also handles Apprise's notify URL format: /apprise-webhook/{roomToken}/notify/{token}
|
||||||
*
|
*
|
||||||
* Apprise sends JSON like:
|
* Apprise sends JSON like:
|
||||||
@@ -175,8 +175,8 @@ class WebhookController extends Controller {
|
|||||||
public function receiveApprise(string $roomToken, string $token): DataResponse {
|
public function receiveApprise(string $roomToken, string $token): DataResponse {
|
||||||
// Validate auth token
|
// Validate auth token
|
||||||
if (!$this->talkService->validateAuthToken($roomToken, $token)) {
|
if (!$this->talkService->validateAuthToken($roomToken, $token)) {
|
||||||
$this->logger->warning('NCdiscordhook: invalid auth token for room', [
|
$this->logger->warning('NCbotwebhooks: invalid auth token for room', [
|
||||||
'app' => 'ncdiscordhook',
|
'app' => 'nc_bot_webhooks',
|
||||||
'room_token' => $roomToken,
|
'room_token' => $roomToken,
|
||||||
]);
|
]);
|
||||||
return new DataResponse(
|
return new DataResponse(
|
||||||
@@ -215,8 +215,8 @@ class WebhookController extends Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (empty($data) || !is_array($data)) {
|
if (empty($data) || !is_array($data)) {
|
||||||
$this->logger->warning('NCdiscordhook: invalid payload from apprise webhook', [
|
$this->logger->warning('NCbotwebhooks: invalid payload from apprise webhook', [
|
||||||
'app' => 'ncdiscordhook',
|
'app' => 'nc_bot_webhooks',
|
||||||
'room_token' => $roomToken,
|
'room_token' => $roomToken,
|
||||||
'content_type' => $contentType,
|
'content_type' => $contentType,
|
||||||
'body_length' => strlen($body),
|
'body_length' => strlen($body),
|
||||||
@@ -272,8 +272,8 @@ class WebhookController extends Controller {
|
|||||||
$success = $this->talkService->postToRoom($roomToken, $message, $senderName, $richObjects);
|
$success = $this->talkService->postToRoom($roomToken, $message, $senderName, $richObjects);
|
||||||
|
|
||||||
if ($success) {
|
if ($success) {
|
||||||
$this->logger->info('NCdiscordhook: apprise webhook processed successfully', [
|
$this->logger->info('NCbotwebhooks: apprise webhook processed successfully', [
|
||||||
'app' => 'ncdiscordhook',
|
'app' => 'nc_bot_webhooks',
|
||||||
'room_token' => $roomToken,
|
'room_token' => $roomToken,
|
||||||
]);
|
]);
|
||||||
return new DataResponse(
|
return new DataResponse(
|
||||||
@@ -283,8 +283,8 @@ class WebhookController extends Controller {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->logger->error('NCdiscordhook: failed to post apprise message to Talk', [
|
$this->logger->error('NCbotwebhooks: failed to post apprise message to Talk', [
|
||||||
'app' => 'ncdiscordhook',
|
'app' => 'nc_bot_webhooks',
|
||||||
'room_token' => $roomToken,
|
'room_token' => $roomToken,
|
||||||
]);
|
]);
|
||||||
return new DataResponse(
|
return new DataResponse(
|
||||||
@@ -301,7 +301,7 @@ class WebhookController extends Controller {
|
|||||||
* Apprise's apprise:// URL scheme inserts 'notify' in the path.
|
* Apprise's apprise:// URL scheme inserts 'notify' in the path.
|
||||||
* Delegates to receiveApprise() for processing.
|
* 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]
|
#[PublicPage]
|
||||||
#[NoCSRFRequired]
|
#[NoCSRFRequired]
|
||||||
@@ -312,7 +312,7 @@ class WebhookController extends Controller {
|
|||||||
/**
|
/**
|
||||||
* Save bot password from the settings UI.
|
* Save bot password from the settings UI.
|
||||||
*
|
*
|
||||||
* URL: POST /apps/ncdiscordhook/save-bot-password
|
* URL: POST /apps/nc_bot_webhooks/save-bot-password
|
||||||
*/
|
*/
|
||||||
#[AdminRequired]
|
#[AdminRequired]
|
||||||
#[NoCSRFRequired]
|
#[NoCSRFRequired]
|
||||||
@@ -334,7 +334,7 @@ class WebhookController extends Controller {
|
|||||||
/**
|
/**
|
||||||
* Save configuration from the settings UI.
|
* Save configuration from the settings UI.
|
||||||
*
|
*
|
||||||
* URL: POST /apps/ncdiscordhook/save-config
|
* URL: POST /apps/nc_bot_webhooks/save-config
|
||||||
*/
|
*/
|
||||||
#[AdminRequired]
|
#[AdminRequired]
|
||||||
#[NoCSRFRequired]
|
#[NoCSRFRequired]
|
||||||
@@ -351,8 +351,8 @@ class WebhookController extends Controller {
|
|||||||
try {
|
try {
|
||||||
$this->talkService->saveConfig($config);
|
$this->talkService->saveConfig($config);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$this->logger->error('NCdiscordhook: saveConfig failed: ' . $e->getMessage(), [
|
$this->logger->error('NCbotwebhooks: saveConfig failed: ' . $e->getMessage(), [
|
||||||
'app' => 'ncdiscordhook',
|
'app' => 'nc_bot_webhooks',
|
||||||
'exception' => (string)$e,
|
'exception' => (string)$e,
|
||||||
]);
|
]);
|
||||||
return new DataResponse(
|
return new DataResponse(
|
||||||
@@ -370,13 +370,13 @@ class WebhookController extends Controller {
|
|||||||
/**
|
/**
|
||||||
* Debug endpoint to verify the app is working.
|
* Debug endpoint to verify the app is working.
|
||||||
*
|
*
|
||||||
* URL: GET /apps/ncdiscordhook/debug
|
* URL: GET /apps/nc_bot_webhooks/debug
|
||||||
* Query params:
|
* 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
|
* - test_post=1: Actually POST a test message to the room
|
||||||
*
|
*
|
||||||
* This endpoint is disabled by default. Enable it via:
|
* 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
|
* SECURITY: Never leave debug enabled in production. It exposes internal
|
||||||
* configuration, database schema, and bot credentials.
|
* configuration, database schema, and bot credentials.
|
||||||
@@ -386,10 +386,10 @@ class WebhookController extends Controller {
|
|||||||
#[NoAdminRequired]
|
#[NoAdminRequired]
|
||||||
public function debug(): DataResponse {
|
public function debug(): DataResponse {
|
||||||
// Debug endpoint must be explicitly enabled via OCC command
|
// 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) {
|
if (!$debugEnabled) {
|
||||||
return new DataResponse(
|
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,
|
Http::STATUS_FORBIDDEN,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -399,7 +399,7 @@ class WebhookController extends Controller {
|
|||||||
$isAdmin = $user !== null && $this->groupManager->isAdmin($uid);
|
$isAdmin = $user !== null && $this->groupManager->isAdmin($uid);
|
||||||
|
|
||||||
$info = [
|
$info = [
|
||||||
'app_enabled' => $this->appManager->isInstalled('ncdiscordhook'),
|
'app_enabled' => $this->appManager->isInstalled('nc_bot_webhooks'),
|
||||||
'user' => $uid,
|
'user' => $uid,
|
||||||
'user_is_admin' => $isAdmin,
|
'user_is_admin' => $isAdmin,
|
||||||
'bot_user' => null,
|
'bot_user' => null,
|
||||||
@@ -432,7 +432,7 @@ class WebhookController extends Controller {
|
|||||||
$knownKeys = ['bot_password', 'rooms', 'auth_tokens', 'retention_days', 'sender_name'];
|
$knownKeys = ['bot_password', 'rooms', 'auth_tokens', 'retention_days', 'sender_name'];
|
||||||
$appConfigKeys = [];
|
$appConfigKeys = [];
|
||||||
foreach ($knownKeys as $key) {
|
foreach ($knownKeys as $key) {
|
||||||
$val = $this->appConfig->getValueString('ncdiscordhook', $key, '');
|
$val = $this->appConfig->getValueString('nc_bot_webhooks', $key, '');
|
||||||
$appConfigKeys[$key] = $val !== '' ? '[set]' : '[empty]';
|
$appConfigKeys[$key] = $val !== '' ? '[set]' : '[empty]';
|
||||||
}
|
}
|
||||||
$info['app_config_keys'] = $appConfigKeys;
|
$info['app_config_keys'] = $appConfigKeys;
|
||||||
@@ -544,8 +544,8 @@ class WebhookController extends Controller {
|
|||||||
$path = $parsed['path'] ?? '';
|
$path = $parsed['path'] ?? '';
|
||||||
$segments = explode('/', trim($path, '/'));
|
$segments = explode('/', trim($path, '/'));
|
||||||
|
|
||||||
// Expected: apps/ncdiscordhook/discord-webhook/{roomToken}/{token}
|
// Expected: apps/nc_bot_webhooks/discord-webhook/{roomToken}/{token}
|
||||||
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') {
|
||||||
$roomToken = $segments[3];
|
$roomToken = $segments[3];
|
||||||
$token = $segments[4];
|
$token = $segments[4];
|
||||||
$result['room_token'] = $roomToken;
|
$result['room_token'] = $roomToken;
|
||||||
@@ -697,7 +697,7 @@ class WebhookController extends Controller {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
$result['url_valid'] = false;
|
$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;
|
return $result;
|
||||||
@@ -714,7 +714,7 @@ class WebhookController extends Controller {
|
|||||||
$path = $parsed['path'] ?? '';
|
$path = $parsed['path'] ?? '';
|
||||||
$segments = explode('/', trim($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'];
|
return ['error' => 'Invalid webhook URL format'];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -733,14 +733,14 @@ class WebhookController extends Controller {
|
|||||||
|
|
||||||
// Step 2: Build a realistic Discord-style test payload
|
// Step 2: Build a realistic Discord-style test payload
|
||||||
$testPayload = [
|
$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' => [
|
'embeds' => [
|
||||||
[
|
[
|
||||||
'title' => 'Webhook Test',
|
'title' => 'Webhook Test',
|
||||||
'description' => 'Sent at ' . date('Y-m-d H:i:s T'),
|
'description' => 'Sent at ' . date('Y-m-d H:i:s T'),
|
||||||
'color' => 3066993,
|
'color' => 3066993,
|
||||||
'footer' => [
|
'footer' => [
|
||||||
'text' => 'ncdiscordhook debug endpoint',
|
'text' => 'nc_bot_webhooks debug endpoint',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
@@ -852,7 +852,7 @@ class WebhookController extends Controller {
|
|||||||
/**
|
/**
|
||||||
* Get available Talk rooms.
|
* Get available Talk rooms.
|
||||||
*
|
*
|
||||||
* URL: GET /apps/ncdiscordhook/rooms
|
* URL: GET /apps/nc_bot_webhooks/rooms
|
||||||
*/
|
*/
|
||||||
#[AdminRequired]
|
#[AdminRequired]
|
||||||
#[NoCSRFRequired]
|
#[NoCSRFRequired]
|
||||||
@@ -902,7 +902,7 @@ class WebhookController extends Controller {
|
|||||||
|
|
||||||
return new DataResponse($result);
|
return new DataResponse($result);
|
||||||
} catch (\Exception $e) {
|
} 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(
|
return new DataResponse(
|
||||||
['error' => 'Server error: ' . $e->getMessage()],
|
['error' => 'Server error: ' . $e->getMessage()],
|
||||||
Http::STATUS_INTERNAL_SERVER_ERROR,
|
Http::STATUS_INTERNAL_SERVER_ERROR,
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?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\BackgroundJob\IJob;
|
||||||
use OCP\Files\IRootFolder;
|
use OCP\Files\IRootFolder;
|
||||||
use OCP\IConfig;
|
use OCP\IConfig;
|
||||||
@@ -37,7 +37,7 @@ class ImageCleanup implements IJob {
|
|||||||
// Check if images directory exists
|
// Check if images directory exists
|
||||||
try {
|
try {
|
||||||
$userFolder = $this->rootFolder->getUserFolder($bot->getUID());
|
$userFolder = $this->rootFolder->getUserFolder($bot->getUID());
|
||||||
$imagesDir = $userFolder->getFolder('NCdiscordhook-images');
|
$imagesDir = $userFolder->getFolder('nc_bot_webhooks-images');
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -46,8 +46,8 @@ class ImageCleanup implements IJob {
|
|||||||
|
|
||||||
if ($count > 0) {
|
if ($count > 0) {
|
||||||
$this->logger->info(
|
$this->logger->info(
|
||||||
'NCdiscordhook: purged ' . $count . ' old image files',
|
'NCbotwebhooks: purged ' . $count . ' old image files',
|
||||||
['app' => 'ncdiscordhook'],
|
['app' => 'nc_bot_webhooks'],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace OCA\NCdiscordhook;
|
namespace OCA\Ncbotwebhooks;
|
||||||
|
|
||||||
use OCP\IConfig;
|
use OCP\IConfig;
|
||||||
use OCP\IL10N;
|
use OCP\IL10N;
|
||||||
@@ -24,12 +24,12 @@ class NavigationProvider implements INavigationProvider {
|
|||||||
|
|
||||||
return [
|
return [
|
||||||
[
|
[
|
||||||
'id' => 'ncdiscordhook',
|
'id' => 'nc_bot_webhooks',
|
||||||
'app_id' => 'ncdiscordhook',
|
'app_id' => 'nc_bot_webhooks',
|
||||||
'type' => 'settings',
|
'type' => 'settings',
|
||||||
'name' => $this->l10n->t('NCdiscordhook'),
|
'name' => $this->l10n->t('NCbotwebhooks'),
|
||||||
'href' => $this->urlGenerator->linkToRoute('settings.AdminSettings#index'),
|
'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,
|
'order' => 0,
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|||||||
+23
-23
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace OCA\NCdiscordhook\Service;
|
namespace OCA\Ncbotwebhooks\Service;
|
||||||
|
|
||||||
use OCP\AppFramework\Http;
|
use OCP\AppFramework\Http;
|
||||||
use OCP\Files\File;
|
use OCP\Files\File;
|
||||||
@@ -21,8 +21,8 @@ use OCP\AppFramework\Db\DoesNotExistException;
|
|||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
class TalkService {
|
class TalkService {
|
||||||
private const APP_ID = 'ncdiscordhook';
|
private const APP_ID = 'nc_bot_webhooks';
|
||||||
private const IMAGES_DIR = 'NCdiscordhook-images';
|
private const IMAGES_DIR = 'nc_bot_webhooks-images';
|
||||||
|
|
||||||
private IDBConnection $db;
|
private IDBConnection $db;
|
||||||
private IRootFolder $rootFolder;
|
private IRootFolder $rootFolder;
|
||||||
@@ -213,7 +213,7 @@ class TalkService {
|
|||||||
if ($roomTable === null) {
|
if ($roomTable === null) {
|
||||||
$sysPrefix = $this->config->getSystemValueString('dbtableprefix', '');
|
$sysPrefix = $this->config->getSystemValueString('dbtableprefix', '');
|
||||||
$talkPrefix = $this->config->getAppValue('spreed', 'databaseprefix', $sysPrefix);
|
$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,
|
'app' => self::APP_ID,
|
||||||
'sysPrefix' => $sysPrefix,
|
'sysPrefix' => $sysPrefix,
|
||||||
'talkPrefix' => $talkPrefix,
|
'talkPrefix' => $talkPrefix,
|
||||||
@@ -235,7 +235,7 @@ class TalkService {
|
|||||||
AND name NOT LIKE \'["%\'';
|
AND name NOT LIKE \'["%\'';
|
||||||
$result = $this->db->executeQuery($sql);
|
$result = $this->db->executeQuery($sql);
|
||||||
} catch (\Exception $e) {
|
} 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,
|
'app' => self::APP_ID,
|
||||||
'error' => $e->getMessage(),
|
'error' => $e->getMessage(),
|
||||||
]);
|
]);
|
||||||
@@ -249,7 +249,7 @@ class TalkService {
|
|||||||
$result = $this->db->executeQuery($sql);
|
$result = $this->db->executeQuery($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->logger->info('NCdiscordhook: getAvailableTalkRooms', [
|
$this->logger->info('NCbotwebhooks: getAvailableTalkRooms', [
|
||||||
'app' => self::APP_ID,
|
'app' => self::APP_ID,
|
||||||
'room_table' => $roomTable,
|
'room_table' => $roomTable,
|
||||||
]);
|
]);
|
||||||
@@ -261,14 +261,14 @@ class TalkService {
|
|||||||
}
|
}
|
||||||
$result->closeCursor();
|
$result->closeCursor();
|
||||||
|
|
||||||
$this->logger->info('NCdiscordhook: found ' . count($rooms) . ' rooms', [
|
$this->logger->info('NCbotwebhooks: found ' . count($rooms) . ' rooms', [
|
||||||
'app' => self::APP_ID,
|
'app' => self::APP_ID,
|
||||||
'rooms' => array_keys($rooms),
|
'rooms' => array_keys($rooms),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $rooms;
|
return $rooms;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$this->logger->error('NCdiscordhook: room listing exception', [
|
$this->logger->error('NCbotwebhooks: room listing exception', [
|
||||||
'app' => self::APP_ID,
|
'app' => self::APP_ID,
|
||||||
'error' => $e->getMessage(),
|
'error' => $e->getMessage(),
|
||||||
'file' => $e->getFile(),
|
'file' => $e->getFile(),
|
||||||
@@ -365,7 +365,7 @@ class TalkService {
|
|||||||
}
|
}
|
||||||
$result->closeCursor();
|
$result->closeCursor();
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$this->logger->warning('NCdiscordhook: information_schema query failed', [
|
$this->logger->warning('NCbotwebhooks: information_schema query failed', [
|
||||||
'app' => self::APP_ID,
|
'app' => self::APP_ID,
|
||||||
'error' => $e->getMessage(),
|
'error' => $e->getMessage(),
|
||||||
]);
|
]);
|
||||||
@@ -783,7 +783,7 @@ class TalkService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Upload an image to the bot user's files.
|
* 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 {
|
public function uploadImage(string $roomToken, string $filename, string $data, string $mimeType): ?string {
|
||||||
$bot = $this->userManager->get('talk-bot');
|
$bot = $this->userManager->get('talk-bot');
|
||||||
@@ -878,13 +878,13 @@ class TalkService {
|
|||||||
): bool {
|
): bool {
|
||||||
$botPassword = $this->getBotPassword();
|
$botPassword = $this->getBotPassword();
|
||||||
if ($botPassword === null) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check bot is enabled for this room (via AppConfig)
|
// Check bot is enabled for this room (via AppConfig)
|
||||||
if (!$this->isBotEnabledForRoom($roomToken)) {
|
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,
|
'app' => self::APP_ID,
|
||||||
'room_token' => $roomToken,
|
'room_token' => $roomToken,
|
||||||
]);
|
]);
|
||||||
@@ -893,7 +893,7 @@ class TalkService {
|
|||||||
|
|
||||||
$baseUrl = $this->getBaseUrl();
|
$baseUrl = $this->getBaseUrl();
|
||||||
if ($baseUrl === '') {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -947,21 +947,21 @@ class TalkService {
|
|||||||
|
|
||||||
$statusCode = $response->getStatusCode();
|
$statusCode = $response->getStatusCode();
|
||||||
if ($statusCode >= 200 && $statusCode < 300) {
|
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,
|
'app' => self::APP_ID,
|
||||||
]);
|
]);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$responseBody = $response->getBody();
|
$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,
|
'app' => self::APP_ID,
|
||||||
'room_token' => $roomToken,
|
'room_token' => $roomToken,
|
||||||
'status' => $statusCode,
|
'status' => $statusCode,
|
||||||
]);
|
]);
|
||||||
return false;
|
return false;
|
||||||
} catch (\Exception $e) {
|
} 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,
|
'app' => self::APP_ID,
|
||||||
'room_token' => $roomToken,
|
'room_token' => $roomToken,
|
||||||
]);
|
]);
|
||||||
@@ -1005,7 +1005,7 @@ class TalkService {
|
|||||||
} catch (DoesNotExistException $e) {
|
} catch (DoesNotExistException $e) {
|
||||||
return 'talk-bot';
|
return 'talk-bot';
|
||||||
} catch (\Exception $e) {
|
} 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,
|
'app' => self::APP_ID,
|
||||||
'error' => $e->getMessage(),
|
'error' => $e->getMessage(),
|
||||||
]);
|
]);
|
||||||
@@ -1125,7 +1125,7 @@ class TalkService {
|
|||||||
// Get the talk-bot user
|
// Get the talk-bot user
|
||||||
$botUser = $this->userManager->get('talk-bot');
|
$botUser = $this->userManager->get('talk-bot');
|
||||||
if ($botUser === null) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1137,7 +1137,7 @@ class TalkService {
|
|||||||
// Detect Talk rooms table name
|
// Detect Talk rooms table name
|
||||||
$roomTable = $this->detectTalkTableFromCatalog('talk_rooms', 'spreed_room');
|
$roomTable = $this->detectTalkTableFromCatalog('talk_rooms', 'spreed_room');
|
||||||
if ($roomTable === null) {
|
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,
|
'app' => self::APP_ID,
|
||||||
]);
|
]);
|
||||||
return;
|
return;
|
||||||
@@ -1154,7 +1154,7 @@ class TalkService {
|
|||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
if ($roomId === 0) {
|
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,
|
'app' => self::APP_ID,
|
||||||
'token' => $token,
|
'token' => $token,
|
||||||
]);
|
]);
|
||||||
@@ -1184,18 +1184,18 @@ class TalkService {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
$this->attendeeMapper->insert($newAttendee);
|
$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,
|
'app' => self::APP_ID,
|
||||||
'room_id' => $roomId,
|
'room_id' => $roomId,
|
||||||
]);
|
]);
|
||||||
} catch (\Exception $e) {
|
} 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,
|
'app' => self::APP_ID,
|
||||||
'error' => $e->getMessage(),
|
'error' => $e->getMessage(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} 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,
|
'app' => self::APP_ID,
|
||||||
'error' => $e->getMessage(),
|
'error' => $e->getMessage(),
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?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\AppFramework\Http\TemplateResponse;
|
||||||
use OCP\IL10N;
|
use OCP\IL10N;
|
||||||
use OCP\Settings\ISettings;
|
use OCP\Settings\ISettings;
|
||||||
@@ -17,8 +17,8 @@ class Admin implements ISettings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getForm(): TemplateResponse {
|
public function getForm(): TemplateResponse {
|
||||||
\OCP\Util::addStyle('ncdiscordhook', 'adminSettings');
|
\OCP\Util::addStyle('nc_bot_webhooks', 'adminSettings');
|
||||||
\OCP\Util::addScript('ncdiscordhook', 'settings');
|
\OCP\Util::addScript('nc_bot_webhooks', 'settings');
|
||||||
|
|
||||||
$params = [
|
$params = [
|
||||||
'hasBotPassword' => $this->talkService->hasBotPassword(),
|
'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;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@ class Admin implements ISettings {
|
|||||||
public function getIcons(): array {
|
public function getIcons(): array {
|
||||||
$urlGenerator = \OC::$server->get(\OCP\IURLGenerator::class);
|
$urlGenerator = \OC::$server->get(\OCP\IURLGenerator::class);
|
||||||
return [
|
return [
|
||||||
$urlGenerator->imagePath('ncdiscordhook', 'app.svg'),
|
$urlGenerator->imagePath('nc_bot_webhooks', 'app.svg'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user