Skip to content

Commit b3fb639

Browse files
authored
🎨 New PO email per product to use in account requests πŸ—ƒοΈπŸš¨ (#7131)
1 parent b3641d9 commit b3fb639

File tree

7 files changed

+60
-12
lines changed

7 files changed

+60
-12
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
"""Add product owners email col
2+
3+
Revision ID: 1bc517536e0a
4+
Revises: 5f88b513cd4c
5+
Create Date: 2025-01-29 10:05:58.254306+00:00
6+
7+
"""
8+
import sqlalchemy as sa
9+
from alembic import op
10+
11+
# revision identifiers, used by Alembic.
12+
revision = "1bc517536e0a"
13+
down_revision = "5f88b513cd4c"
14+
branch_labels = None
15+
depends_on = None
16+
17+
18+
def upgrade():
19+
# ### commands auto generated by Alembic - please adjust! ###
20+
op.add_column(
21+
"products", sa.Column("product_owners_email", sa.String(), nullable=True)
22+
)
23+
# ### end Alembic commands ###
24+
25+
26+
def downgrade():
27+
# ### commands auto generated by Alembic - please adjust! ###
28+
op.drop_column("products", "product_owners_email")
29+
# ### end Alembic commands ###

β€Žpackages/postgres-database/src/simcore_postgres_database/models/products.pyβ€Ž

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,12 @@ class ProductLoginSettingsDict(TypedDict, total=False):
154154
doc="Support email for this product"
155155
'Therefore smtp_sender = f"{display_name} support <{support_email}>"',
156156
),
157+
sa.Column(
158+
"product_owners_email",
159+
sa.String,
160+
nullable=True,
161+
doc="Alternative support email directed to POs only (e.g. for account request, sales, etc)",
162+
),
157163
sa.Column(
158164
"twilio_messaging_sid",
159165
sa.String,

β€Žpackages/pytest-simcore/src/pytest_simcore/helpers/faker_factories.pyβ€Ž

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,12 @@ def random_product(
227227
"short_name": suffix[:4],
228228
"host_regex": r"[a-zA-Z0-9]+\.com",
229229
"support_email": f"support@{suffix}.io",
230-
"twilio_messaging_sid": fake.random_element(elements=(None, fake.uuid4()[:34])),
230+
"product_owners_email": fake.random_element(
231+
elements=[f"product-onwers@{suffix}.io", None]
232+
),
233+
"twilio_messaging_sid": fake.random_element(
234+
elements=(None, f"{fake.uuid4()}"[:34])
235+
),
231236
"vendor": Vendor(
232237
name=fake.company(),
233238
copyright=fake.company_suffix(),

β€Žservices/web/server/src/simcore_service_webserver/login/_registration_api.pyβ€Ž

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ async def send_account_request_email_to_support(
6363
ipinfo: dict,
6464
):
6565
template_name = "request_account.jinja2"
66-
support_email = product.support_email
66+
destination_email = product.product_owners_email or product.support_email
6767
email_template_path = await get_product_template_path(request, template_name)
6868
try:
6969
user_email = TypeAdapter(LowerCaseEmailStr).validate_python(
@@ -75,13 +75,13 @@ async def send_account_request_email_to_support(
7575
try:
7676
await send_email_from_template(
7777
request,
78-
from_=support_email,
79-
to=support_email,
78+
from_=product.support_email,
79+
to=destination_email,
8080
reply_to=user_email, # So that issue-tracker system ACK email is sent to the user that requests the account
8181
template=email_template_path,
8282
context={
8383
"host": request.host,
84-
"name": "support-team",
84+
"name": "product-owners",
8585
"product": product.model_dump(
8686
include={
8787
"name",
@@ -99,7 +99,7 @@ async def send_account_request_email_to_support(
9999
_logger.exception(
100100
"Failed while sending '%s' email to %s",
101101
template_name,
102-
f"{support_email=}",
102+
f"{destination_email=}",
103103
)
104104

105105

β€Žservices/web/server/src/simcore_service_webserver/products/_db.pyβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
products.c.short_name,
3333
products.c.host_regex,
3434
products.c.support_email,
35+
products.c.product_owners_email,
3536
products.c.twilio_messaging_sid,
3637
products.c.vendor,
3738
products.c.issues,

β€Žservices/web/server/src/simcore_service_webserver/products/_model.pyβ€Ž

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,18 @@ class Product(BaseModel):
6363
..., description="Host regex"
6464
)
6565

66-
support_email: LowerCaseEmailStr = Field(
67-
...,
68-
description="Main support email."
69-
" Other support emails can be defined under 'support' field",
70-
)
66+
support_email: Annotated[
67+
LowerCaseEmailStr,
68+
Field(
69+
description="Main support email."
70+
" Other support emails can be defined under 'support' field",
71+
),
72+
]
73+
74+
product_owners_email: Annotated[
75+
LowerCaseEmailStr | None,
76+
Field(description="Used e.g. for account requests forms"),
77+
] = None
7178

7279
twilio_messaging_sid: str | None = Field(
7380
default=None, min_length=34, max_length=34, description="Identifier for SMS"

β€Žservices/web/server/tests/unit/with_dbs/03/login/test_login_registration_handlers.pyβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,4 +208,4 @@ async def test_request_an_account(
208208
mimetext = mocked_send_email.call_args[1]["message"]
209209
assert "account" in mimetext["Subject"].lower()
210210
assert mimetext["From"] == product.support_email
211-
assert mimetext["To"] == product.support_email
211+
assert mimetext["To"] == product.product_owners_email or product.support_email

0 commit comments

Comments
Β (0)