s365b.core.branding =================== .. py:module:: s365b.core.branding .. autoapi-nested-parse:: 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 ---------- .. autoapisummary:: s365b.core.branding.HEX_COLOR s365b.core.branding.MAX_IMAGE_BYTES s365b.core.branding.ASSET_KEYS Exceptions ---------- .. autoapisummary:: s365b.core.branding.BrandingError Classes ------- .. autoapisummary:: s365b.core.branding.Branding Functions --------- .. autoapisummary:: s365b.core.branding.sniff_image s365b.core.branding.save_asset Module Contents --------------- .. py:data:: HEX_COLOR .. py:data:: MAX_IMAGE_BYTES :value: 524288 .. py:data:: ASSET_KEYS :value: ('logo', 'logo_dark', 'favicon') .. py:exception:: BrandingError Bases: :py:obj:`ValueError` Raised for an invalid branding image. .. py:class:: Branding Bases: :py:obj:`s365b.core.settings_store.SettingsGroup` Branding settings. :ivar product_name: Name shown in the header, page titles and emails. :ivar tagline: Short line under the name on the sign-in page. :ivar primary_color: Main colour (buttons, links, focus), ``#rrggbb``. :ivar accent_color: Secondary colour (highlights, charts), ``#rrggbb``. :ivar default_theme: Theme for users who have not chosen one. :ivar default_language: Language for users who have not chosen one: ``auto`` follows the browser. Web UI only: emails are in English. :ivar login_message: Text on the sign-in page, e.g. an acceptable-use notice. :ivar support_email: Contact shown in the UI footer and emails. :ivar support_url: Link shown in the UI footer and emails. :ivar email_footer: Plain text appended to every notification email. .. py:attribute:: key :value: 'branding' .. py:attribute:: product_name :type: str .. py:attribute:: tagline :type: str .. py:attribute:: primary_color :type: str :value: '#2563eb' .. py:attribute:: accent_color :type: str :value: '#0d9488' .. py:attribute:: default_theme :type: Literal['system', 'light', 'dark'] :value: 'system' .. py:attribute:: default_language :type: Literal['auto', 'en', 'es', 'fr'] :value: 'auto' .. py:attribute:: login_message :type: str .. py:attribute:: support_email :type: str .. py:attribute:: support_url :type: pydantic.HttpUrl | None :value: None .. py:attribute:: email_footer :type: str .. py:function:: sniff_image(data: bytes) -> str 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. :param data: Uploaded bytes. :returns: The detected content type. :raises BrandingError: If the file is too large, not an accepted type, or an unsafe SVG. .. py:function:: save_asset(session: sqlalchemy.ext.asyncio.AsyncSession, key: str, data: bytes) -> s365b.db.models.Asset :async: Validate and store a branding image. :param session: Open session; the caller commits. :param key: One of :data:`ASSET_KEYS`. :param data: Image bytes. :returns: The stored asset. :raises BrandingError: If the key or image is invalid.