DataManager

Struct DataManager 

Source
pub struct DataManager(pub DataManager<Config>, pub DataManager);

Tuple Fields§

§0: DataManager<Config>§1: DataManager

Implementations§

Source§

impl DataManager

Source

pub async fn get_audit_log_entry_by_id( &self, selector: usize, ) -> Result<AuditLogEntry>

Source

pub async fn get_audit_log_entries( &self, batch: usize, page: usize, ) -> Result<Vec<AuditLogEntry>>

Get all audit log entries (paginated).

§Arguments
  • batch - the limit of items in each page
  • page - the page number
Source

pub async fn create_audit_log_entry(&self, data: AuditLogEntry) -> Result<()>

Create a new audit log entry in the database.

§Arguments
Source

pub async fn delete_audit_log_entry(&self, id: usize, user: User) -> Result<()>

Source§

impl DataManager

Source

pub async fn get_ipban_by_ip(&self, selector: &str) -> Result<IpBan>

Source

pub async fn get_ipban_by_addr(&self, addr: &RemoteAddr) -> Result<IpBan>

Get an IP ban as a RemoteAddr.

§Arguments
  • prefix
Source

pub async fn get_ip_bans(&self, batch: usize, page: usize) -> Result<Vec<IpBan>>

Get all IP bans (paginated).

§Arguments
  • batch - the limit of items in each page
  • page - the page number
Source

pub async fn create_ipban(&self, data: IpBan) -> Result<()>

Create a new IP ban in the database.

§Arguments
  • data - a mock IpBan object to insert
Source

pub async fn delete_ipban(&self, ip: &str, user: User) -> Result<()>

Source§

impl DataManager

Source

pub async fn get_notification_by_id(&self, id: usize) -> Result<Notification>

Source

pub async fn get_notifications_by_owner( &self, owner: usize, ) -> Result<Vec<Notification>>

Get all notifications by owner.

Source

pub async fn get_notifications_by_owner_paginated( &self, owner: usize, batch: usize, page: usize, ) -> Result<Vec<Notification>>

Get all notifications by owner (paginated).

Source

pub async fn get_notifications_by_tag( &self, tag: &str, ) -> Result<Vec<Notification>>

Get all notifications by tag.

Source

pub async fn create_notification(&self, data: Notification) -> Result<()>

Create a new notification in the database.

§Arguments
Source

pub async fn delete_notification(&self, id: usize, user: &User) -> Result<()>

Source

pub async fn delete_all_notifications(&self, user: &User) -> Result<()>

Source

pub async fn delete_all_notifications_by_tag( &self, user: &User, tag: &str, ) -> Result<()>

Source

pub async fn update_notification_read( &self, id: usize, new_read: bool, user: &User, ) -> Result<()>

Source

pub async fn update_all_notifications_read( &self, user: &User, read: bool, ) -> Result<()>

Source§

impl DataManager

Source

pub async fn get_organization_membership_by_id( &self, selector: usize, ) -> Result<OrganizationMembership>

Source

pub async fn get_organization_memberships_by_user( &self, user: usize, ) -> Result<Vec<OrganizationMembership>>

Get all organization_memberships by user.

§Arguments
  • user - the ID of the user to fetch organization_memberships for
Source

pub async fn get_organization_memberships_by_organization( &self, organization: usize, batch: usize, page: usize, ) -> Result<Vec<OrganizationMembership>>

Get all organization_memberships by organization (paginated).

§Arguments
  • organization - the ID of the user to fetch organization_memberships for
Source

pub async fn get_organization_membership_by_owner_organization( &self, user: usize, organization: usize, ) -> Result<OrganizationMembership>

Get an organization membership by user and organization.

§Arguments
  • user - the ID of the user to fetch organization_memberships for
  • org - the ID of the organization
Source

pub async fn create_organization_membership( &self, data: OrganizationMembership, ) -> Result<()>

Create a new organization_membership in the database.

§Arguments
Source

pub async fn delete_organization_membership( &self, id: usize, user: User, ) -> Result<()>

Source

pub async fn update_organization_membership_role( &self, id: usize, x: OrganizationRole, ) -> Result<()>

Source§

impl DataManager

Source

pub async fn get_organization_by_id( &self, selector: usize, ) -> Result<Organization>

Source

pub async fn get_organization_by_name( &self, selector: &str, ) -> Result<Organization>

Source

pub async fn get_organizations_by_user( &self, user: usize, ) -> Result<Vec<Organization>>

Get all organizations by user.

§Arguments
  • user - the ID of the user to fetch organizations for
Source

pub async fn create_organization(&self, data: Organization) -> Result<usize>

Create a new organization in the database.

§Arguments
Source

pub async fn delete_organization(&self, id: usize, user: User) -> Result<()>

Source

pub async fn update_organization_name(&self, id: usize, x: &str) -> Result<()>

Source

pub async fn update_organization_roles( &self, id: usize, x: HashMap<usize, String>, ) -> Result<()>

Source

pub async fn incr_organization_members(&self, id: usize) -> Result<()>

Source

pub async fn decr_organization_members(&self, id: usize) -> Result<()>

Source§

impl DataManager

Source

pub async fn get_permissions_list_by_id( &self, selector: usize, ) -> Result<PermissionsList>

Source

pub async fn get_permissions_lists_by_organization( &self, organization: usize, batch: usize, page: usize, ) -> Result<Vec<PermissionsList>>

Get all permissions_lists by organization (paginated).

§Arguments
  • organization - the ID of the user to fetch permissions_lists for
Source

pub async fn create_permissions_list( &self, data: PermissionsList, ) -> Result<usize>

Create a new permissions_list in the database.

§Arguments
Source

pub async fn delete_permissions_list(&self, id: usize, user: User) -> Result<()>

Source

pub async fn update_permissions_list_roles( &self, id: usize, x: Vec<usize>, ) -> Result<()>

Source§

impl DataManager

Source

pub async fn get_property_by_id(&self, selector: usize) -> Result<Property>

Source

pub async fn get_properties_by_user(&self, user: usize) -> Result<Vec<Property>>

Get all properties by user (paginated).

§Arguments
  • user - the ID of the user to fetch properties for
Source

pub async fn create_property(&self, data: Property) -> Result<()>

Create a new property in the database.

§Arguments
  • data - a mock Property object to insert
Source

pub async fn delete_property(&self, id: usize, user: User) -> Result<()>

Source

pub async fn update_property_custom_domain( &self, id: usize, x: &str, ) -> Result<()>

Source

pub async fn update_property_name(&self, id: usize, x: &str) -> Result<()>

Source§

impl DataManager

Source

pub async fn get_user_warning_by_id( &self, selector: usize, ) -> Result<UserWarning>

Source

pub async fn get_user_warnings_by_user( &self, user: usize, batch: usize, page: usize, ) -> Result<Vec<UserWarning>>

Get all user warnings by user (paginated).

§Arguments
  • user - the ID of the user to fetch warnings for
  • batch - the limit of items in each page
  • page - the page number
Source

pub async fn create_user_warning(&self, data: UserWarning) -> Result<()>

Create a new user warning in the database.

§Arguments
Source

pub async fn delete_user_warning(&self, id: usize, user: User) -> Result<()>

Source§

impl DataManager

Source

pub async fn get_user_by_id(&self, selector: usize) -> Result<User>

Source

pub async fn get_user_by_username(&self, selector: &str) -> Result<User>

Source

pub async fn get_user_by_username_no_cache( &self, selector: &str, ) -> Result<User>

Source

pub async fn get_user_by_id_with_void(&self, id: usize) -> Result<User>

Get a user given just their ID. Returns the void user if the user doesn’t exist.

§Arguments
  • id - the ID of the user
Source

pub async fn get_user_by_token(&self, token: &str) -> Result<User>

Get a user given just their auth token.

§Arguments
  • token - the token of the user
Source

pub async fn create_user(&self, data: User) -> Result<User>

Create a new user in the database.

§Arguments
  • data - a mock User object to insert
Source

pub async fn delete_user( &self, id: usize, password: &str, force: bool, ) -> Result<User>

Delete an existing user in the database.

§Arguments
  • id - the ID of the user
  • password - the current password of the user
  • force - if we should delete even if the given password is incorrect
Source

pub async fn update_user_verified_status( &self, id: usize, x: bool, user: User, ) -> Result<()>

Source

pub async fn update_user_is_deactivated( &self, id: usize, x: bool, user: User, ) -> Result<()>

Source

pub async fn update_user_password( &self, id: usize, from: String, to: String, user: User, force: bool, ) -> Result<()>

Source

pub async fn update_user_username( &self, id: usize, to: String, user: User, ) -> Result<()>

Source

pub fn check_totp(&self, ua: &User, code: &str) -> bool

Validate a given TOTP code for the given profile.

Source

pub fn generate_totp_recovery_codes() -> Vec<String>

Generate 8 random recovery codes for TOTP.

Source

pub async fn update_user_totp( &self, id: usize, secret: &str, recovery: &Vec<String>, ) -> Result<()>

Update the profile’s TOTP secret.

§Arguments
  • id - the ID of the user
  • secret - the TOTP secret
  • recovery - the TOTP recovery codes
Source

pub async fn enable_totp( &self, id: usize, user: User, ) -> Result<(String, String, Vec<String>)>

Enable TOTP for a profile.

§Arguments
  • id - the ID of the user to enable TOTP for
  • user - the user doing this
§Returns

Result<(secret, qr base64)>

Source

pub async fn get_principal_org(&self, user: &User) -> Option<Organization>

Get the given user’s principal organization.

Source

pub async fn cache_clear_user(&self, user: &User)

Source

pub async fn update_user_permissions( &self, id: usize, x: Vec<UserPermission>, ) -> Result<()>

Source

pub async fn update_user_tokens(&self, id: usize, x: Vec<Token>) -> Result<()>

Source

pub async fn update_user_settings( &self, id: usize, x: UserSettings, ) -> Result<()>

Source

pub async fn update_user_ban_reason(&self, id: usize, x: &str) -> Result<()>

Source

pub async fn update_user_ban_expire(&self, id: usize, x: i64) -> Result<()>

Source

pub async fn update_user_checkouts( &self, id: usize, x: Vec<String>, ) -> Result<()>

Source

pub async fn update_user_linked_accounts( &self, id: usize, x: UserLinkedAccounts, ) -> Result<()>

Source

pub async fn update_user_badges( &self, id: usize, x: Vec<UserBadge>, ) -> Result<()>

Source

pub async fn update_user_principal_org( &self, id: usize, x: Option<i64>, ) -> Result<()>

Source

pub async fn update_user_org_as_tenant(&self, id: usize, x: i32) -> Result<()>

Source

pub async fn get_user_by_stripe_id(&self, selector: &str) -> Result<User>

Source

pub async fn update_user_stripe_id(&self, id: usize, x: &str) -> Result<()>

Source

pub async fn update_user_notification_count( &self, id: usize, x: i32, ) -> Result<()>

Source

pub async fn incr_user_notifications(&self, id: usize) -> Result<()>

Source

pub async fn decr_user_notifications(&self, id: usize) -> Result<()>

Source

pub async fn incr_user_org_creation_credits(&self, id: usize) -> Result<()>

Source

pub async fn decr_user_org_creation_credits(&self, id: usize) -> Result<()>

Source

pub async fn incr_user_org_user_register_credits(&self, id: usize) -> Result<()>

Source

pub async fn decr_user_org_user_register_credits(&self, id: usize) -> Result<()>

Source§

impl DataManager

Source

pub async fn new(config: Config) -> PgResult<Self>

Create a new DataManager.

Source

pub async fn init(&self) -> Result<()>

Initialize tables.

Trait Implementations§

Source§

impl Clone for DataManager

Source§

fn clone(&self) -> DataManager

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more