Skip to content

Commit

Permalink
PHRAS-4078_ExpiringRight-to-core (#4526)
Browse files Browse the repository at this point in the history
* wip do not merge

* fix event EXPORT_CREATE for basket download

* fix bad conf (not a worker)

* fix bad table name
  • Loading branch information
jygaulier authored Jul 17, 2024
1 parent 0d970a2 commit 1979ad0
Show file tree
Hide file tree
Showing 8 changed files with 1,141 additions and 1 deletion.
3 changes: 3 additions & 0 deletions bin/console
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace KonsoleKommander;
use Alchemy\Phrasea\CLI;
use Alchemy\Phrasea\Command\ApplyRightsCommand;
use Alchemy\Phrasea\Command\BuildMissingSubdefs;
use Alchemy\Phrasea\Command\ExpiringRights\AlertExpiringRightsCommand;
use Alchemy\Phrasea\Command\Record\BuildPermalinks;
use Alchemy\Phrasea\Command\Record\BuildSubdefs;
use Alchemy\Phrasea\Command\CheckConfig;
Expand Down Expand Up @@ -194,6 +195,8 @@ $cli->command(new SendValidationRemindersCommand());

$cli->command(new NetworkProxiesTestCommand('network-proxies:test'));

$cli->command(new AlertExpiringRightsCommand());

$cli->loadPlugins();

$cli->run();
39 changes: 39 additions & 0 deletions config/configuration.sample.yml
Original file line number Diff line number Diff line change
Expand Up @@ -489,3 +489,42 @@ translator:
# end of job : change coll status
set_status: 10xxxx
set_collection: online
expiring-rights:
version: 3
jobs:
# "I want to alert owners that records have expired"
- rights-expired-owners:
active: false
target: "owners"
databox: "db_with_rights"
collection: [ "Promo", "Selections" ]
expire_field: ExpireDate
prior_notice: -60
set_status: 01xxxx
alerts:
- method: webhook
recipient: ["[email protected]", "[email protected]"]

# "I want to alert users who have downloaded that a document rights will expire in 60 days"
- rights-60-downloaders:
active: false
target: "downloaders"
databox: "db_with_rights"
collection: [ "Promo", "Selections" ]
downloaded: [ "document", "preview" ]
expire_field: "ExpirationDate"
prior_notice: -60
alerts:
- method: "webhook"

# "I want to alert users who have downloaded that a document rights has expired"
- rights-expired-dowloaders:
active: false
target: "downloaders"
databox: "db_with_rights"
collection: [ "Promo", "Selections" ]
downloaded: [ "document", "preview" ]
expire_field: "ExpirationDate"
prior_notice: 0
alerts:
- method: "webhook"
4 changes: 4 additions & 0 deletions lib/Alchemy/Phrasea/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@
use Alchemy\Phrasea\Authorization\AuthorizationServiceProvider;
use Alchemy\Phrasea\Core\Event\Subscriber\BasketSubscriber;
use Alchemy\Phrasea\Core\Event\Subscriber\BridgeSubscriber;
use Alchemy\Phrasea\Core\Event\Subscriber\ExpiringRightsSubscriber;
use Alchemy\Phrasea\Core\Event\Subscriber\ExportSubscriber;
use Alchemy\Phrasea\Core\Event\Subscriber\FeedEntrySubscriber;
use Alchemy\Phrasea\Core\Event\Subscriber\LazaretSubscriber;
use Alchemy\Phrasea\Core\Event\Subscriber\PhraseaInstallSubscriber;
use Alchemy\Phrasea\Core\Event\Subscriber\RegistrationSubscriber;
use Alchemy\Phrasea\Core\Event\Subscriber\ValidationSubscriber;
use Alchemy\Phrasea\Core\Event\Subscriber\WebhookUserEventSubscriber;
use Alchemy\Phrasea\Core\LazyLocator;
use Alchemy\Phrasea\Core\MetaProvider\DatabaseMetaProvider;
use Alchemy\Phrasea\Core\MetaProvider\HttpStackMetaProvider;
use Alchemy\Phrasea\Core\MetaProvider\MediaUtilitiesMetaServiceProvider;
Expand Down Expand Up @@ -767,6 +769,8 @@ private function setupEventDispatcher()
$dispatcher->addSubscriber(new WebhookUserEventSubscriber($app));
}

$dispatcher->addSubscriber(new ExpiringRightsSubscriber($app, new LazyLocator($app, 'phraseanet.appbox')));

return $dispatcher;
})
);
Expand Down
Loading

0 comments on commit 1979ad0

Please sign in to comment.