mas_config/sections/branding.rs
1// Copyright 2024 New Vector Ltd.
2// Copyright 2023, 2024 The Matrix.org Foundation C.I.C.
3//
4// SPDX-License-Identifier: AGPL-3.0-only
5// Please see LICENSE in the repository root for full details.
6
7use schemars::JsonSchema;
8use serde::{Deserialize, Serialize};
9use url::Url;
10
11use crate::ConfigurationSection;
12
13/// Configuration section for tweaking the branding of the service
14#[derive(Clone, Debug, Deserialize, JsonSchema, Serialize, Default)]
15pub struct BrandingConfig {
16 /// A human-readable name. Defaults to the server's address.
17 #[serde(skip_serializing_if = "Option::is_none")]
18 pub service_name: Option<String>,
19
20 /// Link to a privacy policy, displayed in the footer of web pages and
21 /// emails. It is also advertised to clients through the `op_policy_uri`
22 /// OIDC provider metadata.
23 #[serde(skip_serializing_if = "Option::is_none")]
24 pub policy_uri: Option<Url>,
25
26 /// Link to a terms of service document, displayed in the footer of web
27 /// pages and emails. It is also advertised to clients through the
28 /// `op_tos_uri` OIDC provider metadata.
29 #[serde(skip_serializing_if = "Option::is_none")]
30 pub tos_uri: Option<Url>,
31
32 /// Legal imprint, displayed in the footer in the footer of web pages and
33 /// emails.
34 #[serde(skip_serializing_if = "Option::is_none")]
35 pub imprint: Option<String>,
36
37 /// Logo displayed in some web pages.
38 #[serde(skip_serializing_if = "Option::is_none")]
39 pub logo_uri: Option<Url>,
40}
41
42impl BrandingConfig {
43 /// Returns true if the configuration is the default one
44 pub(crate) fn is_default(&self) -> bool {
45 self.service_name.is_none()
46 && self.policy_uri.is_none()
47 && self.tos_uri.is_none()
48 && self.imprint.is_none()
49 && self.logo_uri.is_none()
50 }
51}
52
53impl ConfigurationSection for BrandingConfig {
54 const PATH: Option<&'static str> = Some("branding");
55}