From cee36c2d2d56b1516de8fba2e18bc9a4a8cac1c2 Mon Sep 17 00:00:00 2001 From: jasquat <2487833+jasquat@users.noreply.github.com> Date: Tue, 4 Jun 2024 11:51:39 -0400 Subject: [PATCH] remove-email-service (#1670) * this library does not seem used so remove it and its dependency from the app * use the flask version of sentry-sdk so it can install its dependencies --------- Co-authored-by: jasquat --- spiffworkflow-backend/poetry.lock | 33 ++++++---------- spiffworkflow-backend/pyproject.toml | 3 +- .../src/spiffworkflow_backend/__init__.py | 4 -- .../services/email_service.py | 38 ------------------- 4 files changed, 13 insertions(+), 65 deletions(-) delete mode 100644 spiffworkflow-backend/src/spiffworkflow_backend/services/email_service.py diff --git a/spiffworkflow-backend/poetry.lock b/spiffworkflow-backend/poetry.lock index b2345ef5..e24c1e5c 100644 --- a/spiffworkflow-backend/poetry.lock +++ b/spiffworkflow-backend/poetry.lock @@ -229,13 +229,13 @@ files = [ [[package]] name = "blinker" -version = "1.7.0" +version = "1.8.2" description = "Fast, simple object-to-object and broadcast signaling" optional = false python-versions = ">=3.8" files = [ - {file = "blinker-1.7.0-py3-none-any.whl", hash = "sha256:c3f865d4d54db7abc53758a01601cf343fe55b84c1de4e3fa910e420b438d5b9"}, - {file = "blinker-1.7.0.tar.gz", hash = "sha256:e6820ff6fa4e4d1d8e2747c2283749c3f547e4fee112b98555cdcdae32996182"}, + {file = "blinker-1.8.2-py3-none-any.whl", hash = "sha256:1779309f71bf239144b9399d06ae925637cf6634cf6bd131104184531bf67c01"}, + {file = "blinker-1.8.2.tar.gz", hash = "sha256:8f77b09d3bf7c795e969e9486f39c2c5e9c39d4ee07424be2bc594ece9642d83"}, ] [[package]] @@ -953,20 +953,6 @@ Werkzeug = ">=0.14" [package.extras] asymmetric-crypto = ["cryptography (>=3.3.1)"] -[[package]] -name = "flask-mail" -version = "0.9.1" -description = "Flask extension for sending email" -optional = false -python-versions = "*" -files = [ - {file = "Flask-Mail-0.9.1.tar.gz", hash = "sha256:22e5eb9a940bf407bcf30410ecc3708f3c56cc44b29c34e1726fe85006935f41"}, -] - -[package.dependencies] -blinker = "*" -Flask = "*" - [[package]] name = "flask-marshmallow" version = "1.2.0" @@ -2729,17 +2715,20 @@ typing-extensions = ">=4.7.1" [[package]] name = "sentry-sdk" -version = "1.40.5" +version = "1.45.0" description = "Python client for Sentry (https://sentry.io)" optional = false python-versions = "*" files = [ - {file = "sentry-sdk-1.40.5.tar.gz", hash = "sha256:d2dca2392cc5c9a2cc9bb874dd7978ebb759682fe4fe889ee7e970ee8dd1c61e"}, - {file = "sentry_sdk-1.40.5-py2.py3-none-any.whl", hash = "sha256:d188b407c9bacbe2a50a824e1f8fb99ee1aeb309133310488c570cb6d7056643"}, + {file = "sentry-sdk-1.45.0.tar.gz", hash = "sha256:509aa9678c0512344ca886281766c2e538682f8acfa50fd8d405f8c417ad0625"}, + {file = "sentry_sdk-1.45.0-py2.py3-none-any.whl", hash = "sha256:1ce29e30240cc289a027011103a8c83885b15ef2f316a60bcc7c5300afa144f1"}, ] [package.dependencies] +blinker = {version = ">=1.1", optional = true, markers = "extra == \"flask\""} certifi = "*" +flask = {version = ">=0.11", optional = true, markers = "extra == \"flask\""} +markupsafe = {version = "*", optional = true, markers = "extra == \"flask\""} urllib3 = {version = ">=1.26.11", markers = "python_version >= \"3.6\""} [package.extras] @@ -2749,6 +2738,7 @@ asyncpg = ["asyncpg (>=0.23)"] beam = ["apache-beam (>=2.12)"] bottle = ["bottle (>=0.12.13)"] celery = ["celery (>=3)"] +celery-redbeat = ["celery-redbeat (>=2)"] chalice = ["chalice (>=1.16.0)"] clickhouse-driver = ["clickhouse-driver (>=0.2.0)"] django = ["django (>=1.8)"] @@ -2759,6 +2749,7 @@ grpcio = ["grpcio (>=1.21.1)"] httpx = ["httpx (>=0.16.0)"] huey = ["huey (>=2)"] loguru = ["loguru (>=0.5)"] +openai = ["openai (>=1.0.0)", "tiktoken (>=0.3.0)"] opentelemetry = ["opentelemetry-distro (>=0.35b0)"] opentelemetry-experimental = ["opentelemetry-distro (>=0.40b0,<1.0)", "opentelemetry-instrumentation-aiohttp-client (>=0.40b0,<1.0)", "opentelemetry-instrumentation-django (>=0.40b0,<1.0)", "opentelemetry-instrumentation-fastapi (>=0.40b0,<1.0)", "opentelemetry-instrumentation-flask (>=0.40b0,<1.0)", "opentelemetry-instrumentation-requests (>=0.40b0,<1.0)", "opentelemetry-instrumentation-sqlite3 (>=0.40b0,<1.0)", "opentelemetry-instrumentation-urllib (>=0.40b0,<1.0)"] pure-eval = ["asttokens", "executing", "pure-eval"] @@ -3474,4 +3465,4 @@ tests-strict = ["pytest (==4.6.0)", "pytest (==4.6.0)", "pytest (==6.2.5)", "pyt [metadata] lock-version = "2.0" python-versions = ">=3.10,<3.13" -content-hash = "a57ba478d94a0aab9d8d6457cdca73253c108c1340a7cf12add419bf868d579e" +content-hash = "fb41619398b5c1933459392b2ac10d6ecd10434846bc717929c803db231a0875" diff --git a/spiffworkflow-backend/pyproject.toml b/spiffworkflow-backend/pyproject.toml index 220e23e0..96e40641 100644 --- a/spiffworkflow-backend/pyproject.toml +++ b/spiffworkflow-backend/pyproject.toml @@ -22,14 +22,13 @@ flask-admin = "*" flask-bcrypt = "*" flask-cors = "*" flask-jwt-extended = "^4.4.4" -flask-mail = "*" flask-marshmallow = "*" flask-migrate = "*" flask-restful = "*" SpiffWorkflow = {git = "https://github.com/sartography/SpiffWorkflow", rev = "main"} # SpiffWorkflow = {develop = true, path = "../../spiffworkflow/" } # SpiffWorkflow = {develop = true, path = "../../SpiffWorkflow/" } -sentry-sdk = "^1.10" +sentry-sdk = {extras = ['flask'], version = "^1.10"} # sphinx-autoapi = "^2.0" psycopg2 = "^2.9.3" typing-extensions = "^4.10.0" diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/__init__.py b/spiffworkflow-backend/src/spiffworkflow_backend/__init__.py index fb8dd206..9710e220 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/__init__.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/__init__.py @@ -8,7 +8,6 @@ import flask.json import sqlalchemy from flask.json.provider import DefaultJSONProvider from flask_cors import CORS # type: ignore -from flask_mail import Mail # type: ignore import spiffworkflow_backend.load_database_models # noqa: F401 from spiffworkflow_backend.background_processing.apscheduler import start_apscheduler_if_appropriate @@ -94,9 +93,6 @@ def create_app() -> flask.app.Flask: connexion_app.add_api("api.yml", base_path=V1_API_PATH_PREFIX) - mail = Mail(app) - app.config["MAIL_APP"] = mail - app.json = MyJSONEncoder(app) configure_sentry(app) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/services/email_service.py b/spiffworkflow-backend/src/spiffworkflow_backend/services/email_service.py deleted file mode 100644 index 0d6da09e..00000000 --- a/spiffworkflow-backend/src/spiffworkflow_backend/services/email_service.py +++ /dev/null @@ -1,38 +0,0 @@ -from flask import current_app -from flask_mail import Message # type: ignore - - -class EmailService: - """Provides common interface for working with an Email.""" - - @staticmethod - def add_email( - subject: str, - sender: str, - recipients: list[str], - content: str, - content_html: str, - cc: str | None = None, - bcc: str | None = None, - reply_to: str | None = None, - attachment_files: dict | None = None, - ) -> None: - """We will receive all data related to an email and send it.""" - mail = current_app.config["MAIL_APP"] - - msg = Message( - subject, - sender=sender, - recipients=recipients, - body=content, - html=content_html, - cc=cc, - bcc=bcc, - reply_to=reply_to, - ) - - if attachment_files is not None: - for file in attachment_files: - msg.attach(file["name"], file["type"], file["data"]) - - mail.send(msg)