Skip to main content

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_app_by_id(&self, id: &Id) -> 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: &Id) -> 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: &Id, user: &User) -> Result<()>

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source§

impl DataManager

Source

pub async fn get_audit_log_entry_by_id(&self, id: &Id) -> 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: &Id, user: User) -> Result<()>

Source§

impl DataManager

Source

pub async fn get_user_by_id(&self, id: &Id) -> 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: &Id) -> 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: &Id, 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: &Id, 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: &Id, x: bool, user: User, ) -> Result<()>

Source

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

Source

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

Source

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

Source

pub async fn update_user_awaiting_purchased_status( &self, id: &Id, 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: &Id, 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: &Id, 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 cache_clear_user(&self, user: &User)

Source

pub async fn update_user_permissions( &self, id: &Id, x: PermissionsContainer, ) -> Result<()>

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

pub async fn update_user_legacy_permissions( &self, id: &Id, 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: &Id, x: &str) -> Result<()>

Source

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

Source

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

Source

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

Source

pub async fn incr_user_follower_count(&self, id: &Id) -> Result<()>

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

pub async fn incr_user_missed_messages(&self, id: &Id) -> Result<()>

Source

pub async fn decr_user_missed_messages(&self, id: &Id) -> Result<()>

Source

pub async fn incr_profile_views(&self, id: &Id) -> Result<()>

Source

pub async fn decr_profile_views(&self, id: &Id) -> 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

pub async fn list_tables(&self) -> Result<Vec<String>>

Source§

impl DataManager

Source

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

Source

pub async fn get_drafts_by_user( &self, id: &Id, 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: &Id) -> 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<Id>

Create a new post draft in the database.

§Arguments
Source

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

Source

pub async fn update_draft_content( &self, id: &Id, 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_group_membership_by_id( &self, id: &Id, ) -> Result<GroupMembership>

Source

pub async fn get_group_membership_by_owner_group( &self, owner: &Id, group: &Id, ) -> Result<GroupMembership>

Get a membership by owner and group (in that order).

Source

pub async fn get_group_memberships_by_owner( &self, id: &Id, batch: usize, page: usize, ) -> Result<Vec<GroupMembership>>

Get group memberships by the given user.

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

pub async fn get_group_memberships_group_by_owner_all( &self, id: &Id, ) -> Result<Vec<Id>>

Get group memberships by the given user.

§Arguments
  • id - the ID of the user
Source

pub async fn get_group_memberships_by_group_role( &self, group: &Id, role: &GroupRole, batch: usize, page: usize, ) -> Result<Vec<GroupMembership>>

Get all memberships of a group by role.

Source

pub async fn create_group_membership(&self, data: GroupMembership) -> Result<()>

Create a new membership in the database.

§Arguments
Source

pub async fn delete_group_membership(&self, id: &Id) -> Result<()>

Source

pub async fn update_group_membership_role( &self, id: &Id, role: GroupRole, ) -> Result<()>

Source§

impl DataManager

Source

pub async fn get_group_by_id(&self, id: &Id) -> Result<Group>

Source

pub async fn get_group_by_name(&self, selector: &str) -> Result<Group>

Source

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

Get groups by a search query.

Source

pub async fn create_group(&self, data: Group) -> Result<Id>

Create a new group in the database.

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

pub async fn update_group_settings( &self, id: &Id, settings: GroupSettings, ) -> Result<()>

Source

pub async fn update_group_owner(&self, id: &Id, owner: Id) -> Result<()>

Source

pub async fn delete_group(&self, id: &Id) -> Result<()>

Source

pub async fn cache_clear_group(&self, c: &Group) -> bool

Source

pub async fn incr_group_members(&self, id: &Id) -> Result<()>

Source

pub async fn decr_group_members(&self, id: &Id) -> Result<()>

Source§

impl DataManager

Source

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

Source

pub async fn get_ip_ban_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_ip_ban(&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_ip_ban(&self, ip: &str, user: User) -> Result<()>

Source§

impl DataManager

Source

pub async fn get_ip_block_by_id(&self, id: &Id) -> Result<IpBlock>

Source

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

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

Source

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

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

Source

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

Get all ip blocks by initiator.

Source

pub async fn create_ip_block(&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_ip_block(&self, id: &Id, user: User) -> Result<()>

Source§

impl DataManager

Source

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

Source

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

Get all notifications by owner.

Source

pub async fn get_notifications_by_owner_paginated( &self, owner: &Id, 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: &Id, 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: &Id, 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_vote_by_id(&self, id: &Id) -> Result<PollVote>

Source

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

Source

pub async fn create_poll_vote(&self, data: PollVote) -> Result<Id>

Create a new poll vote in the database.

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

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

Source§

impl DataManager

Source

pub async fn get_poll_by_id(&self, id: &Id) -> Result<Poll>

Source

pub async fn get_polls_by_owner_all(&self, owner: Id) -> 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<Id>

Create a new poll in the database.

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

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source§

impl DataManager

Source

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

Source

pub async fn get_replies_by_post( &self, id: &Id, batch: usize, page: usize, ) -> 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_posts_by_user( &self, id: &Id, 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_posts_by_group( &self, id: &Id, batch: usize, page: usize, ) -> Result<Vec<Post>>

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

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

Get all posts from the given user (sorted by likes - dislikes).

§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: &Id, 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: &Id, 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: &Id, 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: &Id, text_query: &str, batch: usize, page: usize, 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, text_query: &str, batch: usize, page: usize, ) -> Result<Vec<Post>>

Get all post (searched).

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

pub async fn get_posts_by_user_tag( &self, id: &Id, 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: &Id, 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_pinned_posts_by_user(&self, id: &Id) -> 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: &Id, 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: &Id, question: &Id, ) -> 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: &Id, 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: &Id, 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
  • before - the timestamp to pull posts before
  • cutoff - the maximum number of milliseconds ago the post could have been created
Source

pub async fn get_latest_posts( &self, as_user: &Option<&User>, batch: usize, page: 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_posts_from_user_following( &self, id: &Id, 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_user_groups( &self, id: &Id, batch: usize, page: usize, ) -> Result<Vec<Post>>

Get posts from all groups the 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 create_post(&self, data: Post) -> Result<Id>

Create a new post in the database.

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

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

pub async fn incr_post_views(&self, id: &Id) -> Result<()>

Source

pub async fn decr_post_views(&self, id: &Id) -> Result<()>

Source§

impl DataManager

Source

pub async fn get_question_by_id(&self, id: &Id) -> 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>, as_user: &Option<&User>, ignore_users: &[Id], ) -> 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: &[(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: Id) -> Result<Vec<Question>>

Get all questions by owner.

Source

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

Get all questions by owner (paginated).

Source

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

Get all questions by receiver.

Source

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

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

Source

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

Get global questions, sorted by creation.

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

Get global questions, 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<Id>

Create a new question in the database.

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

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source§

impl DataManager

Source

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

Source

pub async fn fill_reactions( &self, reactions: &Vec<Reaction>, ignore_users: Vec<Id>, ) -> 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: &Id, asset: &Id, ) -> 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: &Id, user: &User) -> Result<()>

Source§

impl DataManager

Source

pub async fn get_report_by_id(&self, id: &Id) -> 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: &Id, user: User) -> Result<()>

Source§

impl DataManager

Source

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

Source

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

Get all action requests by owner.

Source

pub async fn get_requests_by_owner_paginated( &self, owner: &Id, 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: &Id, linked_asset: &Id, user: &User, force: bool, ) -> Result<()>

Source

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

Source§

impl DataManager

Source

pub async fn get_user_block_by_id(&self, id: &Id) -> Result<UserBlock>

Source

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

Fill a vector of user blocks with their receivers.

Source

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

Get a user block by its users.

Source

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

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

Source

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

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

Source

pub async fn get_user_blocks_receivers(&self, initiator: &Id) -> Vec<Id>

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

Source

pub async fn get_user_blocks_by_initiator( &self, initiator: &Id, batch: usize, page: usize, ) -> Vec<UserBlock>

Get all user blocks created by the given initiator.

Source

pub async fn get_user_blocks_initiator_by_receivers( &self, receiver: &Id, ) -> Vec<Id>

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

Source

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

Create a new user block in the database.

§Arguments
Source

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

Source

pub async fn delete_user_block_forced(&self, id: &Id) -> Result<()>

Source§

impl DataManager

Source

pub async fn get_user_follow_by_id(&self, id: &Id) -> Result<UserFollow>

Source

pub fn user_follows_user_filter( &self, x: &[(UserFollow, User)], ) -> Vec<(UserFollow, User)>

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

Source

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

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

Source

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

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

Source

pub async fn get_user_follows_by_initiator( &self, id: &Id, 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 user_follows in each page
  • page - the page number
Source

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

Get users the given user is following.

§Arguments
  • id - the ID of the user
Source

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

Get users following the given user.

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

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

Get users following the given user.

§Arguments
  • id - the ID of the user
Source

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

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

Source

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

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

Source

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

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_user_follow( &self, id: &Id, user: &User, is_deleting_user: bool, ) -> Result<()>

Source

pub async fn delete_user_follow_forced( &self, id: &Id, user_id: &Id, ) -> Result<()>

Source§

impl DataManager

Source

pub async fn get_user_warning_by_id(&self, id: &Id) -> Result<UserWarning>

Source

pub async fn get_user_warnings_by_user( &self, user: &Id, 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: &Id, user: User) -> 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> 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