Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
117 commits
Select commit Hold shift + click to select a range
83093c2
feat(app): register workflow bootstrap services
vitormattos Mar 17, 2026
3212c5b
feat(service): dispatch profile field workflow events
vitormattos Mar 17, 2026
656d17b
test(app): cover workflow bootstrap registration
vitormattos Mar 17, 2026
ee81aba
test(service): cover workflow event dispatching
vitormattos Mar 17, 2026
d7e6b63
build(vite): add workflow entrypoint
vitormattos Mar 17, 2026
759e416
feat(listener): load workflow settings assets
vitormattos Mar 17, 2026
d5debd6
feat(listener): register workflow checks
vitormattos Mar 17, 2026
833d34e
feat(listener): register workflow entities
vitormattos Mar 17, 2026
a831fa7
feat(listener): register workflow operations
vitormattos Mar 17, 2026
c8cf067
feat(notification): add workflow notifier
vitormattos Mar 17, 2026
59484ae
feat(workflow): add abstract profile field event
vitormattos Mar 17, 2026
1e7093e
feat(workflow): add profile field created event
vitormattos Mar 17, 2026
67c3a5e
feat(workflow): add profile field updated event
vitormattos Mar 17, 2026
d69882e
feat(workflow): add profile field visibility event
vitormattos Mar 17, 2026
b38e4a6
feat(workflow): add log profile field operation
vitormattos Mar 17, 2026
cf0695d
feat(workflow): add notify user operation
vitormattos Mar 17, 2026
a42e54b
feat(workflow): add profile field workflow entity
vitormattos Mar 17, 2026
6dbc76b
feat(workflow): add profile field subject context
vitormattos Mar 17, 2026
2350028
feat(workflow): add profile field workflow subject
vitormattos Mar 17, 2026
9e09084
feat(workflow): add profile field check
vitormattos Mar 17, 2026
0a18c94
test(e2e): cover workflow notify action
vitormattos Mar 17, 2026
c2fb5f8
test(frontend): cover workflow check utilities
vitormattos Mar 17, 2026
d347332
feat(frontend): add workflow check utilities
vitormattos Mar 17, 2026
871355b
feat(frontend): integrate workflow actions
vitormattos Mar 17, 2026
cd5103a
test(workflow): cover log operation integration
vitormattos Mar 17, 2026
a53052a
test(workflow): cover profile field check integration
vitormattos Mar 17, 2026
8b3b5f6
test(notification): cover workflow notifier
vitormattos Mar 17, 2026
538eeef
test(workflow): cover log operation unit
vitormattos Mar 17, 2026
c9eeb1d
test(workflow): cover notify operation unit
vitormattos Mar 17, 2026
b7981f4
test(workflow): cover profile field check unit
vitormattos Mar 17, 2026
14a2126
feat(workflow): add send webhook operation
vitormattos Mar 17, 2026
a178888
feat(listener): register webhook workflow operation
vitormattos Mar 17, 2026
60ac7d3
feat(frontend): add webhook workflow operation input
vitormattos Mar 17, 2026
9daa6a8
test(workflow): cover send webhook operation unit
vitormattos Mar 17, 2026
9e6f8c8
test(e2e): cover webhook workflow action
vitormattos Mar 17, 2026
4e49b20
chore(app): sort workflow event imports
vitormattos Mar 17, 2026
4f328c5
feat(listener): register email workflow operation
vitormattos Mar 17, 2026
77dfb73
chore(notification): sort notifier imports
vitormattos Mar 17, 2026
65d4daf
feat(workflow): differentiate log action icon
vitormattos Mar 17, 2026
c7733f0
feat(workflow): differentiate notify action icon
vitormattos Mar 17, 2026
4799d22
chore(workflow): remove entity unused imports
vitormattos Mar 17, 2026
4c75edc
chore(workflow): remove check unused import
vitormattos Mar 17, 2026
fa98d21
test(e2e): cover email workflow action
vitormattos Mar 17, 2026
847629c
feat(frontend): expose email workflow action
vitormattos Mar 17, 2026
2542145
chore(test): sort notifier test imports
vitormattos Mar 17, 2026
0fbe7ec
test(workflow): cover log action icon
vitormattos Mar 17, 2026
9df7008
test(workflow): cover notify action icon
vitormattos Mar 17, 2026
24cb44c
feat(workflow): add email user operation
vitormattos Mar 17, 2026
8fdc600
test(workflow): cover email user operation
vitormattos Mar 17, 2026
2919713
chore(workflow): normalize email operation newline
vitormattos Mar 17, 2026
2414a75
chore(test): sort email operation imports
vitormattos Mar 17, 2026
a4be156
feat(workflow): add activity workflow operation
vitormattos Mar 17, 2026
7d42934
test(workflow): cover activity workflow operation
vitormattos Mar 17, 2026
973bd21
feat(workflow): add admin target workflow operation
vitormattos Mar 17, 2026
c49aaf7
test(workflow): cover admin target workflow operation
vitormattos Mar 17, 2026
f7f43bf
feat(workflow): add talk workflow operation
vitormattos Mar 17, 2026
d1a56ac
test(workflow): cover talk workflow operation
vitormattos Mar 17, 2026
31d139f
feat(workflow): template email workflow operation
vitormattos Mar 17, 2026
fcb28c6
test(workflow): cover email workflow templates
vitormattos Mar 17, 2026
4ca4d67
feat(workflow): harden webhook workflow operation
vitormattos Mar 17, 2026
c8d2090
test(workflow): cover webhook workflow config
vitormattos Mar 17, 2026
1d32260
feat(listener): register expanded workflow operations
vitormattos Mar 17, 2026
1629e25
feat(frontend): expose expanded workflow actions
vitormattos Mar 17, 2026
e35a95c
test(e2e): cover expanded workflow actions
vitormattos Mar 17, 2026
2b7be15
feat(workflow): add targets select component
vitormattos Mar 17, 2026
a0560b9
feat(workflow): refactor workflow targets handling
vitormattos Mar 17, 2026
ac6c437
feat(api): add workflow principal search support
vitormattos Mar 17, 2026
4eec5e5
fix(workflow): load workflow settings styles
vitormattos Mar 17, 2026
3716247
refactor(app): remove legacy workflow notifier wiring
vitormattos Mar 17, 2026
4ba270b
refactor(workflow): remove legacy operation registrations
vitormattos Mar 17, 2026
7f4976e
refactor(notification): remove legacy workflow notifier
vitormattos Mar 17, 2026
79d4087
refactor(workflow): remove activity change operation
vitormattos Mar 17, 2026
d2b1996
refactor(workflow): remove notify user operation
vitormattos Mar 17, 2026
abe8dac
test(workflow): align e2e coverage with new targets flow
vitormattos Mar 17, 2026
e9ce288
test(app): remove legacy notifier assertions
vitormattos Mar 17, 2026
0ee392a
test(notification): remove legacy notifier test
vitormattos Mar 17, 2026
79e62f5
test(workflow): remove activity operation test
vitormattos Mar 17, 2026
e117881
test(workflow): remove notify user operation test
vitormattos Mar 17, 2026
d9166ec
feat(playwright): harden screenshot generation flow
vitormattos Mar 17, 2026
1e66388
test(playwright): add pedro poti avatar fixture
vitormattos Mar 17, 2026
ff174f5
docs(screenshots): refresh admin catalog thumbnail
vitormattos Mar 17, 2026
a4fcc9f
docs(screenshots): refresh personal settings thumbnail
vitormattos Mar 17, 2026
fd0a526
docs(screenshots): refresh personal settings capture
vitormattos Mar 17, 2026
59d53eb
docs(screenshots): refresh user management thumbnail
vitormattos Mar 17, 2026
0b82846
docs(screenshots): refresh user management capture
vitormattos Mar 17, 2026
837aeeb
docs(screenshots): add workflow thumbnail
vitormattos Mar 17, 2026
048e18a
docs(screenshots): add workflow capture
vitormattos Mar 17, 2026
2973790
docs(appinfo): update screenshot gallery metadata
vitormattos Mar 17, 2026
48541f5
docs(readme): add screenshot section subtitles
vitormattos Mar 17, 2026
a09089f
chore: annotate playwright fixture licensing
vitormattos Mar 17, 2026
03b9aa4
feat: add profile fields notifier
vitormattos Mar 17, 2026
3446389
feat: register profile fields notifier
vitormattos Mar 17, 2026
404f8fd
test: reset workflow and notification fixtures
vitormattos Mar 17, 2026
8527914
fix: store workflow notification message keys
vitormattos Mar 17, 2026
5b2cf92
test: cover workflow notification payloads
vitormattos Mar 17, 2026
7ae7c76
test: reuse package feature context
vitormattos Mar 17, 2026
74fb5c7
test: drop duplicate behat context
vitormattos Mar 17, 2026
4e48c4c
test: cover workflow notifications end to end
vitormattos Mar 17, 2026
d713906
chore: bump nextcloud-behat integration lock
vitormattos Mar 17, 2026
75e7996
ci: install behat workflow app dependencies
vitormattos Mar 17, 2026
723b310
test: move workflow coverage out of api feature
vitormattos Mar 17, 2026
e098edf
test: add workflow integration scenarios
vitormattos Mar 17, 2026
06ab748
ci: stop forcing workflowengine enable
vitormattos Mar 17, 2026
c342501
test: normalize workflow feature file ending
vitormattos Mar 17, 2026
f99201d
ci(behat): add mailpit and sockets support
vitormattos Mar 17, 2026
4beb926
feat(tests): add integration behat dependencies
vitormattos Mar 17, 2026
d2ccd52
chore(tests): refresh integration lockfile
vitormattos Mar 17, 2026
0ed4400
feat(tests): rewire behat contexts
vitormattos Mar 17, 2026
8d424a9
refactor(tests): remove legacy feature context
vitormattos Mar 17, 2026
f067f62
feat(tests): add mock web server behat context
vitormattos Mar 17, 2026
12d2933
fix(workflow): translate talk conversation title safely
vitormattos Mar 17, 2026
9b05647
test(integration): cover workflow webhook email and talk flows
vitormattos Mar 17, 2026
a336e81
ci(behat): clone bundled apps from default branch
vitormattos Mar 17, 2026
882fd8a
test(workflow): align talk conversation assertion
vitormattos Mar 17, 2026
1212b2f
test(behat): add stable nextcloud log reader step
vitormattos Mar 17, 2026
84c01ee
test(workflow): harden integration feature setup
vitormattos Mar 17, 2026
f144217
test(api): reset profile field fixtures per scenario
vitormattos Mar 17, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion .github/workflows/behat-sqlite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ jobs:
env:
APP_NAME: profile_fields

services:
mailpit:
image: axllent/mailpit:v1.27
ports:
- 1025:1025
- 8025:8025

name: SQLite PHP 8.2 Nextcloud master

steps:
Expand All @@ -71,7 +78,7 @@ jobs:
uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # v2.37.0
with:
php-version: '8.2'
extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, session, simplexml, sqlite, pdo_sqlite, xmlreader, xmlwriter, zip, zlib
extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, session, simplexml, sockets, sqlite, pdo_sqlite, xmlreader, xmlwriter, zip, zlib
coverage: none
ini-file: development
ini-values: disable_functions=
Expand All @@ -85,6 +92,7 @@ jobs:

- name: Set up Nextcloud
run: |
echo "127.0.0.1 mailpit" | sudo tee -a /etc/hosts
mkdir data
./occ maintenance:install \
--verbose \
Expand All @@ -93,6 +101,12 @@ jobs:
--admin-user admin \
--admin-pass admin
./occ app:enable --force ${{ env.APP_NAME }}
git clone --depth 1 https://github.com/nextcloud/notifications apps/notifications
composer --working-dir=apps/notifications install --no-dev
./occ app:enable --force notifications
git clone --depth 1 https://github.com/nextcloud/spreed apps/spreed
composer --working-dir=apps/spreed install --no-dev
./occ app:enable --force spreed
./occ config:system:set auth.bruteforce.protection.enabled --value false --type boolean
./occ config:system:set ratelimit.protection.enabled --value false --type boolean
./occ config:system:set debug --value true --type boolean
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,14 @@ Notes:

## Screenshots

### Admin catalog
![Admin catalog](img/screenshots/admin-catalog.png)

### User management dialog
![User management dialog](img/screenshots/user-management-dialog.png)

### Personal settings
![Personal settings](img/screenshots/personal-settings.png)

### Workflow automation
![Workflow automation](img/screenshots/workflow-notify-admins.png)
1 change: 1 addition & 0 deletions REUSE.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ path = [
"openapi.json",
"package-lock.json",
"package.json",
"playwright/fixtures/*.png",
"psalm.xml",
"src/types/openapi/*.ts",
"tests/integration/composer.json",
Expand Down
3 changes: 2 additions & 1 deletion appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ Developed with ❤️ by [LibreCode](https://librecode.coop). Help us transform
<bugs>https://github.com/LibreCodeCoop/profile_fields/issues</bugs>
<repository type="git">https://github.com/LibreCodeCoop/profile_fields</repository>
<screenshot small-thumbnail="https://raw.githubusercontent.com/LibreCodeCoop/profile_fields/main/img/screenshots/admin-catalog-thumb.png">https://raw.githubusercontent.com/LibreCodeCoop/profile_fields/main/img/screenshots/admin-catalog.png</screenshot>
<screenshot small-thumbnail="https://raw.githubusercontent.com/LibreCodeCoop/profile_fields/main/img/screenshots/personal-settings-thumb.png">https://raw.githubusercontent.com/LibreCodeCoop/profile_fields/main/img/screenshots/personal-settings.png</screenshot>
<screenshot small-thumbnail="https://raw.githubusercontent.com/LibreCodeCoop/profile_fields/main/img/screenshots/user-management-dialog-thumb.png">https://raw.githubusercontent.com/LibreCodeCoop/profile_fields/main/img/screenshots/user-management-dialog.png</screenshot>
<screenshot small-thumbnail="https://raw.githubusercontent.com/LibreCodeCoop/profile_fields/main/img/screenshots/personal-settings-thumb.png">https://raw.githubusercontent.com/LibreCodeCoop/profile_fields/main/img/screenshots/personal-settings.png</screenshot>
<screenshot small-thumbnail="https://raw.githubusercontent.com/LibreCodeCoop/profile_fields/main/img/screenshots/workflow-notify-admins-thumb.png">https://raw.githubusercontent.com/LibreCodeCoop/profile_fields/main/img/screenshots/workflow-notify-admins.png</screenshot>
<donation title="Donate via GitHub Sponsors">https://github.com/sponsors/LibreSign</donation>
<dependencies>
<nextcloud min-version="32" max-version="34"/>
Expand Down
Binary file modified img/screenshots/admin-catalog-thumb.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/screenshots/personal-settings-thumb.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/screenshots/personal-settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/screenshots/user-management-dialog-thumb.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/screenshots/user-management-dialog.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/screenshots/workflow-notify-admins-thumb.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/screenshots/workflow-notify-admins.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,23 @@
namespace OCA\ProfileFields\AppInfo;

use OCA\ProfileFields\Listener\BeforeTemplateRenderedListener;
use OCA\ProfileFields\Listener\LoadWorkflowSettingsScriptsListener;
use OCA\ProfileFields\Listener\RegisterWorkflowCheckListener;
use OCA\ProfileFields\Listener\RegisterWorkflowEntityListener;
use OCA\ProfileFields\Listener\RegisterWorkflowOperationListener;
use OCA\ProfileFields\Listener\UserDeletedCleanupListener;
use OCA\ProfileFields\Notification\Notifier;
use OCP\AppFramework\App;
use OCP\AppFramework\Bootstrap\IBootContext;
use OCP\AppFramework\Bootstrap\IBootstrap;
use OCP\AppFramework\Bootstrap\IRegistrationContext;
use OCP\IRequest;
use OCP\User\Events\UserDeletedEvent;
use OCP\Util;
use OCP\WorkflowEngine\Events\LoadSettingsScriptsEvent;
use OCP\WorkflowEngine\Events\RegisterChecksEvent;
use OCP\WorkflowEngine\Events\RegisterEntitiesEvent;
use OCP\WorkflowEngine\Events\RegisterOperationsEvent;

/**
* @codeCoverageIgnore
Expand All @@ -32,8 +41,13 @@ public function __construct() {

#[\Override]
public function register(IRegistrationContext $context): void {
$context->registerNotifierService(Notifier::class);
$context->registerEventListener('\\OCA\\Settings\\Events\\BeforeTemplateRenderedEvent', BeforeTemplateRenderedListener::class);
$context->registerEventListener(UserDeletedEvent::class, UserDeletedCleanupListener::class);
$context->registerEventListener(RegisterEntitiesEvent::class, RegisterWorkflowEntityListener::class);
$context->registerEventListener(RegisterOperationsEvent::class, RegisterWorkflowOperationListener::class);
$context->registerEventListener(RegisterChecksEvent::class, RegisterWorkflowCheckListener::class);
$context->registerEventListener(LoadSettingsScriptsEvent::class, LoadWorkflowSettingsScriptsListener::class);
}

#[\Override]
Expand Down
20 changes: 20 additions & 0 deletions lib/Command/Developer/Reset.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

namespace OCA\ProfileFields\Command\Developer;

use OCA\ProfileFields\AppInfo\Application;
use OCP\IDBConnection;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
Expand Down Expand Up @@ -65,12 +66,31 @@ protected function execute(InputInterface $input, OutputInterface $output): int

if ($resetDefinitions) {
$this->deleteTable('profile_fields_definitions');
$this->deleteWorkflowTables();
$this->deleteProfileFieldNotifications();
}

$output->writeln('<info>Profile Fields data reset complete.</info>');
return self::SUCCESS;
}

private function deleteWorkflowTables(): void {
foreach (['flow_checks', 'flow_operations', 'flow_operations_scope'] as $tableName) {
$this->deleteTable($tableName);
}
}

private function deleteProfileFieldNotifications(): void {
if (!$this->connection->tableExists('notifications')) {
return;
}

$query = $this->connection->getQueryBuilder();
$query->delete('notifications')
->where($query->expr()->eq('app', $query->createNamedParameter(Application::APP_ID)))
->executeStatement();
}

private function deleteTable(string $tableName): void {
if (!$this->connection->tableExists($tableName)) {
return;
Expand Down
31 changes: 31 additions & 0 deletions lib/Listener/LoadWorkflowSettingsScriptsListener.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

/**
* SPDX-FileCopyrightText: 2026 LibreCode coop and LibreCode contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

declare(strict_types=1);

namespace OCA\ProfileFields\Listener;

use OCA\ProfileFields\AppInfo\Application;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use OCP\Util;
use OCP\WorkflowEngine\Events\LoadSettingsScriptsEvent;

/**
* @template-implements IEventListener<LoadSettingsScriptsEvent>
*/
class LoadWorkflowSettingsScriptsListener implements IEventListener {
#[\Override]
public function handle(Event $event): void {
if (!$event instanceof LoadSettingsScriptsEvent) {
return;
}

Util::addStyle(Application::APP_ID, 'profile_fields-workflow');
Util::addScript(Application::APP_ID, 'profile_fields-workflow', 'workflowengine');
}
}
34 changes: 34 additions & 0 deletions lib/Listener/RegisterWorkflowCheckListener.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

/**
* SPDX-FileCopyrightText: 2026 LibreCode coop and LibreCode contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

declare(strict_types=1);

namespace OCA\ProfileFields\Listener;

use OCA\ProfileFields\Workflow\UserProfileFieldCheck;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use OCP\WorkflowEngine\Events\RegisterChecksEvent;

/**
* @template-implements IEventListener<RegisterChecksEvent>
*/
class RegisterWorkflowCheckListener implements IEventListener {
public function __construct(
private UserProfileFieldCheck $check,
) {
}

#[\Override]
public function handle(Event $event): void {
if (!$event instanceof RegisterChecksEvent) {
return;
}

$event->registerCheck($this->check);
}
}
34 changes: 34 additions & 0 deletions lib/Listener/RegisterWorkflowEntityListener.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

/**
* SPDX-FileCopyrightText: 2026 LibreCode coop and LibreCode contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

declare(strict_types=1);

namespace OCA\ProfileFields\Listener;

use OCA\ProfileFields\Workflow\ProfileFieldValueEntity;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use OCP\WorkflowEngine\Events\RegisterEntitiesEvent;

/**
* @template-implements IEventListener<RegisterEntitiesEvent>
*/
class RegisterWorkflowEntityListener implements IEventListener {
public function __construct(
private ProfileFieldValueEntity $entity,
) {
}

#[\Override]
public function handle(Event $event): void {
if (!$event instanceof RegisterEntitiesEvent) {
return;
}

$event->registerEntity($this->entity);
}
}
46 changes: 46 additions & 0 deletions lib/Listener/RegisterWorkflowOperationListener.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

/**
* SPDX-FileCopyrightText: 2026 LibreCode coop and LibreCode contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

declare(strict_types=1);

namespace OCA\ProfileFields\Listener;

use OCA\ProfileFields\Workflow\CreateTalkConversationProfileFieldChangeOperation;
use OCA\ProfileFields\Workflow\EmailUserProfileFieldChangeOperation;
use OCA\ProfileFields\Workflow\LogProfileFieldChangeOperation;
use OCA\ProfileFields\Workflow\NotifyAdminsOrGroupsProfileFieldChangeOperation;
use OCA\ProfileFields\Workflow\SendWebhookProfileFieldChangeOperation;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use OCP\WorkflowEngine\Events\RegisterOperationsEvent;

/**
* @template-implements IEventListener<RegisterOperationsEvent>
*/
class RegisterWorkflowOperationListener implements IEventListener {
public function __construct(
private LogProfileFieldChangeOperation $operation,
private EmailUserProfileFieldChangeOperation $emailUserOperation,
private NotifyAdminsOrGroupsProfileFieldChangeOperation $notifyAdminsOrGroupsOperation,
private CreateTalkConversationProfileFieldChangeOperation $createTalkConversationOperation,
private SendWebhookProfileFieldChangeOperation $sendWebhookOperation,
) {
}

#[\Override]
public function handle(Event $event): void {
if (!$event instanceof RegisterOperationsEvent) {
return;
}

$event->registerOperation($this->operation);
$event->registerOperation($this->emailUserOperation);
$event->registerOperation($this->notifyAdminsOrGroupsOperation);
$event->registerOperation($this->createTalkConversationOperation);
$event->registerOperation($this->sendWebhookOperation);
}
}
65 changes: 65 additions & 0 deletions lib/Notification/Notifier.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php

/**
* SPDX-FileCopyrightText: 2026 LibreCode coop and LibreCode contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

declare(strict_types=1);

namespace OCA\ProfileFields\Notification;

use OCA\ProfileFields\AppInfo\Application;
use OCP\IURLGenerator;
use OCP\L10N\IFactory;
use OCP\Notification\INotification;
use OCP\Notification\INotifier;
use OCP\Notification\UnknownNotificationException;

class Notifier implements INotifier {
public function __construct(
private IFactory $factory,
private IURLGenerator $urlGenerator,
) {
}

#[\Override]
public function getID(): string {
return Application::APP_ID;
}

#[\Override]
public function getName(): string {
return $this->factory->get(Application::APP_ID)->t('Profile fields');
}

#[\Override]
public function prepare(INotification $notification, string $languageCode): INotification {
if ($notification->getApp() !== Application::APP_ID) {
throw new UnknownNotificationException();
}

$l10n = $this->factory->get(Application::APP_ID, $languageCode);

if ($notification->getSubject() === 'profile_field_updated') {
$notification->setParsedSubject($l10n->t('Profile field updated'));
} elseif ($notification->getParsedSubject() === '') {
$notification->setParsedSubject($notification->getSubject());
}

if ($notification->getMessage() === 'profile_field_updated_message') {
$notification->setParsedMessage($l10n->t(
'%1$s changed %2$s\'s %3$s profile field.',
$notification->getMessageParameters(),
));
} elseif ($notification->getMessage() !== '' && $notification->getParsedMessage() === '') {
$notification->setParsedMessage($notification->getMessage());
}

if ($notification->getIcon() === '') {
$notification->setIcon($this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath(Application::APP_ID, 'app.svg')));
}

return $notification;
}
}
Loading
Loading