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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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'],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
@@ -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(),
|
||||
]);
|
||||
|
||||
@@ -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'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user