1#[cfg(feature = "account-data")]
7mod account_data;
8mod acting;
9mod invitation;
10mod members;
11mod organization;
12mod organizations;
13
14use sofie::db::Migrations;
15
16#[cfg(feature = "account-data")]
17pub use account_data::OrganizationMemberships;
18pub use acting::Acting;
19pub use invitation::Invitation;
20pub use members::{ROUTES as ORGANIZATION_ROUTES, routes as organization_routes};
21pub use organization::{
22 MemberJoined, MemberLeft, MemberRoleChanged, Organization, OrganizationArea,
23 OrganizationDeleted, OrganizationId, OrganizationMember, OrganizationRole,
24};
25pub use organizations::{ROUTES as MEMBER_ROUTES, routes as member_routes};
26
27const MODULE_NAME: &str = "sofie_tenancy";
28
29pub const TRANSLATIONS: &[sofie::db::File] =
30 sofie::db::embed!("lang", ["de.toml", "en.toml", "tr.toml"]);
31
32pub const MODULE: sofie::http::Module = sofie::http::Module {
34 migrations: Some(migrations()),
35 #[cfg(feature = "billing")]
36 jobs: worker,
37 ..sofie::http::Module::new(MODULE_NAME)
38};
39
40#[cfg(feature = "billing")]
41#[must_use]
42pub fn worker(worker: sofie::worker::Worker) -> sofie::worker::Worker {
43 worker
44 .on::<sofie::billing::SubscriptionChanged, _>(
45 "sofie_tenancy.cancel_deleted_plan",
46 organization::cancel_deleted_plan,
47 )
48 .on::<OrganizationDeleted, _>(
49 "sofie_tenancy.cancel_plan_of_deleted",
50 organization::cancel_plan_of_deleted,
51 )
52}
53
54#[must_use]
55pub const fn migrations() -> Migrations {
56 Migrations::new(
57 MODULE_NAME,
58 sofie::db::embed!(
59 "migrations",
60 [
61 "0000_module_role.sql",
62 "0001_organizations.sql",
63 "0002_organization_deleted.sql"
64 ]
65 ),
66 )
67 .sqlite(sofie::db::embed!(
68 "migrations/sqlite",
69 [
70 "0000_module_role.sql",
71 "0001_organizations.sql",
72 "0002_organization_deleted.sql"
73 ]
74 ))
75 .aggregates(AGGREGATES)
76}
77
78const AGGREGATES: &[sofie::db::AggregateTable] = &[
79 sofie::db::AggregateTable::of::<Organization>(),
80 sofie::db::AggregateTable::of::<OrganizationMember>(),
81 sofie::db::AggregateTable::of::<Invitation>(),
82];