s365b.core.branding

Branding: product name, colours, logo and sign-in text.

Branding applies to the web UI (including the sign-in page, so it is readable without signing in), notification emails and exports. Defaults give the stock Mail Safehouse look.

Images are stored in the asset table rather than on disk, so every API replica serves the same files and the containers can keep a read-only filesystem.

Attributes

Exceptions

BrandingError

Raised for an invalid branding image.

Classes

Branding

Branding settings.

Functions

sniff_image(data) → str

Validate an uploaded image and return its content type.

save_asset(session, key, data) → s365b.db.models.Asset

Validate and store a branding image.

Module Contents

s365b.core.branding.HEX_COLOR[source]
s365b.core.branding.MAX_IMAGE_BYTES = 524288[source]
s365b.core.branding.ASSET_KEYS = ('logo', 'logo_dark', 'favicon')[source]
exception s365b.core.branding.BrandingError[source]

Bases: ValueError

Raised for an invalid branding image.

class s365b.core.branding.Branding[source]

Bases: s365b.core.settings_store.SettingsGroup

Branding settings.

Variables:
  • product_name – Name shown in the header, page titles and emails.

  • tagline – Short line under the name on the sign-in page.

  • primary_color – Main colour (buttons, links, focus), #rrggbb.

  • accent_color – Secondary colour (highlights, charts), #rrggbb.

  • default_theme – Theme for users who have not chosen one.

  • default_language – Language for users who have not chosen one: auto follows the browser. Web UI only: emails are in English.

  • login_message – Text on the sign-in page, e.g. an acceptable-use notice.

  • support_email – Contact shown in the UI footer and emails.

  • support_url – Link shown in the UI footer and emails.

  • email_footer – Plain text appended to every notification email.

key = 'branding'[source]
product_name: str[source]
tagline: str[source]
primary_color: str = '#2563eb'[source]
accent_color: str = '#0d9488'[source]
default_theme: Literal['system', 'light', 'dark'] = 'system'[source]
default_language: Literal['auto', 'en', 'es', 'fr'] = 'auto'[source]
login_message: str[source]
support_email: str[source]
support_url: pydantic.HttpUrl | None = None[source]
s365b.core.branding.sniff_image(data: bytes) → str[source]

Validate an uploaded image and return its content type.

Accepts PNG, JPEG, WebP, ICO and SVG up to 512 KiB. SVG files must not contain scripts, event handlers or external references; they are also served with a sandboxing Content-Security-Policy.

Parameters:

data – Uploaded bytes.

Returns:

The detected content type.

Raises:

BrandingError – If the file is too large, not an accepted type, or an unsafe SVG.

async s365b.core.branding.save_asset(session: sqlalchemy.ext.asyncio.AsyncSession, key: str, data: bytes) → s365b.db.models.Asset[source]

Validate and store a branding image.

Parameters:
  • session – Open session; the caller commits.

  • key – One of ASSET_KEYS.

  • data – Image bytes.

Returns:

The stored asset.

Raises:

BrandingError – If the key or image is invalid.