Struct DataManager

Source
pub struct DataManager(pub DataManager<Config>, pub HashMap<String, LangFile>);

Tuple Fields§

§0: DataManager<Config>§1: HashMap<String, LangFile>

Implementations§

Source§

impl DataManager

Source

pub const AD_RUN_CHARGE: i32 = 25i32

The amount charged to a UserAd owner each day the ad is running (and is pulled from the pool).

Source

pub const AD_CLICK_CHARGE: i32 = 2i32

The amount charged to a UserAd owner each time the ad is clicked.

Source

pub async fn get_ad_by_id(&self, selector: usize) -> Result<UserAd>

Source

pub async fn get_ads_by_user( &self, id: usize, batch: usize, page: usize, ) -> Result<Vec<UserAd>>

Get all ads by user.

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

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

Disable all ads by the given user.

§Arguments
  • id - the ID of the user to kill ads from
Source

pub async fn create_ad(&self, data: UserAd) -> Result<UserAd>

Create a new ad in the database.

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

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

Source

pub async fn random_ad(&self, size: UserAdSize) -> Result<UserAd>

Pull a random running ad.

Source

pub async fn random_ad_charged(&self, size: UserAdSize) -> Result<UserAd>

Get a random ad and check if the ad owner needs to be charged for this period.

Source

pub async fn ad_click( &self, host: usize, ad: usize, user: Option<User>, ) -> Result<String>

Handle a click on an ad from the given host.

Hosts are just the ID of the user that is embedding the ad on their page.

Source

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

Source

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

Source§

impl DataManager

Source

pub async fn get_app_data_by_id(&self, selector: usize) -> Result<AppData>

Source

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

Get all app_data by app.

§Arguments
  • id - the ID of the app to fetch app_data for
Source

pub async fn query_app_data( &self, query: AppDataQuery, ) -> Result<AppDataQueryResult>

Get all app_data by the given query.

Source

pub async fn query_delete_app_data(&self, query: AppDataQuery) -> Result<()>

Delete all app_data matched by the given query.

Source

pub async fn create_app_data(&self, data: AppData) -> Result<AppData>

Create a new app_data in the database.

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

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

Source

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

Source

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

Source§

impl DataManager

Source

pub async fn get_app_by_id(&self, selector: usize) -> Result<ThirdPartyApp>

Source

pub async fn get_app_by_api_key(&self, selector: &str) -> Result<ThirdPartyApp>

Source

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

Get all apps by user.

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

pub async fn create_app(&self, data: ThirdPartyApp) -> Result<ThirdPartyApp>

Create a new app in the database.

§Arguments
Source

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

Source

pub async fn cache_clear_app(&self, app: &ThirdPartyApp)

Source

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

Source

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

Source

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

Source

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

Source

pub async fn update_app_scopes( &self, id: usize, user: &User, x: Vec<AppScope>, ) -> Result<()>

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

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_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_browser_session(&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 get_user_by_grant_token( &self, token: &str, check_expiration: bool, ) -> Result<(AuthGrant, User)>

Get a user given just their grant token.

Also returns the auth grant this token is associated with from the user.

§Arguments
  • token - the token of the user
Source

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

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 async fn update_user_awaiting_purchased_status( &self, id: usize, x: bool, user: User, require_permission: bool, ) -> Result<()>

Source

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

Source

pub fn add_achievement<'life0, 'life_self, 'async_recursion>( &'life_self self, user: &'life0 mut User, achievement: Achievement, check_for_final: bool, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_recursion>>
where 'life0: 'async_recursion, 'life_self: 'async_recursion,

Add an achievement to a user.

Still returns Ok if the user already has the achievement.

Source

pub fn fill_achievements( &self, list: Vec<Achievement>, ) -> Vec<(String, String, AchievementRarity, Achievement)>

Fill achievements with their title and description.

§Returns

(name, description, rarity, achievement)

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_applied_configurations( &self, user: &User, ) -> Result<Vec<String>>

Get all applied configurations as a vector of strings from the given user.

Source

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

Source

pub async fn update_user_role( &self, id: usize, role: FinePermission, user: &User, force: bool, ) -> Result<()>

Source

pub async fn update_user_secondary_role( &self, id: usize, role: SecondaryPermission, user: &User, force: bool, ) -> Result<()>

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

pub async fn update_user_applied_configurations( &self, id: usize, x: Vec<(AppliedConfigType, usize)>, ) -> 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_follower_count(&self, id: usize) -> Result<()>

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

pub async fn get_user_by_invite_code(&self, selector: i64) -> Result<User>

Source§

impl DataManager

Source

pub async fn get_channel_by_id(&self, selector: usize) -> Result<Channel>

Source

pub async fn fill_members( &self, members: &Vec<usize>, ignore_users: Vec<usize>, ) -> Result<Vec<User>>

Get all member profiles from a channel members list.

Source

pub async fn get_channels_by_community( &self, community: usize, ) -> Result<Vec<Channel>>

Get all channels by community.

§Arguments
  • community - the ID of the community to fetch channels for
Source

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

Get all channels by user.

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

pub async fn get_channel_by_owner_member( &self, owner: usize, member: usize, ) -> Result<Channel>

Get a channel given its owner and a member.

§Arguments
  • owner - the ID of the owner
  • member - the ID of the member
Source

pub async fn create_channel(&self, data: Channel) -> Result<()>

Create a new channel in the database.

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

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source§

impl DataManager

Source

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

Source

pub async fn get_table_row_count(&self, table: &str) -> Result<i32>

Source

pub async fn get_table_row_count_where( &self, table: &str, where: &str, ) -> Result<i32>

Source§

impl DataManager

Source

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

Source

pub async fn get_community_by_title(&self, id: &str) -> Result<Community>

Source

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

Source

pub async fn get_community_by_title_no_void( &self, selector: &str, ) -> Result<Community>

Get the top 12 most popular (most likes) communities.

Source

pub async fn get_communities_searched( &self, query: &str, batch: usize, page: usize, ) -> Result<Vec<Community>>

Get all communities, filtering their title. Communities are sorted by popularity first, creation date second.

Source

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

Get all communities by their owner.

Source

pub async fn create_community(&self, data: Community) -> Result<String>

Create a new community in the database.

§Arguments
Source

pub async fn cache_clear_community(&self, community: &Community)

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

pub async fn update_community_topics( &self, id: usize, user: &User, x: HashMap<usize, ForumTopic>, ) -> Result<()>

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source§

impl DataManager

Source

pub async fn get_domain_by_id(&self, selector: usize) -> Result<Domain>

Source

pub async fn get_domain_by_name_tld( &self, name: &str, tld: &DomainTld, ) -> Result<Domain>

Get a domain given its name and TLD.

§Arguments
  • name
  • tld
Source

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

Get all domains by user.

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

pub async fn create_domain(&self, data: Domain) -> Result<Domain>

Create a new domain in the database.

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

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

Source

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

Source§

impl DataManager

Source

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

Source

pub async fn get_drafts_by_user( &self, id: usize, batch: usize, page: usize, ) -> Result<Vec<PostDraft>>

Get all drafts from the given user (from most recent, paginated).

§Arguments
  • id - the ID of the user the requested drafts belong to
  • batch - the limit of posts in each page
  • page - the page number
Source

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

Get all drafts from the given user (from most recent).

§Arguments
  • id - the ID of the user the requested drafts belong to
Source

pub async fn create_draft(&self, data: PostDraft) -> Result<usize>

Create a new post draft in the database.

§Arguments
Source

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

Source

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

Source§

impl DataManager

Source

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

Create a new DataManager.

Source§

impl DataManager

Source

pub async fn get_emoji_by_id(&self, selector: usize) -> Result<CustomEmoji>

Source

pub async fn get_emojis_by_community( &self, community: usize, ) -> Result<Vec<CustomEmoji>>

Get all emojis by community.

§Arguments
  • community - the ID of the community to fetch emojis for
Source

pub async fn get_user_emojis( &self, id: usize, ) -> Result<HashMap<usize, (String, Vec<CustomEmoji>)>>

Get all emojis by their community for the communities the given user is in.

Source

pub async fn get_emoji_by_community_name( &self, community: usize, name: &str, ) -> Result<(Option<CustomEmoji>, Option<String>)>

Get an emoji by community and name.

§Arguments
  • community - the ID of the community to fetch emoji from
  • name - the name of the emoji
§Returns

(custom emoji, emoji string)

Custom emoji will be none if emoji string is some, and vice versa. Emoji string will only be some if the community is 0 (no community ID in parsed string, or 0.emoji_name)

Regular unicode emojis should have a community ID of 0, since they don’t belong to any community and can be used by anyone.

Source

pub async fn create_emoji(&self, data: CustomEmoji) -> Result<()>

Create a new emoji in the database.

§Arguments
Source

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

Source

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

Source§

impl DataManager

Source

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

Source

pub async fn get_invite_code_by_code( &self, selector: &str, ) -> Result<InviteCode>

Source

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

Get invite_codes by owner.

Source

pub async fn get_invite_codes_by_owner_count(&self, owner: usize) -> Result<i32>

Get invite_codes by owner.

Source

pub async fn fill_invite_codes( &self, codes: Vec<InviteCode>, ) -> Result<Vec<(Option<User>, InviteCode)>>

Fill a vector of invite codes with the user that used them.

Source

pub async fn create_invite_code( &self, data: InviteCode, user: &User, ) -> Result<InviteCode>

Create a new invite_code in the database.

§Arguments
Source

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

Source

pub async fn update_invite_code_is_used( &self, id: usize, new_is_used: bool, ) -> 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_ipbans(&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_ipblock_by_id(&self, id: usize) -> Result<IpBlock>

Source

pub async fn get_ipblock_by_initiator_receiver( &self, initiator: usize, receiver: &RemoteAddr, ) -> Result<IpBlock>

Get a ip block by initiator and receiver (in that order).

Source

pub async fn get_ipblock_by_receiver_initiator( &self, receiver: &str, initiator: usize, ) -> Result<IpBlock>

Get a ip block by receiver and initiator (in that order).

Source

pub async fn get_ipblocks_by_initiator( &self, initiator: usize, ) -> Result<Vec<IpBlock>>

Get all ip blocks by initiator.

Source

pub async fn create_ipblock(&self, data: IpBlock) -> Result<()>

Create a new ip block in the database.

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

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

Source§

impl DataManager

Source

pub async fn get_journal_by_id(&self, selector: usize) -> Result<Journal>

Source

pub async fn get_journal_by_owner_title( &self, owner: usize, title: &str, ) -> Result<Journal>

Get a journal by owner and title.

Source

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

Get all journals by user.

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

pub async fn create_journal(&self, data: Journal) -> Result<Journal>

Create a new journal in the database.

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

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

Source

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

Source

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

Source

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

Source§

impl DataManager

Source

pub async fn get_letter_by_id(&self, selector: usize) -> Result<Letter>

Source

pub async fn get_letters_by_user( &self, id: usize, batch: usize, page: usize, ) -> Result<Vec<Letter>>

Get all letters by user.

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

pub async fn get_received_letters_by_user( &self, id: usize, batch: usize, page: usize, ) -> Result<Vec<Letter>>

Get all letters by user (where user is a receiver).

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

pub async fn get_letters_by_replying_to( &self, id: usize, batch: usize, page: usize, ) -> Result<Vec<Letter>>

Get all letters which are replying to the given letter.

§Arguments
  • id - the ID of the letter to fetch letters for
  • batch - the limit of items in each page
  • page - the page number
Source

pub async fn fill_letters( &self, letters: Vec<Letter>, ) -> Result<Vec<(User, Letter)>>

Fill a list of letters with their owner.

Source

pub async fn create_letter(&self, data: Letter) -> Result<Letter>

Create a new letter in the database.

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

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source§

impl DataManager

Source

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

Source

pub async fn fill_communities( &self, list: Vec<CommunityMembership>, ) -> Result<Vec<Community>>

Replace a list of community memberships with the proper community.

Source

pub async fn fill_users( &self, list: Vec<CommunityMembership>, ) -> Result<Vec<(CommunityMembership, User)>>

Replace a list of community memberships with the proper user.

Source

pub async fn get_membership_by_owner_community( &self, owner: usize, community: usize, ) -> Result<CommunityMembership>

Get a community membership by owner and community.

Source

pub async fn get_membership_by_owner_community_no_void( &self, owner: usize, community: usize, ) -> Result<CommunityMembership>

Get a community membership by owner and community.

Source

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

Get all community memberships by owner.

Source

pub async fn get_memberships_by_community( &self, community: usize, community_owner: usize, batch: usize, page: usize, ) -> Result<Vec<CommunityMembership>>

Get all community memberships by community.

Source

pub fn create_membership<'life0, 'life_self, 'async_recursion>( &'life_self self, data: CommunityMembership, user: &'life0 User, ) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_recursion>>
where 'life0: 'async_recursion, 'life_self: 'async_recursion,

Create a new community membership in the database.

§Arguments
Source

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

Delete a membership given its id

Source

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

Delete a membership given its id

Source

pub async fn update_membership_role( &self, id: usize, new_role: CommunityPermission, ) -> Result<()>

Update a membership’s role given its id

Source§

impl DataManager

Source

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

Source

pub async fn get_message_reactions_by_owner_message( &self, owner: usize, message: usize, ) -> Result<Vec<MessageReaction>>

Get message_reactions by owner and message.

Source

pub async fn get_message_reaction_by_owner_message_emoji( &self, owner: usize, message: usize, emoji: &str, ) -> Result<MessageReaction>

Get a message_reaction by owner, message, and emoji.

Source

pub async fn create_message_reaction( &self, data: MessageReaction, user: &User, ) -> Result<()>

Create a new message_reaction in the database.

§Arguments
Source

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

Source§

impl DataManager

Source

pub async fn get_message_by_id(&self, selector: usize) -> Result<Message>

Source

pub async fn fill_messages( &self, messages: Vec<Message>, ignore_users: &[usize], ) -> Result<Vec<(Message, User, bool)>>

Complete a vector of just messages with their owner as well.

§Returns

(message, owner, group with previous messages in ui)

Source

pub async fn get_messages_by_channel( &self, channel: usize, batch: usize, page: usize, ) -> Result<Vec<Message>>

Get all messages by channel (paginated).

§Arguments
  • channel - the ID of the community to fetch channels for
  • batch - the limit of items in each page
  • page - the page number
Source

pub async fn create_message(&self, data: Message) -> Result<()>

Create a new message in the database.

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

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

Source

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

Source

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

Source§

impl DataManager

Source

pub const MAXIMUM_FREE_GLOBAL_NOTES: usize = 10usize

Source

pub const MAXIMUM_SUPPORTER_GLOBAL_NOTES: usize = 50usize

Source

pub async fn get_note_by_id(&self, selector: usize) -> Result<Note>

Source

pub async fn get_global_note_by_title(&self, selector: &str) -> Result<Note>

Source

pub async fn get_user_global_notes_count(&self, owner: usize) -> Result<i32>

Get the number of global notes a user has.

Source

pub async fn get_note_by_journal_title( &self, journal: usize, title: &str, ) -> Result<Note>

Get a note by journal and title.

Source

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

Get all notes by journal.

§Arguments
  • id - the ID of the journal to fetch notes for
Source

pub async fn get_notes_by_journal_tag( &self, id: usize, tag: &str, ) -> Result<Vec<Note>>

Get all notes by journal with the given tag.

§Arguments
  • id - the ID of the journal to fetch notes for
  • tag
Source

pub async fn create_note(&self, data: Note) -> Result<Note>

Create a new note in the database.

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

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

Source

pub async fn delete_notes_by_journal_dir( &self, journal: usize, dir: usize, user: &User, ) -> Result<()>

Delete all notes by dir ID.

§Arguments
  • journal
  • dir
Source

pub async fn incr_note_views(&self, id: usize)

Incremenet note views. Views are only stored in the cache.

This should only be done for global notes.

Source

pub async fn get_note_views(&self, id: usize) -> Option<String>

Source

pub async fn cache_clear_note(&self, x: &Note)

Source

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

Source

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

Source

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

Source

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

Source

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

Source

pub async fn update_note_is_global(&self, id: usize, x: i32) -> 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_poll_by_id(&self, id: usize) -> Result<Poll>

Source

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

Get all polls by their owner.

§Arguments
  • owner - the ID of the owner of the polls
Source

pub async fn create_poll(&self, data: Poll) -> Result<usize>

Create a new poll in the database.

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

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

Source

pub async fn cache_clear_poll(&self, poll: &Poll)

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source§

impl DataManager

Source

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

Source

pub async fn get_pollvote_by_owner_poll( &self, id: usize, poll_id: usize, ) -> Result<PollVote>

Source

pub async fn create_pollvote(&self, data: PollVote) -> Result<usize>

Create a new poll vote in the database.

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

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

Source§

impl DataManager

Source

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

Source

pub async fn get_replies_by_post( &self, id: usize, batch: usize, page: usize, sort: &str, ) -> Result<Vec<Post>>

Get all posts which are comments on the given post by ID.

§Arguments
  • id - the ID of the post the requested posts are commenting on
  • batch - the limit of posts in each page
  • page - the page number
Source

pub async fn get_post_reposting( &self, post: &Post, ignore_users: &[usize], user: &Option<User>, ) -> (bool, Option<(User, Post)>)

Get the post the given post is reposting (if some).

Source

pub async fn get_post_question( &self, post: &Post, ignore_users: &[usize], seen_questions: &mut HashMap<usize, (Question, User, Option<(User, Post)>)>, ) -> Result<Option<(Question, User, Option<(User, Post)>)>>

Get the question of a given post.

Source

pub async fn get_post_poll( &self, post: &Post, user: &Option<User>, ) -> Result<Option<(Poll, bool, bool)>>

Get the poll of the given post (if some).

§Returns

Result<Option<(poll, voted, expired)>>

Source

pub async fn get_post_stack( &self, seen_stacks: &mut HashMap<usize, UserStack>, post: &Post, as_user_id: usize, ) -> (bool, Option<UserStack>)

Get the stack of the given post (if some).

§Returns

(can view post, stack)

Source

pub async fn fill_posts( &self, posts: Vec<Post>, ignore_users: &[usize], user: &Option<User>, ) -> Result<Vec<(Post, User, Option<(User, Post)>, Option<(Question, User, Option<(User, Post)>)>, Option<(Poll, bool, bool)>, Option<UserStack>)>>

Complete a vector of just posts with their owner as well.

Source

pub async fn fill_posts_with_community( &self, posts: Vec<Post>, user_id: usize, ignore_users: &[usize], user: &Option<User>, ) -> Result<Vec<FullPost>>

Complete a vector of just posts with their owner and community as well.

Source

pub fn posts_muted_phrase_filter( &self, posts: &Vec<FullPost>, muted: Option<&Vec<String>>, ) -> Vec<FullPost>

Update posts which contain a muted phrase.

Source

pub fn posts_owner_filter(&self, posts: &Vec<FullPost>) -> Vec<FullPost>

Filter to update posts to clean their owner for public APIs.

Source

pub async fn get_posts_by_user( &self, id: usize, batch: usize, page: usize, ) -> Result<Vec<Post>>

Get all posts from the given user (from most recent).

§Arguments
  • id - the ID of the user the requested posts belong to
  • batch - the limit of posts in each page
  • page - the page number
Source

pub async fn get_responses_by_user( &self, id: usize, batch: usize, page: usize, ) -> Result<Vec<Post>>

Get all posts (that are answering a question) from the given user (from most recent).

§Arguments
  • id - the ID of the user the requested posts belong to
  • batch - the limit of posts in each page
  • page - the page number
Source

pub async fn get_replies_by_user( &self, id: usize, batch: usize, page: usize, user: &Option<User>, ) -> Result<Vec<Post>>

Get all replies from the given user (from most recent).

§Arguments
  • id - the ID of the user the requested posts belong to
  • batch - the limit of posts in each page
  • page - the page number
Source

pub async fn get_media_posts_by_user( &self, id: usize, batch: usize, page: usize, user: &Option<User>, ) -> Result<Vec<Post>>

Get all posts containing media from the given user (from most recent).

§Arguments
  • id - the ID of the user the requested posts belong to
  • batch - the limit of posts in each page
  • page - the page number
Source

pub async fn get_posts_by_user_searched( &self, id: usize, batch: usize, page: usize, text_query: &str, user: &Option<&User>, ) -> Result<Vec<Post>>

Get all posts from the given user (searched).

§Arguments
  • id - the ID of the user the requested posts belong to
  • batch - the limit of posts in each page
  • page - the page number
  • text_query - the search query
  • user - the user who is viewing the posts
Source

pub async fn get_posts_searched( &self, batch: usize, page: usize, text_query: &str, ) -> Result<Vec<Post>>

Get all post (searched).

§Arguments
  • batch - the limit of posts in each page
  • page - the page number
  • text_query - the search query
Source

pub async fn get_posts_by_user_tag( &self, id: usize, tag: &str, batch: usize, page: usize, ) -> Result<Vec<Post>>

Get all posts from the given user with the given tag (from most recent).

§Arguments
  • id - the ID of the user the requested posts belong to
  • tag - the tag to filter by
  • batch - the limit of posts in each page
  • page - the page number
Source

pub async fn get_responses_by_user_tag( &self, id: usize, tag: &str, batch: usize, page: usize, ) -> Result<Vec<Post>>

Get all posts (that are answering a question) from the given user with the given tag (from most recent).

§Arguments
  • id - the ID of the user the requested posts belong to
  • tag - the tag to filter by
  • batch - the limit of posts in each page
  • page - the page number
Source

pub async fn get_posts_by_community( &self, id: usize, batch: usize, page: usize, user: &Option<User>, ) -> Result<Vec<Post>>

Get all posts from the given community (from most recent).

§Arguments
  • id - the ID of the community the requested posts belong to
  • batch - the limit of posts in each page
  • page - the page number
Source

pub async fn get_posts_by_community_topic( &self, id: usize, topic: usize, batch: usize, page: usize, user: &Option<User>, ) -> Result<Vec<Post>>

Get all posts from the given community and topic (from most recent).

§Arguments
  • id - the ID of the community the requested posts belong to
  • topic - the ID of the topic the requested posts belong to
  • batch - the limit of posts in each page
  • page - the page number
Source

pub async fn get_posts_by_stack( &self, id: usize, batch: usize, page: usize, ) -> Result<Vec<Post>>

Get all posts from the given stack (from most recent).

§Arguments
  • id - the ID of the stack the requested posts belong to
  • batch - the limit of posts in each page
  • page - the page number
Source

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

Get all pinned posts from the given community (from most recent).

§Arguments
  • id - the ID of the community the requested posts belong to
Source

pub async fn get_pinned_posts_by_community_topic( &self, id: usize, topic: usize, ) -> Result<Vec<Post>>

Get all pinned posts from the given community (from most recent).

§Arguments
  • id - the ID of the community the requested posts belong to
  • topic - the ID of the topic the requested posts belong to
Source

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

Get all pinned posts from the given user (from most recent).

§Arguments
  • id - the ID of the user the requested posts belong to
Source

pub async fn get_posts_by_question( &self, id: usize, batch: usize, page: usize, ) -> Result<Vec<Post>>

Get all posts answering the given question (from most recent).

§Arguments
  • id - the ID of the question the requested posts belong to
  • batch - the limit of posts in each page
  • page - the page number
Source

pub async fn get_post_by_owner_question( &self, owner: usize, question: usize, ) -> Result<Post>

Get a post given its owner and question ID.

§Arguments
  • owner - the ID of the post owner
  • question - the ID of the post question
Source

pub async fn get_quoting_posts_by_quoting( &self, id: usize, batch: usize, page: usize, ) -> Result<Vec<Post>>

Get all quoting posts by the post their quoting.

Requires that the post has content. See Self::get_reposts_by_quoting for the no-content version.

§Arguments
  • id - the ID of the post that is being quoted
  • batch - the limit of posts in each page
  • page - the page number
Source

pub async fn get_reposts_by_quoting( &self, id: usize, batch: usize, page: usize, ) -> Result<Vec<Post>>

Get all quoting posts by the post their quoting.

Requires that the post has no content. See Self::get_quoting_posts_by_quoting for the content-required version.

§Arguments
  • id - the ID of the post that is being quoted
  • batch - the limit of posts in each page
  • page - the page number

Get posts from all communities, sorted by likes.

§Arguments
  • batch - the limit of posts in each page
  • page - the page number
  • cutoff - the maximum number of milliseconds ago the post could have been created
Source

pub async fn get_latest_posts( &self, batch: usize, page: usize, as_user: &Option<User>, before_time: usize, ) -> Result<Vec<Post>>

Get posts from all communities, sorted by creation.

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

pub async fn get_latest_forum_posts( &self, batch: usize, page: usize, as_user: &Option<User>, before_time: usize, ) -> Result<Vec<Post>>

Get forum posts from all communities, sorted by creation.

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

pub async fn get_posts_from_user_communities( &self, id: usize, batch: usize, page: usize, user: &User, ) -> Result<Vec<Post>>

Get posts from all communities the given user is in.

§Arguments
  • id - the ID of the user
  • batch - the limit of posts in each page
  • page - the page number
Source

pub async fn get_posts_from_user_following( &self, id: usize, batch: usize, page: usize, ) -> Result<Vec<Post>>

Get posts from all users the given user is following.

§Arguments
  • id - the ID of the user
  • batch - the limit of posts in each page
  • page - the page number
Source

pub async fn get_posts_from_stack( &self, id: usize, batch: usize, page: usize, sort: StackSort, ) -> Result<Vec<Post>>

Get posts from all users in the given stack.

§Arguments
  • id - the ID of the stack
  • batch - the limit of posts in each page
  • page - the page number
Source

pub async fn check_can_post(&self, community: &Community, uid: usize) -> bool

Check if the given uid can post in the given community.

Source

pub async fn check_can_post_with_access( &self, community: &Community, access: &CommunityWriteAccess, uid: usize, ) -> bool

Check if the given uid can post in the given community with the given access.

Source

pub async fn create_post(&self, data: Post) -> Result<usize>

Create a new post in the database.

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

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source§

impl DataManager

Source

pub async fn get_product_by_id(&self, selector: usize) -> Result<Product>

Source

pub async fn get_products_by_user( &self, id: usize, batch: usize, page: usize, ) -> Result<Vec<Product>>

Get all products by user.

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

pub async fn create_product(&self, data: Product) -> Result<Product>

Create a new product in the database.

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

pub async fn purchase_product( &self, product: usize, customer: &mut User, ) -> Result<CoinTransfer>

Purchase the given product as the given user.

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source§

impl DataManager

Source

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

Source

pub async fn get_question_asking_about( &self, question: &Question, ) -> Result<Option<(User, Post)>>

Get the post a given question is asking about.

Source

pub async fn fill_questions( &self, questions: Vec<Question>, ignore_users: &[usize], ) -> Result<Vec<(Question, User, Option<(User, Post)>)>>

Fill the given vector of questions with their owner as well.

Source

pub fn questions_owner_filter( &self, questions: &Vec<(Question, User, Option<(User, Post)>)>, ) -> Vec<(Question, User, Option<(User, Post)>)>

Filter to update questions to clean their owner for public APIs.

Source

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

Get all questions by owner.

Source

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

Get all questions by owner (paginated).

Source

pub async fn get_questions_by_receiver( &self, receiver: usize, ) -> Result<Vec<Question>>

Get all questions by receiver.

Source

pub async fn get_questions_by_community( &self, community: usize, batch: usize, page: usize, ) -> Result<Vec<Question>>

Get all global questions by community.

Source

pub async fn get_questions_from_user_following( &self, id: usize, batch: usize, page: usize, ) -> Result<Vec<Question>>

Get all global questions by the given user’s following.

Source

pub async fn get_questions_from_user_communities( &self, id: usize, batch: usize, page: usize, ) -> Result<Vec<Question>>

Get all global questions posted in the given user’s communities.

Source

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

Get global questions from all communities, sorted by creation.

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

Get global questions from all communities, sorted by likes.

§Arguments
  • batch - the limit of questions in each page
  • page - the page number
  • cutoff - the maximum number of milliseconds ago the question could have been created
Source

pub async fn create_question( &self, data: Question, drawings: Vec<Vec<u8>>, ) -> Result<usize>

Create a new question in the database.

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

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source§

impl DataManager

Source

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

Source

pub async fn fill_reactions( &self, reactions: &Vec<Reaction>, ignore_users: Vec<usize>, ) -> Result<Vec<(Reaction, User)>>

Get all owner profiles from a reactions list.

Source

pub async fn get_reactions_by_asset( &self, asset: usize, batch: usize, page: usize, ) -> Result<Vec<Reaction>>

Get all reactions by their asset.

Source

pub async fn get_likes_reactions_by_asset( &self, asset: usize, batch: usize, page: usize, ) -> Result<Vec<Reaction>>

Get all reactions (likes only) by their asset.

Source

pub async fn get_reaction_by_owner_asset( &self, owner: usize, asset: usize, ) -> Result<Reaction>

Get a reaction by owner and asset.

Source

pub async fn create_reaction( &self, data: Reaction, user: &User, addr: &RemoteAddr, ) -> Result<()>

Create a new reaction in the database.

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

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

Source§

impl DataManager

Source

pub async fn get_report_by_id(&self, selector: usize) -> Result<Report>

Source

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

Get all reports (paginated).

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

pub async fn create_report(&self, data: Report) -> Result<()>

Create a new report in the database.

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

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

Source§

impl DataManager

Source

pub async fn get_request_by_id_linked_asset( &self, id: usize, linked_asset: usize, ) -> Result<ActionRequest>

Source

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

Get all action requests by owner.

Source

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

Get all action requests by owner (paginated).

Source

pub async fn create_request(&self, data: ActionRequest) -> Result<()>

Create a new request in the database.

§Arguments
Source

pub async fn delete_request( &self, id: usize, linked_asset: usize, user: &User, force: bool, ) -> Result<()>

Source

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

Source§

impl DataManager

Source

pub async fn get_service_by_id(&self, selector: usize) -> Result<Service>

Source

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

Get all services by user.

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

pub async fn create_service(&self, data: Service) -> Result<Service>

Create a new service in the database.

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

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

Source

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

Source

pub async fn update_service_files( &self, id: usize, user: &User, x: Vec<ServiceFsEntry>, ) -> Result<()>

Source

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

Source§

impl DataManager

Source

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

Source

pub async fn get_user_stack_blocked_users(&self, user_id: usize) -> Vec<usize>

Source

pub async fn fill_stackblocks_receivers( &self, stack: usize, ) -> Result<Vec<usize>>

Fill a vector of stack blocks with their receivers (by pulling the stack).

Source

pub async fn get_stackblocks_by_initiator( &self, initiator: usize, ) -> Vec<StackBlock>

Get all stack blocks created by the given initiator.

Source

pub async fn get_stackblock_by_initiator_stack( &self, initiator: usize, stack: usize, ) -> Result<StackBlock>

Get a stack block by initiator and stack (in that order).

Source

pub async fn create_stackblock(&self, data: StackBlock) -> Result<()>

Create a new stack block in the database.

§Arguments
Source

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

Source

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

Source§

impl DataManager

Source

pub const MAXIMUM_FREE_STACK_USERS: usize = 50usize

Source

pub async fn get_stack_by_id(&self, selector: usize) -> Result<UserStack>

Source

pub async fn get_stack_posts( &self, as_user_id: usize, id: usize, batch: usize, page: usize, ignore_users: &Vec<usize>, user: &Option<User>, ) -> Result<Vec<FullPost>>

Source

pub async fn get_stack_users( &self, id: usize, batch: usize, page: usize, ) -> Result<Vec<User>>

Source

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

Get all stacks by user.

Also pulls stacks that are of “Circle” type AND the user is added to the users list.

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

pub async fn create_stack(&self, data: UserStack) -> Result<UserStack>

Create a new stack in the database.

§Arguments
Source

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

Source

pub async fn clone_stack(&self, owner: usize, stack: usize) -> Result<UserStack>

Clone the given stack.

Source

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

Source

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

Source

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

Source

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

Source

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

Source§

impl DataManager

Source

pub async fn get_transfer_by_id(&self, selector: usize) -> Result<CoinTransfer>

Source

pub async fn fill_transfers( &self, list: Vec<CoinTransfer>, ) -> Result<Vec<(User, User, Option<Product>, CoinTransfer)>>

Fill a list of transfers with their users and product.

Source

pub async fn get_transfers_by_user( &self, id: usize, batch: usize, page: usize, ) -> Result<Vec<CoinTransfer>>

Get all transfers by user.

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

pub async fn get_transfer_by_sender_method( &self, id: usize, method: CoinTransferMethod, ) -> Result<CoinTransfer>

Get a transfer by user and method.

§Arguments
  • id - the ID of the user to fetch transfers for
  • method - the transfer method
Source

pub async fn create_transfer( &self, data: &mut CoinTransfer, apply: bool, ) -> Result<usize>

Create a new transfer in the database.

§Arguments
Source

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

Apply a pending transfer.

Source

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

Source§

impl DataManager

Source

pub async fn get_upload_by_id(&self, selector: usize) -> Result<MediaUpload>

Source

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

Get all uploads (paginated).

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

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

Get all uploads by their owner (paginated).

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

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

Get all uploads by their owner.

§Arguments
  • owner - the ID of the owner of the upload
Source

pub async fn create_upload(&self, data: MediaUpload) -> Result<MediaUpload>

Create a new upload in the database.

§Arguments
Source

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

Source

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

Source

pub async fn update_upload_alt( &self, id: usize, user: &User, 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_userblock_by_id(&self, id: usize) -> Result<UserBlock>

Source

pub async fn fill_userblocks_receivers( &self, list: Vec<UserBlock>, ) -> Result<Vec<User>>

Fill a vector of user blocks with their receivers.

Source

pub async fn get_userblock_by_initiator_receiver( &self, initiator: usize, receiver: usize, ) -> Result<UserBlock>

Get a user block by initiator and receiver (in that order).

Source

pub async fn get_userblock_by_receiver_initiator( &self, receiver: usize, initiator: usize, ) -> Result<UserBlock>

Get a user block by receiver and initiator (in that order).

Source

pub async fn get_userblocks_receivers( &self, initiator: usize, associated: &Vec<usize>, do_associated: bool, ) -> Vec<usize>

Get the receiver of all user blocks for the given initiator.

Source

pub async fn get_userblocks_by_initiator( &self, initiator: usize, ) -> Vec<UserBlock>

Get all user blocks created by the given initiator.

Source

pub async fn get_userblocks_initiator_by_receivers( &self, receiver: usize, ) -> Vec<usize>

Get the owner of all user blocks for the given receiver.

Source

pub async fn create_userblock(&self, data: UserBlock) -> Result<()>

Create a new user block in the database.

§Arguments
Source

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

Source

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

Source§

impl DataManager

Source

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

Source

pub fn userfollows_user_filter( &self, x: &Vec<(UserFollow, User)>, ) -> Vec<(UserFollow, User)>

Filter to update userfollows to clean their users for public APIs.

Source

pub async fn get_userfollow_by_initiator_receiver( &self, initiator: usize, receiver: usize, ) -> Result<UserFollow>

Get a user follow by initiator and receiver (in that order).

Source

pub async fn get_userfollow_by_receiver_initiator( &self, receiver: usize, initiator: usize, ) -> Result<UserFollow>

Get a user follow by receiver and initiator (in that order).

Source

pub async fn get_userfollows_by_initiator( &self, id: usize, batch: usize, page: usize, ) -> Result<Vec<UserFollow>>

Get users the given user is following.

§Arguments
  • id - the ID of the user
  • batch - the limit of userfollows in each page
  • page - the page number
Source

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

Get users the given user is following.

§Arguments
  • id - the ID of the user
Source

pub async fn get_userfollows_by_receiver( &self, id: usize, batch: usize, page: usize, ) -> Result<Vec<UserFollow>>

Get users following the given user.

§Arguments
  • id - the ID of the user
  • batch - the limit of userfollows in each page
  • page - the page number
Source

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

Get users following the given user.

§Arguments
  • id - the ID of the user
Source

pub async fn fill_userfollows_with_receiver( &self, userfollows: Vec<UserFollow>, as_user: &Option<User>, do_check: bool, ) -> Result<Vec<(UserFollow, User)>>

Complete a vector of just userfollows with their receiver as well.

Source

pub async fn fill_userfollows_with_initiator( &self, userfollows: Vec<UserFollow>, as_user: &Option<User>, do_check: bool, ) -> Result<Vec<(UserFollow, User)>>

Complete a vector of just userfollows with their initiator as well.

Source

pub async fn create_userfollow( &self, data: UserFollow, initiator: &User, force: bool, ) -> Result<FollowResult>

Create a new user follow in the database.

§Arguments
  • data - a mock UserFollow object to insert
  • force - if we should skip the request stage
Source

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

Source

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

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> 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
Source§

impl<T> ErasedDestructor for T
where T: 'static,