Files
inbuxa-server/crates/common/src/storage/mod.rs
T
jcoffey-dev 6a53d47106 Mark the files this fork changed (AGPL section 5(a))
The AGPL asks a modified version to carry prominent notices saying it was
modified, and giving a date. Publishing the source is the conveyance that
asks for it, so it wants doing before the repository is public rather than
at the release.

Every upstream file the fork changed now says so in its header, beneath the
notice it came with: 164 files, found by diffing against the upstream
snapshot branch rather than by guessing, so the list is what actually
differs. Files the fork wrote itself already carry their own copyright and
need nothing. Upstream's notices are untouched, which its licence requires
and which was already true.

The README says the same thing in prose, since the obligation is on the
work as a whole and not only its Rust files.

Builds unchanged: the server and the test binary both compile.
2026-09-19 23:48:35 -07:00

124 lines
3.2 KiB
Rust

/*
* SPDX-FileCopyrightText: 2020 Stalwart Labs LLC <[email protected]>
*
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-SEL
*
* Modified by Coffey Labs in 2026 for INBUXA.
*/
use crate::Server;
use directory::Directory;
use registry::{
schema::{
enums::{StorageQuota, TenantStorageQuota},
prelude::ObjectType,
},
types::EnumImpl,
};
use std::sync::Arc;
use store::{BlobStore, InMemoryStore, RegistryStore, SearchStore, Store};
pub mod archive;
pub mod blob;
pub mod branding; // inbuxa: branding BT-1, BT-2
pub mod dav;
pub mod document;
pub mod encryption;
pub mod index;
pub mod quota;
pub mod state;
pub mod transaction;
#[derive(Debug, Clone)]
pub struct ObjectQuota([u32; StorageQuota::COUNT - 1]);
#[derive(Debug, Clone)]
pub struct TenantQuota([u32; TenantStorageQuota::COUNT - 1]);
impl Server {
#[inline(always)]
pub fn registry(&self) -> &RegistryStore {
&self.core.storage.registry
}
#[inline(always)]
pub fn store(&self) -> &Store {
&self.core.storage.data
}
#[inline(always)]
pub fn blob_store(&self) -> &BlobStore {
&self.core.storage.blob
}
#[inline(always)]
pub fn search_store(&self) -> &SearchStore {
&self.core.storage.search
}
#[inline(always)]
pub fn in_memory_store(&self) -> &InMemoryStore {
&self.core.storage.memory
}
#[inline(always)]
pub fn tracing_store(&self) -> &Store {
&self.core.storage.tracing
}
#[inline(always)]
pub fn metrics_store(&self) -> &Store {
&self.core.storage.metrics
}
#[inline(always)]
pub fn get_directory(&self, id: &u32) -> Option<&Arc<Directory>> {
self.core.storage.directories.get(id)
}
#[inline(always)]
pub fn get_default_directory(&self) -> Option<&Arc<Directory>> {
self.core.storage.directory.as_ref()
}
#[inline(always)]
pub fn get_lookup_store(&self, name: &str) -> Option<InMemoryStore> {
if !name.is_empty() && name != "*" {
self.inner.data.lookup_stores.load().get(name).cloned()
} else {
self.in_memory_store().clone().into()
}
}
pub async fn total_accounts(&self) -> trc::Result<usize> {
self.registry().count_object(ObjectType::Account).await
}
pub async fn total_domains(&self) -> trc::Result<usize> {
self.registry().count_object(ObjectType::Domain).await
}
// inbuxa: BT-9: the first logo mail can carry inline; none leaves the
// built-in INBUXA logo
pub async fn logo_resource(
&self,
domain: &str,
) -> trc::Result<Option<crate::manager::application::Resource<Vec<u8>>>> {
Ok(self
.logos_for(domain)
.await?
.into_iter()
.find(|logo| logo.is_embeddable())
.and_then(|logo| match logo {
inbuxa_features::branding::logo::Logo::Image {
content_type,
bytes,
} => Some(crate::manager::application::Resource::new(
content_type,
bytes,
)),
inbuxa_features::branding::logo::Logo::Url(_) => None,
}))
}
}