pub struct DataManager(pub DataManager<Config>, pub DataManager);Tuple Fields§
§0: DataManager<Config>§1: DataManagerImplementations§
Source§impl DataManager
impl DataManager
pub async fn get_app_by_id(&self, id: &Id) -> Result<ThirdPartyApp>
pub async fn get_app_by_api_key(&self, selector: &str) -> Result<ThirdPartyApp>
Sourcepub async fn get_apps_by_owner(&self, id: &Id) -> Result<Vec<ThirdPartyApp>>
pub async fn get_apps_by_owner(&self, id: &Id) -> Result<Vec<ThirdPartyApp>>
Sourcepub async fn create_app(&self, data: ThirdPartyApp) -> Result<ThirdPartyApp>
pub async fn create_app(&self, data: ThirdPartyApp) -> Result<ThirdPartyApp>
pub async fn delete_app(&self, id: &Id, user: &User) -> Result<()>
pub async fn cache_clear_app(&self, app: &ThirdPartyApp)
pub async fn update_app_title( &self, id: &Id, user: &User, x: &str, ) -> Result<()>
pub async fn update_app_homepage( &self, id: &Id, user: &User, x: &str, ) -> Result<()>
pub async fn update_app_redirect( &self, id: &Id, user: &User, x: &str, ) -> Result<()>
pub async fn update_app_scopes( &self, id: &Id, user: &User, x: Vec<AppScope>, ) -> Result<()>
pub async fn update_app_api_key(&self, id: &Id, x: &str) -> Result<()>
pub async fn update_app_data_used(&self, id: &Id, x: i32) -> Result<()>
pub async fn add_app_data_used(&self, id: &Id, x: i32) -> Result<()>
pub async fn incr_app_grants(&self, id: &Id) -> Result<()>
pub async fn decr_app_grants(&self, id: &Id) -> Result<()>
Source§impl DataManager
impl DataManager
pub async fn get_audit_log_entry_by_id(&self, id: &Id) -> Result<AuditLogEntry>
Sourcepub async fn get_audit_log_entries(
&self,
batch: usize,
page: usize,
) -> Result<Vec<AuditLogEntry>>
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 pagepage- the page number
Sourcepub async fn create_audit_log_entry(&self, data: AuditLogEntry) -> Result<()>
pub async fn create_audit_log_entry(&self, data: AuditLogEntry) -> Result<()>
Create a new audit log entry in the database.
§Arguments
data- a mockAuditLogEntryobject to insert
pub async fn delete_audit_log_entry(&self, id: &Id, user: User) -> Result<()>
Source§impl DataManager
impl DataManager
pub async fn get_user_by_id(&self, id: &Id) -> Result<User>
pub async fn get_user_by_username(&self, selector: &str) -> Result<User>
pub async fn get_user_by_username_no_cache( &self, selector: &str, ) -> Result<User>
pub async fn get_user_by_browser_session(&self, selector: &str) -> Result<User>
Sourcepub async fn get_user_by_id_with_void(&self, id: &Id) -> Result<User>
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
Sourcepub async fn get_user_by_token(&self, token: &str) -> Result<User>
pub async fn get_user_by_token(&self, token: &str) -> Result<User>
Sourcepub async fn get_user_by_grant_token(
&self,
token: &Id,
check_expiration: bool,
) -> Result<(AuthGrant, User)>
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
Sourcepub async fn create_user(&self, data: User) -> Result<()>
pub async fn create_user(&self, data: User) -> Result<()>
Sourcepub async fn delete_user(
&self,
id: &Id,
password: &str,
force: bool,
) -> Result<User>
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 userpassword- the current password of the userforce- if we should delete even if the given password is incorrect
pub async fn update_user_verified_status( &self, id: &Id, x: bool, user: User, ) -> Result<()>
pub async fn update_user_is_deactivated( &self, id: &Id, x: bool, user: User, ) -> Result<()>
pub async fn update_user_password( &self, id: &Id, from: String, to: String, user: User, force: bool, ) -> Result<()>
pub async fn update_user_username( &self, id: &Id, to: String, user: User, ) -> Result<()>
pub async fn update_user_awaiting_purchased_status( &self, id: &Id, x: bool, user: User, require_permission: bool, ) -> Result<()>
pub async fn seen_user(&self, user: &User) -> Result<()>
Sourcepub 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,
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.
Sourcepub fn fill_achievements(
&self,
list: Vec<Achievement>,
) -> Vec<(String, String, AchievementRarity, Achievement)>
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)
Sourcepub fn check_totp(&self, ua: &User, code: &str) -> bool
pub fn check_totp(&self, ua: &User, code: &str) -> bool
Validate a given TOTP code for the given profile.
Sourcepub fn generate_totp_recovery_codes() -> Vec<String>
pub fn generate_totp_recovery_codes() -> Vec<String>
Generate 8 random recovery codes for TOTP.
Sourcepub async fn update_user_totp(
&self,
id: &Id,
secret: &str,
recovery: &Vec<String>,
) -> Result<()>
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 usersecret- the TOTP secretrecovery- the TOTP recovery codes
Sourcepub async fn enable_totp(
&self,
id: &Id,
user: User,
) -> Result<(String, String, Vec<String>)>
pub async fn enable_totp( &self, id: &Id, user: User, ) -> Result<(String, String, Vec<String>)>
pub async fn cache_clear_user(&self, user: &User)
pub async fn update_user_permissions( &self, id: &Id, x: PermissionsContainer, ) -> Result<()>
pub async fn update_user_tokens(&self, id: &Id, x: Vec<Token>) -> Result<()>
pub async fn update_user_grants(&self, id: &Id, x: Vec<AuthGrant>) -> Result<()>
pub async fn update_user_settings(&self, id: &Id, x: UserSettings) -> Result<()>
pub async fn update_user_connections( &self, id: &Id, x: UserConnections, ) -> Result<()>
pub async fn update_user_associated(&self, id: &Id, x: Vec<Id>) -> Result<()>
pub async fn update_user_achievements( &self, id: &Id, x: Vec<Achievement>, ) -> Result<()>
pub async fn update_user_ban_reason(&self, id: &Id, x: &str) -> Result<()>
pub async fn update_user_channel_mutes( &self, id: &Id, x: Vec<usize>, ) -> Result<()>
pub async fn update_user_ban_expire(&self, id: &Id, x: i64) -> Result<()>
pub async fn update_user_checkouts(&self, id: &Id, x: Vec<String>) -> Result<()>
pub async fn update_user_last_policy_consent( &self, id: &Id, x: i64, ) -> Result<()>
pub async fn update_user_close_friends_stack( &self, id: &Id, x: i64, ) -> Result<()>
pub async fn update_user_shrimpcamp_link(&self, id: &Id, x: i64) -> Result<()>
pub async fn update_user_legacy_permissions( &self, id: &Id, x: i32, ) -> Result<()>
pub async fn get_user_by_stripe_id(&self, selector: &str) -> Result<User>
pub async fn update_user_stripe_id(&self, id: &Id, x: &str) -> Result<()>
pub async fn update_user_notification_count( &self, id: &Id, x: i32, ) -> Result<()>
pub async fn incr_user_notifications(&self, id: &Id) -> Result<()>
pub async fn decr_user_notifications(&self, id: &Id) -> Result<()>
pub async fn incr_user_follower_count(&self, id: &Id) -> Result<()>
pub async fn decr_user_follower_count(&self, id: &Id) -> Result<()>
pub async fn incr_user_following_count(&self, id: &Id) -> Result<()>
pub async fn decr_user_following_count(&self, id: &Id) -> Result<()>
pub async fn incr_user_post_count(&self, id: &Id) -> Result<()>
pub async fn decr_user_post_count(&self, id: &Id) -> Result<()>
pub async fn update_user_request_count(&self, id: &Id, x: i32) -> Result<()>
pub async fn incr_user_request_count(&self, id: &Id) -> Result<()>
pub async fn decr_user_request_count(&self, id: &Id) -> Result<()>
pub async fn update_user_missed_messages_count( &self, id: &Id, x: i32, ) -> Result<()>
pub async fn incr_user_missed_messages(&self, id: &Id) -> Result<()>
pub async fn decr_user_missed_messages(&self, id: &Id) -> Result<()>
pub async fn incr_profile_views(&self, id: &Id) -> Result<()>
pub async fn decr_profile_views(&self, id: &Id) -> Result<()>
Source§impl DataManager
impl DataManager
Source§impl DataManager
impl DataManager
pub async fn get_draft_by_id(&self, id: &Id) -> Result<PostDraft>
Sourcepub async fn get_drafts_by_user(
&self,
id: &Id,
batch: usize,
page: usize,
) -> Result<Vec<PostDraft>>
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 tobatch- the limit of posts in each pagepage- the page number
Sourcepub async fn get_drafts_by_user_all(&self, id: &Id) -> Result<Vec<PostDraft>>
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
Sourcepub async fn create_draft(&self, data: PostDraft) -> Result<Id>
pub async fn create_draft(&self, data: PostDraft) -> Result<Id>
pub async fn delete_draft(&self, id: &Id, user: User) -> Result<()>
pub async fn update_draft_content( &self, id: &Id, user: User, x: String, ) -> Result<()>
Source§impl DataManager
impl DataManager
Sourcepub async fn new(config: Config) -> Result<Self>
pub async fn new(config: Config) -> Result<Self>
Create a new DataManager.
Source§impl DataManager
impl DataManager
pub async fn get_group_membership_by_id( &self, id: &Id, ) -> Result<GroupMembership>
Sourcepub async fn get_group_membership_by_owner_group(
&self,
owner: &Id,
group: &Id,
) -> Result<GroupMembership>
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).
Sourcepub async fn get_group_memberships_by_owner(
&self,
id: &Id,
batch: usize,
page: usize,
) -> Result<Vec<GroupMembership>>
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 userbatch- the limit of group memberships in each pagepage- the page number
Sourcepub async fn get_group_memberships_by_group_role(
&self,
group: &Id,
role: &GroupRole,
batch: usize,
page: usize,
) -> Result<Vec<GroupMembership>>
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.
Sourcepub async fn create_group_membership(&self, data: GroupMembership) -> Result<()>
pub async fn create_group_membership(&self, data: GroupMembership) -> Result<()>
pub async fn delete_group_membership(&self, id: &Id) -> Result<()>
pub async fn update_group_membership_role( &self, id: &Id, role: GroupRole, ) -> Result<()>
Source§impl DataManager
impl DataManager
pub async fn get_group_by_id(&self, id: &Id) -> Result<Group>
pub async fn get_group_by_name(&self, selector: &str) -> Result<Group>
Sourcepub async fn get_groups_searched(
&self,
query: &str,
batch: usize,
page: usize,
) -> Result<Vec<Group>>
pub async fn get_groups_searched( &self, query: &str, batch: usize, page: usize, ) -> Result<Vec<Group>>
Get groups by a search query.
Sourcepub async fn create_group(&self, data: Group) -> Result<Id>
pub async fn create_group(&self, data: Group) -> Result<Id>
pub async fn update_group_settings( &self, id: &Id, settings: GroupSettings, ) -> Result<()>
pub async fn update_group_owner(&self, id: &Id, owner: Id) -> Result<()>
pub async fn delete_group(&self, id: &Id) -> Result<()>
pub async fn cache_clear_group(&self, c: &Group) -> bool
pub async fn incr_group_members(&self, id: &Id) -> Result<()>
pub async fn decr_group_members(&self, id: &Id) -> Result<()>
Source§impl DataManager
impl DataManager
pub async fn get_ip_ban_by_ip(&self, selector: &str) -> Result<IpBan>
Sourcepub async fn get_ip_ban_by_addr(&self, addr: &RemoteAddr) -> Result<IpBan>
pub async fn get_ip_ban_by_addr(&self, addr: &RemoteAddr) -> Result<IpBan>
Sourcepub async fn get_ip_bans(&self, batch: usize, page: usize) -> Result<Vec<IpBan>>
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 pagepage- the page number
Sourcepub async fn create_ip_ban(&self, data: IpBan) -> Result<()>
pub async fn create_ip_ban(&self, data: IpBan) -> Result<()>
pub async fn delete_ip_ban(&self, ip: &str, user: User) -> Result<()>
Source§impl DataManager
impl DataManager
pub async fn get_ip_block_by_id(&self, id: &Id) -> Result<IpBlock>
Sourcepub async fn get_ip_block_by_initiator_receiver(
&self,
initiator: &Id,
receiver: &RemoteAddr,
) -> Result<IpBlock>
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).
Sourcepub async fn get_ip_block_by_receiver_initiator(
&self,
receiver: &str,
initiator: &Id,
) -> Result<IpBlock>
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).
Sourcepub async fn get_ip_blocks_by_initiator(
&self,
initiator: &Id,
) -> Result<Vec<IpBlock>>
pub async fn get_ip_blocks_by_initiator( &self, initiator: &Id, ) -> Result<Vec<IpBlock>>
Get all ip blocks by initiator.
Sourcepub async fn create_ip_block(&self, data: IpBlock) -> Result<()>
pub async fn create_ip_block(&self, data: IpBlock) -> Result<()>
pub async fn delete_ip_block(&self, id: &Id, user: User) -> Result<()>
Source§impl DataManager
impl DataManager
pub async fn get_notification_by_id(&self, id: &Id) -> Result<Notification>
Sourcepub async fn get_notifications_by_owner(
&self,
owner: &Id,
) -> Result<Vec<Notification>>
pub async fn get_notifications_by_owner( &self, owner: &Id, ) -> Result<Vec<Notification>>
Get all notifications by owner.
Sourcepub async fn get_notifications_by_owner_paginated(
&self,
owner: &Id,
batch: usize,
page: usize,
) -> Result<Vec<Notification>>
pub async fn get_notifications_by_owner_paginated( &self, owner: &Id, batch: usize, page: usize, ) -> Result<Vec<Notification>>
Get all notifications by owner (paginated).
Sourcepub async fn get_notifications_by_tag(
&self,
tag: &str,
) -> Result<Vec<Notification>>
pub async fn get_notifications_by_tag( &self, tag: &str, ) -> Result<Vec<Notification>>
Get all notifications by tag.
Sourcepub async fn create_notification(&self, data: Notification) -> Result<()>
pub async fn create_notification(&self, data: Notification) -> Result<()>
pub async fn delete_notification(&self, id: &Id, user: &User) -> Result<()>
pub async fn delete_all_notifications(&self, user: &User) -> Result<()>
pub async fn delete_all_notifications_by_tag( &self, user: &User, tag: &str, ) -> Result<()>
pub async fn update_notification_read( &self, id: &Id, new_read: bool, user: &User, ) -> Result<()>
pub async fn update_all_notifications_read( &self, user: &User, read: bool, ) -> Result<()>
Source§impl DataManager
impl DataManager
pub async fn get_poll_vote_by_id(&self, id: &Id) -> Result<PollVote>
pub async fn get_poll_vote_by_owner_poll( &self, id: &Id, poll_id: &Id, ) -> Result<PollVote>
Sourcepub async fn create_poll_vote(&self, data: PollVote) -> Result<Id>
pub async fn create_poll_vote(&self, data: PollVote) -> Result<Id>
pub async fn delete_poll_vote(&self, id: &Id, user: User) -> Result<()>
Source§impl DataManager
impl DataManager
pub async fn get_poll_by_id(&self, id: &Id) -> Result<Poll>
Sourcepub async fn create_poll(&self, data: Poll) -> Result<Id>
pub async fn create_poll(&self, data: Poll) -> Result<Id>
pub async fn delete_poll(&self, id: &Id, user: &User) -> Result<()>
pub async fn cache_clear_poll(&self, poll: &Poll)
pub async fn incr_votes_a_count(&self, id: &Id) -> Result<()>
pub async fn decr_votes_a_count(&self, id: &Id) -> Result<()>
pub async fn incr_votes_b_count(&self, id: &Id) -> Result<()>
pub async fn decr_votes_b_count(&self, id: &Id) -> Result<()>
pub async fn incr_votes_c_count(&self, id: &Id) -> Result<()>
pub async fn decr_votes_c_count(&self, id: &Id) -> Result<()>
pub async fn incr_votes_d_count(&self, id: &Id) -> Result<()>
pub async fn decr_votes_d_count(&self, id: &Id) -> Result<()>
Source§impl DataManager
impl DataManager
pub async fn get_post_by_id(&self, id: &Id) -> Result<Post>
Sourcepub async fn get_replies_by_post(
&self,
id: &Id,
batch: usize,
page: usize,
) -> Result<Vec<Post>>
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 onbatch- the limit of posts in each pagepage- the page number
Sourcepub async fn get_posts_by_user(
&self,
id: &Id,
batch: usize,
page: usize,
) -> Result<Vec<Post>>
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 tobatch- the limit of posts in each pagepage- the page number
Sourcepub async fn get_posts_by_group(
&self,
id: &Id,
batch: usize,
page: usize,
) -> Result<Vec<Post>>
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 tobatch- the limit of posts in each pagepage- the page number
Sourcepub async fn get_popular_posts_by_user(
&self,
id: &Id,
batch: usize,
page: usize,
) -> Result<Vec<Post>>
pub async fn get_popular_posts_by_user( &self, id: &Id, batch: usize, page: usize, ) -> Result<Vec<Post>>
Get all posts from the given user (sorted by likes - dislikes).
§Arguments
id- the ID of the user the requested posts belong tobatch- the limit of posts in each pagepage- the page number
Sourcepub async fn get_responses_by_user(
&self,
id: &Id,
batch: usize,
page: usize,
) -> Result<Vec<Post>>
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 tobatch- the limit of posts in each pagepage- the page number
Sourcepub async fn get_replies_by_user(
&self,
id: &Id,
batch: usize,
page: usize,
user: &Option<User>,
) -> Result<Vec<Post>>
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 tobatch- the limit of posts in each pagepage- the page number
Sourcepub async fn get_media_posts_by_user(
&self,
id: &Id,
batch: usize,
page: usize,
user: &Option<User>,
) -> Result<Vec<Post>>
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 tobatch- the limit of posts in each pagepage- the page number
Sourcepub async fn get_posts_by_user_searched(
&self,
id: &Id,
text_query: &str,
batch: usize,
page: usize,
user: &Option<&User>,
) -> Result<Vec<Post>>
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 tobatch- the limit of posts in each pagepage- the page numbertext_query- the search queryuser- the user who is viewing the posts
Sourcepub async fn get_posts_searched(
&self,
text_query: &str,
batch: usize,
page: usize,
) -> Result<Vec<Post>>
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 querybatch- the limit of posts in each pagepage- the page number
Sourcepub async fn get_posts_by_user_tag(
&self,
id: &Id,
tag: &str,
batch: usize,
page: usize,
) -> Result<Vec<Post>>
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 totag- the tag to filter bybatch- the limit of posts in each pagepage- the page number
Sourcepub async fn get_responses_by_user_tag(
&self,
id: &Id,
tag: &str,
batch: usize,
page: usize,
) -> Result<Vec<Post>>
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 totag- the tag to filter bybatch- the limit of posts in each pagepage- the page number
Sourcepub async fn get_pinned_posts_by_user(&self, id: &Id) -> Result<Vec<Post>>
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
Sourcepub async fn get_posts_by_question(
&self,
id: &Id,
batch: usize,
page: usize,
) -> Result<Vec<Post>>
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 tobatch- the limit of posts in each pagepage- the page number
Sourcepub async fn get_post_by_owner_question(
&self,
owner: &Id,
question: &Id,
) -> Result<Post>
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 ownerquestion- the ID of the post question
Sourcepub async fn get_quoting_posts_by_quoting(
&self,
id: &Id,
batch: usize,
page: usize,
) -> Result<Vec<Post>>
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 quotedbatch- the limit of posts in each pagepage- the page number
Sourcepub async fn get_reposts_by_quoting(
&self,
id: &Id,
batch: usize,
page: usize,
) -> Result<Vec<Post>>
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 quotedbatch- the limit of posts in each pagepage- the page number
Sourcepub async fn get_popular_posts(
&self,
batch: usize,
before: usize,
cutoff: usize,
) -> Result<Vec<Post>>
pub async fn get_popular_posts( &self, batch: usize, before: usize, cutoff: usize, ) -> Result<Vec<Post>>
Get posts from all communities, sorted by likes.
§Arguments
batch- the limit of posts in each pagebefore- the timestamp to pull posts beforecutoff- the maximum number of milliseconds ago the post could have been created
Sourcepub async fn get_latest_posts(
&self,
as_user: &Option<&User>,
batch: usize,
page: usize,
) -> Result<Vec<Post>>
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 pagepage- the page number
Sourcepub async fn get_posts_from_user_following(
&self,
id: &Id,
batch: usize,
page: usize,
) -> Result<Vec<Post>>
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 userbatch- the limit of posts in each pagepage- the page number
Sourcepub async fn get_posts_from_user_groups(
&self,
id: &Id,
batch: usize,
page: usize,
) -> Result<Vec<Post>>
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 userbatch- the limit of posts in each pagepage- the page number
Sourcepub async fn create_post(&self, data: Post) -> Result<Id>
pub async fn create_post(&self, data: Post) -> Result<Id>
pub async fn delete_post(&self, id: &Id, user: User) -> Result<()>
pub async fn fake_delete_post( &self, id: &Id, user: User, is_deleted: bool, ) -> Result<()>
pub async fn update_post_context( &self, id: &Id, user: User, x: PostContext, ) -> Result<()>
pub async fn update_post_content( &self, id: &Id, user: User, x: String, ) -> Result<()>
pub async fn incr_post_likes(&self, id: &Id) -> Result<()>
pub async fn incr_post_dislikes(&self, id: &Id) -> Result<()>
pub async fn decr_post_likes(&self, id: &Id) -> Result<()>
pub async fn decr_post_dislikes(&self, id: &Id) -> Result<()>
pub async fn incr_post_comments(&self, id: &Id) -> Result<()>
pub async fn decr_post_comments(&self, id: &Id) -> Result<()>
pub async fn incr_post_views(&self, id: &Id) -> Result<()>
pub async fn decr_post_views(&self, id: &Id) -> Result<()>
Source§impl DataManager
impl DataManager
pub async fn get_question_by_id(&self, id: &Id) -> Result<Question>
Sourcepub async fn get_question_asking_about(
&self,
question: &Question,
) -> Result<Option<(User, Post)>>
pub async fn get_question_asking_about( &self, question: &Question, ) -> Result<Option<(User, Post)>>
Get the post a given question is asking about.
Sourcepub async fn fill_questions(
&self,
questions: Vec<Question>,
as_user: &Option<&User>,
ignore_users: &[Id],
) -> Result<Vec<(Question, User, Option<(User, Post)>)>>
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.
Sourcepub fn questions_owner_filter(
&self,
questions: &[(Question, User, Option<(User, Post)>)],
) -> Vec<(Question, User, Option<(User, Post)>)>
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.
Sourcepub async fn get_questions_by_owner(&self, owner: Id) -> Result<Vec<Question>>
pub async fn get_questions_by_owner(&self, owner: Id) -> Result<Vec<Question>>
Get all questions by owner.
Sourcepub async fn get_questions_by_owner_paginated(
&self,
owner: Id,
batch: usize,
page: usize,
) -> Result<Vec<Question>>
pub async fn get_questions_by_owner_paginated( &self, owner: Id, batch: usize, page: usize, ) -> Result<Vec<Question>>
Get all questions by owner (paginated).
Sourcepub async fn get_questions_by_receiver(
&self,
receiver: &Id,
) -> Result<Vec<Question>>
pub async fn get_questions_by_receiver( &self, receiver: &Id, ) -> Result<Vec<Question>>
Get all questions by receiver.
Sourcepub async fn get_questions_from_user_following(
&self,
id: &Id,
batch: usize,
page: usize,
) -> Result<Vec<Question>>
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.
Sourcepub async fn get_latest_global_questions(
&self,
batch: usize,
page: usize,
) -> Result<Vec<Question>>
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 pagepage- the page number
Sourcepub async fn get_popular_global_questions(
&self,
batch: usize,
page: usize,
cutoff: usize,
) -> Result<Vec<Question>>
pub async fn get_popular_global_questions( &self, batch: usize, page: usize, cutoff: usize, ) -> Result<Vec<Question>>
Get global questions, sorted by likes.
§Arguments
batch- the limit of questions in each pagepage- the page numbercutoff- the maximum number of milliseconds ago the question could have been created
pub async fn delete_question(&self, id: &Id, user: &User) -> Result<()>
pub async fn delete_all_questions(&self, user: &User) -> Result<()>
pub async fn incr_question_answer_count(&self, id: &Id) -> Result<()>
pub async fn decr_question_answer_count(&self, id: &Id) -> Result<()>
pub async fn incr_question_likes(&self, id: &Id) -> Result<()>
pub async fn incr_question_dislikes(&self, id: &Id) -> Result<()>
pub async fn decr_question_likes(&self, id: &Id) -> Result<()>
pub async fn decr_question_dislikes(&self, id: &Id) -> Result<()>
Source§impl DataManager
impl DataManager
pub async fn get_reaction_by_id(&self, id: &Id) -> Result<Reaction>
Sourcepub async fn fill_reactions(
&self,
reactions: &Vec<Reaction>,
ignore_users: Vec<Id>,
) -> Result<Vec<(Reaction, User)>>
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.
Sourcepub async fn get_reactions_by_asset(
&self,
asset: usize,
batch: usize,
page: usize,
) -> Result<Vec<Reaction>>
pub async fn get_reactions_by_asset( &self, asset: usize, batch: usize, page: usize, ) -> Result<Vec<Reaction>>
Get all reactions by their asset.
Sourcepub async fn get_likes_reactions_by_asset(
&self,
asset: usize,
batch: usize,
page: usize,
) -> Result<Vec<Reaction>>
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.
Sourcepub async fn get_reaction_by_owner_asset(
&self,
owner: &Id,
asset: &Id,
) -> Result<Reaction>
pub async fn get_reaction_by_owner_asset( &self, owner: &Id, asset: &Id, ) -> Result<Reaction>
Get a reaction by owner and asset.
Sourcepub async fn create_reaction(
&self,
data: Reaction,
user: &User,
addr: &RemoteAddr,
) -> Result<()>
pub async fn create_reaction( &self, data: Reaction, user: &User, addr: &RemoteAddr, ) -> Result<()>
pub async fn delete_reaction(&self, id: &Id, user: &User) -> Result<()>
Source§impl DataManager
impl DataManager
pub async fn get_report_by_id(&self, id: &Id) -> Result<Report>
Sourcepub async fn get_reports(
&self,
batch: usize,
page: usize,
) -> Result<Vec<Report>>
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 pagepage- the page number
Sourcepub async fn create_report(&self, data: Report) -> Result<()>
pub async fn create_report(&self, data: Report) -> Result<()>
pub async fn delete_report(&self, id: &Id, user: User) -> Result<()>
Source§impl DataManager
impl DataManager
pub async fn get_request_by_id_linked_asset( &self, id: &Id, linked_asset: &Id, ) -> Result<ActionRequest>
Sourcepub async fn get_requests_by_owner(
&self,
owner: &Id,
) -> Result<Vec<ActionRequest>>
pub async fn get_requests_by_owner( &self, owner: &Id, ) -> Result<Vec<ActionRequest>>
Get all action requests by owner.
Sourcepub async fn get_requests_by_owner_paginated(
&self,
owner: &Id,
batch: usize,
page: usize,
) -> Result<Vec<ActionRequest>>
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).
Sourcepub async fn create_request(&self, data: ActionRequest) -> Result<()>
pub async fn create_request(&self, data: ActionRequest) -> Result<()>
pub async fn delete_request( &self, id: &Id, linked_asset: &Id, user: &User, force: bool, ) -> Result<()>
pub async fn delete_all_requests(&self, user: &User) -> Result<()>
Source§impl DataManager
impl DataManager
pub async fn get_user_block_by_id(&self, id: &Id) -> Result<UserBlock>
Sourcepub async fn fill_user_blocks_receivers(
&self,
list: Vec<UserBlock>,
) -> Result<Vec<(UserBlock, User)>>
pub async fn fill_user_blocks_receivers( &self, list: Vec<UserBlock>, ) -> Result<Vec<(UserBlock, User)>>
Fill a vector of user blocks with their receivers.
Sourcepub async fn get_user_block_by_users(
&self,
initiator: &Id,
receiver: &Id,
) -> Result<UserBlock>
pub async fn get_user_block_by_users( &self, initiator: &Id, receiver: &Id, ) -> Result<UserBlock>
Get a user block by its users.
Sourcepub async fn get_user_block_by_initiator_receiver(
&self,
initiator: &Id,
receiver: &Id,
) -> Result<UserBlock>
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).
Sourcepub async fn get_user_block_by_receiver_initiator(
&self,
receiver: &Id,
initiator: &Id,
) -> Result<UserBlock>
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).
Sourcepub async fn get_user_blocks_receivers(&self, initiator: &Id) -> Vec<Id>
pub async fn get_user_blocks_receivers(&self, initiator: &Id) -> Vec<Id>
Get the receiver of all user blocks for the given initiator.
Sourcepub async fn get_user_blocks_by_initiator(
&self,
initiator: &Id,
batch: usize,
page: usize,
) -> Vec<UserBlock>
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.
Sourcepub async fn get_user_blocks_initiator_by_receivers(
&self,
receiver: &Id,
) -> Vec<Id>
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.
Sourcepub async fn create_user_block(&self, data: UserBlock) -> Result<()>
pub async fn create_user_block(&self, data: UserBlock) -> Result<()>
pub async fn delete_user_block(&self, id: &Id, user: User) -> Result<()>
pub async fn delete_user_block_forced(&self, id: &Id) -> Result<()>
Source§impl DataManager
impl DataManager
pub async fn get_user_follow_by_id(&self, id: &Id) -> Result<UserFollow>
Sourcepub fn user_follows_user_filter(
&self,
x: &[(UserFollow, User)],
) -> Vec<(UserFollow, User)>
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.
Sourcepub async fn get_user_follow_by_initiator_receiver(
&self,
initiator: &Id,
receiver: &Id,
) -> Result<UserFollow>
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).
Sourcepub async fn get_user_follow_by_receiver_initiator(
&self,
receiver: &Id,
initiator: &Id,
) -> Result<UserFollow>
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).
Sourcepub async fn get_user_follows_by_initiator(
&self,
id: &Id,
batch: usize,
page: usize,
) -> Result<Vec<UserFollow>>
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 userbatch- the limit of user_follows in each pagepage- the page number
Sourcepub async fn get_user_follows_by_initiator_all(
&self,
id: &Id,
) -> Result<Vec<UserFollow>>
pub async fn get_user_follows_by_initiator_all( &self, id: &Id, ) -> Result<Vec<UserFollow>>
Sourcepub async fn get_user_follows_by_receiver(
&self,
id: &Id,
batch: usize,
page: usize,
) -> Result<Vec<UserFollow>>
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 userbatch- the limit of user_follows in each pagepage- the page number
Sourcepub async fn get_user_follows_by_receiver_all(
&self,
id: &Id,
) -> Result<Vec<UserFollow>>
pub async fn get_user_follows_by_receiver_all( &self, id: &Id, ) -> Result<Vec<UserFollow>>
Sourcepub async fn fill_user_follows_with_receiver(
&self,
user_follows: Vec<UserFollow>,
as_user: &Option<User>,
do_check: bool,
) -> Result<Vec<(UserFollow, User)>>
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.
Sourcepub async fn fill_user_follows_with_initiator(
&self,
user_follows: Vec<UserFollow>,
as_user: &Option<User>,
do_check: bool,
) -> Result<Vec<(UserFollow, User)>>
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.
Sourcepub async fn create_user_follow(
&self,
data: UserFollow,
initiator: &User,
force: bool,
) -> Result<bool>
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 mockUserFollowobject to insertforce- if we should skip the request stage
pub async fn delete_user_follow( &self, id: &Id, user: &User, is_deleting_user: bool, ) -> Result<()>
pub async fn delete_user_follow_forced( &self, id: &Id, user_id: &Id, ) -> Result<()>
Source§impl DataManager
impl DataManager
pub async fn get_user_warning_by_id(&self, id: &Id) -> Result<UserWarning>
Sourcepub async fn get_user_warnings_by_user(
&self,
user: &Id,
batch: usize,
page: usize,
) -> Result<Vec<UserWarning>>
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 forbatch- the limit of items in each pagepage- the page number
Sourcepub async fn create_user_warning(&self, data: UserWarning) -> Result<()>
pub async fn create_user_warning(&self, data: UserWarning) -> Result<()>
pub async fn delete_user_warning(&self, id: &Id, user: User) -> Result<()>
Trait Implementations§
Source§impl Clone for DataManager
impl Clone for DataManager
Source§fn clone(&self) -> DataManager
fn clone(&self) -> DataManager
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for DataManager
impl !RefUnwindSafe for DataManager
impl Send for DataManager
impl Sync for DataManager
impl Unpin for DataManager
impl UnsafeUnpin for DataManager
impl !UnwindSafe for DataManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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