-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue1248: Persistent Email Reminders (#1354)
### Feature or Bugfix - Feature ### Detail - When a share request is initiated and remains pending for an extended period, dataset producers will receive automated email reminders at predefined intervals. These reminders will prompt producers to either approve or extend the share request, thereby preventing delays in accessing datasets. Attaching screenshots for emails: <img width="1336" alt="Screenshot 2024-06-20 at 5 34 31 PM" src="https://github.com/data-dot-all/dataall/assets/26413731/d7be28c3-5c98-4146-92b1-295e136137a3"> <img width="1322" alt="Screenshot 2024-06-20 at 5 34 52 PM" src="https://github.com/data-dot-all/dataall/assets/26413731/047556e8-59ee-4ebf-b8a7-c0a6684e2a63"> - Email will be sent every Monday at 9am UTC. Schedule can be changed in cron expression in container.py ### Relates - #1248 ### Security Please answer the questions below briefly where applicable, or write `N/A`. Based on [OWASP 10](https://owasp.org/Top10/en/). - Does this PR introduce or modify any input fields or queries - this includes fetching data from storage outside the application (e.g. a database, an S3 bucket)? - Is the input sanitized? - What precautions are you taking before deserializing the data you consume? - Is injection prevented by parametrizing queries? - Have you ensured no `eval` or similar functions are used? - Does this PR introduce any functionality or component that requires authorization? - How have you ensured it respects the existing AuthN/AuthZ mechanisms? - Are you logging failed auth attempts? - Are you using or adding any cryptographic features? - Do you use a standard proven implementations? - Are the used keys controlled by the customer? Where are they stored? - Are you introducing any new policies/roles/users? - Have you used the least-privilege principle? How? By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license. --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Anushka Singh <anushka.singh@yahooinc.com> Co-authored-by: trajopadhye <tejas.rajopadhye@yahooinc.com> Co-authored-by: Mohit Arora <marora@yahooinc.com> Co-authored-by: rbernota <rbernota@yahooinc.com> Co-authored-by: Rick Bernotas <rbernota@verizonmedia.com> Co-authored-by: Raj Chopde <rchopde@yahooinc.com> Co-authored-by: Noah Paige <69586985+noah-paige@users.noreply.github.com> Co-authored-by: dlpzx <71252798+dlpzx@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: jaidisido <jaidisido@gmail.com> Co-authored-by: dlpzx <dlpzx@amazon.com> Co-authored-by: mourya-33 <134511711+mourya-33@users.noreply.github.com> Co-authored-by: nikpodsh <124577300+nikpodsh@users.noreply.github.com> Co-authored-by: MK <manjula_kasturi@hotmail.com> Co-authored-by: Manjula <manjula.kasturi@gmail.com> Co-authored-by: Zilvinas Saltys <zilvinas.saltys@gmail.com> Co-authored-by: Zilvinas Saltys <zilvinas.saltys@yahooinc.com> Co-authored-by: Daniel Lorch <98748454+lorchda@users.noreply.github.com> Co-authored-by: Tejas Rajopadhye <71188245+TejasRGitHub@users.noreply.github.com> Co-authored-by: Zilvinas Saltys <zilvinas.saltys@oath.com> Co-authored-by: Sofia Sazonova <sofia-s@304.ru> Co-authored-by: Sofia Sazonova <sazonova@amazon.co.uk>
- Loading branch information
1 parent
e477bdf
commit 90835fb
Showing
6 changed files
with
205 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
backend/dataall/modules/shares_base/tasks/persistent_email_reminders_task.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import logging | ||
import os | ||
import sys | ||
from dataall.modules.shares_base.db.share_object_models import ShareObject | ||
from dataall.base.db import get_engine | ||
from dataall.base.aws.sqs import SqsQueue | ||
from dataall.core.tasks.service_handlers import Worker | ||
from backend.dataall.modules.shares_base.db.share_object_repositories import ShareObjectRepository | ||
from dataall.modules.shares_base.services.share_notification_service import ShareNotificationService | ||
from dataall.modules.datasets_base.db.dataset_repositories import DatasetBaseRepository | ||
|
||
|
||
root = logging.getLogger() | ||
root.setLevel(logging.INFO) | ||
if not root.hasHandlers(): | ||
root.addHandler(logging.StreamHandler(sys.stdout)) | ||
log = logging.getLogger(__name__) | ||
|
||
|
||
def persistent_email_reminders(engine): | ||
""" | ||
A method used by the scheduled ECS Task to run persistent_email_reminder() process against ALL | ||
active share objects within data.all and send emails to all pending shares. | ||
""" | ||
with engine.scoped_session() as session: | ||
log.info('Running Persistent Email Reminders Task') | ||
pending_shares = ShareObjectRepository.fetch_submitted_shares_with_notifications(session=session) | ||
log.info(f'Found {len(pending_shares)} pending shares') | ||
pending_share: ShareObject | ||
for pending_share in pending_shares: | ||
log.info(f'Sending Email Reminder for Share: {pending_share.shareUri}') | ||
share = ShareObjectRepository.get_share_by_uri(session, pending_share.shareUri) | ||
dataset = DatasetBaseRepository.get_dataset_by_uri(session, share.datasetUri) | ||
ShareNotificationService(session=session, dataset=dataset, share=share).notify_persistent_email_reminder( | ||
email_id=share.owner | ||
) | ||
log.info(f'Email reminder sent for share {share.shareUri}') | ||
log.info('Completed Persistent Email Reminders Task') | ||
|
||
|
||
if __name__ == '__main__': | ||
ENVNAME = os.environ.get('envname', 'local') | ||
ENGINE = get_engine(envname=ENVNAME) | ||
persistent_email_reminders(engine=ENGINE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters