Add f7push webhook for support replies and ticket deep links.

OCS endpoint for support.f7cloud.ru, notification notifier, and ?ticket= URL opening in the client UI.
This commit is contained in:
root
2026-05-24 12:30:02 +03:00
parent 92df667d78
commit dc299709f7
10 changed files with 332 additions and 21 deletions
+74
View File
@@ -0,0 +1,74 @@
<?php
declare(strict_types=1);
namespace OCA\F7Support\Notification;
use OCP\IURLGenerator;
use OCP\L10N\IFactory;
use OCP\Notification\IManager as INotificationManager;
use OCP\Notification\INotification;
use OCP\Notification\INotifier;
use OCP\Notification\UnknownNotificationException;
class Notifier implements INotifier {
public function __construct(
private IFactory $l10nFactory,
private IURLGenerator $urlGenerator,
private INotificationManager $notificationManager,
) {
}
public function getID(): string {
return 'f7support';
}
public function getName(): string {
return $this->l10nFactory->get('f7support')->t('Support');
}
public function prepare(INotification $notification, string $languageCode): INotification {
if ($notification->getApp() !== 'f7support') {
throw new UnknownNotificationException();
}
if ($notification->getSubject() !== 'support_reply') {
throw new UnknownNotificationException();
}
$params = $notification->getSubjectParameters();
$ticketNumber = (string)($params['ticketNumber'] ?? '');
$ticketSubject = trim((string)($params['ticketSubject'] ?? ''));
$preview = trim((string)($params['preview'] ?? ''));
if ($preview === '') {
$msgParams = $notification->getMessageParameters();
$preview = trim((string)($msgParams['preview'] ?? ''));
}
if ($ticketSubject !== '') {
$title = 'Заявка ' . $ticketNumber . ': ' . $ticketSubject;
} else {
$title = 'Заявка ' . $ticketNumber;
}
if ($preview === '') {
$preview = 'Новый ответ от поддержки';
}
$icon = $this->urlGenerator->getAbsoluteURL(
$this->urlGenerator->imagePath('f7support', 'app.svg')
);
if ($this->notificationManager->isPreparingPushNotification()) {
$notification->setParsedSubject($title . "\n" . $preview);
} else {
$notification->setParsedSubject($title);
$notification->setParsedMessage($preview);
}
$notification->setIcon($icon);
return $notification;
}
}