Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"""Add product owners email col

Revision ID: 1bc517536e0a
Revises: 5f88b513cd4c
Create Date: 2025-01-29 10:05:58.254306+00:00

"""
import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision = "1bc517536e0a"
down_revision = "5f88b513cd4c"
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column(
"products", sa.Column("product_owners_email", sa.String(), nullable=True)
)
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column("products", "product_owners_email")
# ### end Alembic commands ###
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,12 @@ class ProductLoginSettingsDict(TypedDict, total=False):
doc="Support email for this product"
'Therefore smtp_sender = f"{display_name} support <{support_email}>"',
),
sa.Column(
"product_owners_email",
sa.String,
nullable=True,
doc="Alternative support email directed to POs only (e.g. for account request, sales, etc)",
),
sa.Column(
"twilio_messaging_sid",
sa.String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,12 @@ def random_product(
"short_name": suffix[:4],
"host_regex": r"[a-zA-Z0-9]+\.com",
"support_email": f"support@{suffix}.io",
"twilio_messaging_sid": fake.random_element(elements=(None, fake.uuid4()[:34])),
"product_owners_email": fake.random_element(
elements=[f"product-onwers@{suffix}.io", None]
),
"twilio_messaging_sid": fake.random_element(
elements=(None, f"{fake.uuid4()}"[:34])
),
"vendor": Vendor(
name=fake.company(),
copyright=fake.company_suffix(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ async def send_account_request_email_to_support(
ipinfo: dict,
):
template_name = "request_account.jinja2"
support_email = product.support_email
destination_email = product.product_owners_email or product.support_email
email_template_path = await get_product_template_path(request, template_name)
try:
user_email = TypeAdapter(LowerCaseEmailStr).validate_python(
Expand All @@ -75,13 +75,13 @@ async def send_account_request_email_to_support(
try:
await send_email_from_template(
request,
from_=support_email,
to=support_email,
from_=product.support_email,
to=destination_email,
reply_to=user_email, # So that issue-tracker system ACK email is sent to the user that requests the account
template=email_template_path,
context={
"host": request.host,
"name": "support-team",
"name": "product-owners",
"product": product.model_dump(
include={
"name",
Expand All @@ -99,7 +99,7 @@ async def send_account_request_email_to_support(
_logger.exception(
"Failed while sending '%s' email to %s",
template_name,
f"{support_email=}",
f"{destination_email=}",
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
products.c.short_name,
products.c.host_regex,
products.c.support_email,
products.c.product_owners_email,
products.c.twilio_messaging_sid,
products.c.vendor,
products.c.issues,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,18 @@ class Product(BaseModel):
..., description="Host regex"
)

support_email: LowerCaseEmailStr = Field(
...,
description="Main support email."
" Other support emails can be defined under 'support' field",
)
support_email: Annotated[
LowerCaseEmailStr,
Field(
description="Main support email."
" Other support emails can be defined under 'support' field",
),
]

product_owners_email: Annotated[
LowerCaseEmailStr | None,
Field(description="Used e.g. for account requests forms"),
] = None

twilio_messaging_sid: str | None = Field(
default=None, min_length=34, max_length=34, description="Identifier for SMS"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,4 @@ async def test_request_an_account(
mimetext = mocked_send_email.call_args[1]["message"]
assert "account" in mimetext["Subject"].lower()
assert mimetext["From"] == product.support_email
assert mimetext["To"] == product.support_email
assert mimetext["To"] == product.product_owners_email or product.support_email
Loading