pub struct DataManager(pub DataManager<Config>, pub HashMap<String, LangFile>, pub DataManager);
Tuple Fields§
§0: DataManager<Config>
§1: HashMap<String, LangFile>
§2: DataManager
Implementations§
Source§impl DataManager
impl DataManager
pub async fn get_app_data_by_id(&self, selector: usize) -> Result<AppData>
Sourcepub async fn query_app_data(
&self,
query: AppDataQuery,
) -> Result<AppDataQueryResult>
pub async fn query_app_data( &self, query: AppDataQuery, ) -> Result<AppDataQueryResult>
Get all app_data by the given query.
Sourcepub async fn query_delete_app_data(&self, query: AppDataQuery) -> Result<()>
pub async fn query_delete_app_data(&self, query: AppDataQuery) -> Result<()>
Delete all app_data matched by the given query.
Sourcepub async fn create_app_data(&self, data: AppData) -> Result<AppData>
pub async fn create_app_data(&self, data: AppData) -> Result<AppData>
pub async fn delete_app_data(&self, id: usize) -> Result<()>
pub async fn update_app_data_key(&self, id: usize, x: &str) -> Result<()>
pub async fn update_app_data_value(&self, id: usize, x: &str) -> Result<()>
Source§impl DataManager
impl DataManager
pub async fn get_app_by_id(&self, selector: usize) -> Result<ThirdPartyApp>
pub async fn get_app_by_api_key(&self, selector: &str) -> Result<ThirdPartyApp>
Sourcepub async fn get_apps_by_owner(&self, id: usize) -> Result<Vec<ThirdPartyApp>>
pub async fn get_apps_by_owner(&self, id: usize) -> 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: usize, user: &User) -> Result<()>
pub async fn cache_clear_app(&self, app: &ThirdPartyApp)
pub async fn update_app_title( &self, id: usize, user: &User, x: &str, ) -> Result<()>
pub async fn update_app_homepage( &self, id: usize, user: &User, x: &str, ) -> Result<()>
pub async fn update_app_redirect( &self, id: usize, user: &User, x: &str, ) -> Result<()>
pub async fn update_app_quota_status( &self, id: usize, x: AppQuota, ) -> Result<()>
pub async fn update_app_scopes( &self, id: usize, user: &User, x: Vec<AppScope>, ) -> Result<()>
pub async fn update_app_api_key(&self, id: usize, x: &str) -> Result<()>
pub async fn update_app_storage_capacity( &self, id: usize, x: DeveloperPassStorageQuota, ) -> Result<()>
pub async fn update_app_data_used(&self, id: usize, x: i32) -> Result<()>
pub async fn add_app_data_used(&self, id: usize, x: i32) -> Result<()>
pub async fn incr_app_grants(&self, id: usize) -> Result<()>
pub async fn decr_app_grants(&self, id: usize) -> Result<()>
Source§impl DataManager
impl DataManager
pub async fn get_audit_log_entry_by_id( &self, selector: usize, ) -> 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 mockAuditLogEntry
object to insert
pub async fn delete_audit_log_entry(&self, id: usize, user: User) -> Result<()>
Source§impl DataManager
impl DataManager
pub async fn get_user_by_id(&self, selector: usize) -> 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: usize) -> Result<User>
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
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: &str,
check_expiration: bool,
) -> Result<(AuthGrant, User)>
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
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: usize,
password: &str,
force: bool,
) -> Result<User>
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 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: usize, x: bool, user: User, ) -> Result<()>
pub async fn update_user_is_deactivated( &self, id: usize, x: bool, user: User, ) -> Result<()>
pub async fn update_user_password( &self, id: usize, from: String, to: String, user: User, force: bool, ) -> Result<()>
pub async fn update_user_username( &self, id: usize, to: String, user: User, ) -> Result<()>
pub async fn update_user_awaiting_purchased_status( &self, id: usize, 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: usize,
secret: &str,
recovery: &Vec<String>,
) -> Result<()>
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 usersecret
- the TOTP secretrecovery
- the TOTP recovery codes
Sourcepub async fn enable_totp(
&self,
id: usize,
user: User,
) -> Result<(String, String, Vec<String>)>
pub async fn enable_totp( &self, id: usize, user: User, ) -> Result<(String, String, Vec<String>)>
pub async fn cache_clear_user(&self, user: &User)
pub async fn update_user_role( &self, id: usize, role: FinePermission, user: &User, force: bool, ) -> Result<()>
pub async fn update_user_secondary_role( &self, id: usize, role: SecondaryPermission, user: &User, force: bool, ) -> Result<()>
pub async fn update_user_tokens(&self, id: usize, x: Vec<Token>) -> Result<()>
pub async fn update_user_grants( &self, id: usize, x: Vec<AuthGrant>, ) -> Result<()>
pub async fn update_user_settings( &self, id: usize, x: UserSettings, ) -> Result<()>
pub async fn update_user_connections( &self, id: usize, x: UserConnections, ) -> Result<()>
pub async fn update_user_associated( &self, id: usize, x: Vec<usize>, ) -> Result<()>
pub async fn update_user_achievements( &self, id: usize, x: Vec<Achievement>, ) -> Result<()>
pub async fn update_user_invite_code(&self, id: usize, x: i64) -> Result<()>
pub async fn update_user_browser_session( &self, id: usize, x: &str, ) -> Result<()>
pub async fn update_user_ban_reason(&self, id: usize, x: &str) -> Result<()>
pub async fn update_user_channel_mutes( &self, id: usize, x: Vec<usize>, ) -> Result<()>
pub async fn update_user_ban_expire(&self, id: usize, x: i64) -> Result<()>
pub async fn update_user_checkouts( &self, id: usize, x: Vec<String>, ) -> Result<()>
pub async fn update_user_last_policy_consent( &self, id: usize, x: i64, ) -> Result<()>
pub async fn update_user_close_friends_stack( &self, id: usize, x: i64, ) -> Result<()>
pub async fn update_user_shrimpcamp_link(&self, id: usize, x: i64) -> Result<()>
pub async fn get_user_by_stripe_id(&self, selector: &str) -> Result<User>
pub async fn update_user_stripe_id(&self, id: usize, x: &str) -> Result<()>
pub async fn update_user_notification_count( &self, id: usize, x: i32, ) -> Result<()>
pub async fn incr_user_notifications(&self, id: usize) -> Result<()>
pub async fn decr_user_notifications(&self, id: usize) -> Result<()>
pub async fn incr_user_follower_count(&self, id: usize) -> Result<()>
pub async fn decr_user_follower_count(&self, id: usize) -> Result<()>
pub async fn incr_user_following_count(&self, id: usize) -> Result<()>
pub async fn decr_user_following_count(&self, id: usize) -> Result<()>
pub async fn incr_user_post_count(&self, id: usize) -> Result<()>
pub async fn decr_user_post_count(&self, id: usize) -> Result<()>
pub async fn update_user_request_count(&self, id: usize, x: i32) -> Result<()>
pub async fn incr_user_request_count(&self, id: usize) -> Result<()>
pub async fn decr_user_request_count(&self, id: usize) -> Result<()>
pub async fn get_user_by_invite_code(&self, selector: i64) -> Result<User>
pub async fn update_user_missed_messages_count( &self, id: usize, x: i32, ) -> Result<()>
pub async fn incr_user_missed_messages(&self, id: usize) -> Result<()>
pub async fn decr_user_missed_messages(&self, id: usize) -> Result<()>
pub async fn incr_profile_views(&self, id: usize) -> Result<()>
pub async fn decr_profile_views(&self, id: usize) -> Result<()>
Source§impl DataManager
impl DataManager
Source§impl DataManager
impl DataManager
pub async fn get_community_by_id(&self, id: usize) -> Result<Community>
pub async fn get_community_by_title(&self, id: &str) -> Result<Community>
pub async fn get_community_by_id_no_void(&self, id: usize) -> Result<Community>
pub async fn get_community_by_title_no_void( &self, selector: &str, ) -> Result<Community>
Sourcepub async fn get_popular_communities(&self) -> Result<Vec<Community>>
pub async fn get_popular_communities(&self) -> Result<Vec<Community>>
Get the top 12 most popular (most likes) communities.
Sourcepub async fn get_communities_searched(
&self,
query: &str,
batch: usize,
page: usize,
) -> Result<Vec<Community>>
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.
Sourcepub async fn get_communities_by_owner(
&self,
id: usize,
) -> Result<Vec<Community>>
pub async fn get_communities_by_owner( &self, id: usize, ) -> Result<Vec<Community>>
Get all communities by their owner.
Sourcepub async fn create_community(&self, data: Community) -> Result<String>
pub async fn create_community(&self, data: Community) -> Result<String>
pub async fn cache_clear_community(&self, community: &Community)
pub async fn delete_community(&self, id: usize, user: &User) -> Result<()>
pub async fn update_community_title( &self, id: usize, user: User, title: &str, ) -> Result<()>
pub async fn update_community_owner( &self, id: usize, user: User, new_owner: usize, ) -> Result<()>
pub async fn delete_topic_posts(&self, id: usize, topic: usize) -> Result<()>
pub async fn update_community_context( &self, id: usize, user: &User, x: CommunityContext, ) -> Result<()>
pub async fn update_community_read_access( &self, id: usize, user: &User, x: CommunityReadAccess, ) -> Result<()>
pub async fn update_community_write_access( &self, id: usize, user: &User, x: CommunityWriteAccess, ) -> Result<()>
pub async fn update_community_join_access( &self, id: usize, user: &User, x: CommunityJoinAccess, ) -> Result<()>
pub async fn update_community_topics( &self, id: usize, user: &User, x: HashMap<usize, ForumTopic>, ) -> Result<()>
pub async fn update_community_is_forum( &self, id: usize, user: &User, x: i32, ) -> Result<()>
pub async fn incr_community_likes(&self, id: usize) -> Result<()>
pub async fn incr_community_dislikes(&self, id: usize) -> Result<()>
pub async fn decr_community_likes(&self, id: usize) -> Result<()>
pub async fn decr_community_dislikes(&self, id: usize) -> Result<()>
pub async fn incr_community_member_count(&self, id: usize) -> Result<()>
pub async fn decr_community_member_count(&self, id: usize) -> Result<()>
pub async fn incr_community_post_count(&self, id: usize) -> Result<()>
pub async fn decr_community_post_count(&self, id: usize) -> Result<()>
Source§impl DataManager
impl DataManager
pub async fn get_draft_by_id(&self, id: usize) -> Result<PostDraft>
Sourcepub async fn get_drafts_by_user(
&self,
id: usize,
batch: usize,
page: usize,
) -> Result<Vec<PostDraft>>
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 tobatch
- the limit of posts in each pagepage
- the page number
Sourcepub async fn get_drafts_by_user_all(&self, id: usize) -> Result<Vec<PostDraft>>
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
Sourcepub async fn create_draft(&self, data: PostDraft) -> Result<usize>
pub async fn create_draft(&self, data: PostDraft) -> Result<usize>
pub async fn delete_draft(&self, id: usize, user: User) -> Result<()>
pub async fn update_draft_content( &self, id: usize, 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_emoji_by_id(&self, selector: usize) -> Result<CustomEmoji>
Sourcepub async fn get_emojis_by_community(
&self,
community: usize,
) -> Result<Vec<CustomEmoji>>
pub async fn get_emojis_by_community( &self, community: usize, ) -> Result<Vec<CustomEmoji>>
Sourcepub async fn get_user_emojis(
&self,
id: usize,
) -> Result<HashMap<usize, (String, Vec<CustomEmoji>)>>
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.
Sourcepub async fn get_emoji_by_community_name(
&self,
community: usize,
name: &str,
) -> Result<(Option<CustomEmoji>, Option<String>)>
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 fromname
- 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.
Sourcepub async fn create_emoji(&self, data: CustomEmoji) -> Result<()>
pub async fn create_emoji(&self, data: CustomEmoji) -> Result<()>
pub async fn delete_emoji(&self, id: usize, user: &User) -> Result<()>
pub async fn update_emoji_name( &self, id: usize, user: &User, x: &str, ) -> Result<()>
Source§impl DataManager
impl DataManager
pub async fn get_guest_log_by_id(&self, id: usize) -> Result<GuestLog>
Sourcepub async fn get_guest_logs_by_owner(
&self,
owner: usize,
batch: usize,
page: usize,
) -> Result<Vec<GuestLog>>
pub async fn get_guest_logs_by_owner( &self, owner: usize, batch: usize, page: usize, ) -> Result<Vec<GuestLog>>
Get all guest_logs by owner
.
Sourcepub async fn get_guest_logs_by_owner_wfr(
&self,
owner: usize,
batch: usize,
page: usize,
) -> Result<Vec<GuestLog>>
pub async fn get_guest_logs_by_owner_wfr( &self, owner: usize, batch: usize, page: usize, ) -> Result<Vec<GuestLog>>
Get all guest_logs by owner
.
Sourcepub async fn create_guest_log(&self, data: GuestLog) -> Result<usize>
pub async fn create_guest_log(&self, data: GuestLog) -> Result<usize>
pub async fn delete_guest_log(&self, id: usize, user: &User) -> Result<()>
pub async fn update_guest_log_waiting_for_review( &self, id: usize, new_wfr: bool, user: &User, ) -> Result<()>
Source§impl DataManager
impl DataManager
pub async fn get_invite_code_by_id(&self, id: usize) -> Result<InviteCode>
pub async fn get_invite_code_by_code( &self, selector: &str, ) -> Result<InviteCode>
Sourcepub async fn get_invite_codes_by_owner(
&self,
owner: usize,
batch: usize,
page: usize,
) -> Result<Vec<InviteCode>>
pub async fn get_invite_codes_by_owner( &self, owner: usize, batch: usize, page: usize, ) -> Result<Vec<InviteCode>>
Get invite_codes by owner
.
Sourcepub async fn get_invite_codes_by_owner_count(&self, owner: usize) -> Result<i32>
pub async fn get_invite_codes_by_owner_count(&self, owner: usize) -> Result<i32>
Get invite_codes by owner
.
Sourcepub async fn fill_invite_codes(
&self,
codes: Vec<InviteCode>,
) -> Result<Vec<(Option<User>, InviteCode)>>
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.
Sourcepub async fn create_invite_code(
&self,
data: InviteCode,
user: &User,
) -> Result<InviteCode>
pub async fn create_invite_code( &self, data: InviteCode, user: &User, ) -> Result<InviteCode>
pub async fn delete_invite_code(&self, id: usize, user: &User) -> Result<()>
pub async fn update_invite_code_is_used( &self, id: usize, new_is_used: bool, ) -> Result<()>
Source§impl DataManager
impl DataManager
pub async fn get_ipban_by_ip(&self, selector: &str) -> Result<IpBan>
Sourcepub async fn get_ipban_by_addr(&self, addr: &RemoteAddr) -> Result<IpBan>
pub async fn get_ipban_by_addr(&self, addr: &RemoteAddr) -> Result<IpBan>
Sourcepub async fn get_ipbans(&self, batch: usize, page: usize) -> Result<Vec<IpBan>>
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 pagepage
- the page number
Sourcepub async fn create_ipban(&self, data: IpBan) -> Result<()>
pub async fn create_ipban(&self, data: IpBan) -> Result<()>
pub async fn delete_ipban(&self, ip: &str, user: User) -> Result<()>
Source§impl DataManager
impl DataManager
pub async fn get_ipblock_by_id(&self, id: usize) -> Result<IpBlock>
Sourcepub async fn get_ipblock_by_initiator_receiver(
&self,
initiator: usize,
receiver: &RemoteAddr,
) -> Result<IpBlock>
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).
Sourcepub async fn get_ipblock_by_receiver_initiator(
&self,
receiver: &str,
initiator: usize,
) -> Result<IpBlock>
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).
Sourcepub async fn get_ipblocks_by_initiator(
&self,
initiator: usize,
) -> Result<Vec<IpBlock>>
pub async fn get_ipblocks_by_initiator( &self, initiator: usize, ) -> Result<Vec<IpBlock>>
Get all ip blocks by initiator
.
Sourcepub async fn create_ipblock(&self, data: IpBlock) -> Result<()>
pub async fn create_ipblock(&self, data: IpBlock) -> Result<()>
pub async fn delete_ipblock(&self, id: usize, user: User) -> Result<()>
Source§impl DataManager
impl DataManager
pub async fn get_letter_by_id(&self, selector: usize) -> Result<Letter>
Sourcepub async fn get_letters_by_user(
&self,
id: usize,
batch: usize,
page: usize,
) -> Result<Vec<Letter>>
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 forbatch
- the limit of items in each pagepage
- the page number
Sourcepub async fn get_received_letters_by_user(
&self,
id: usize,
batch: usize,
page: usize,
) -> Result<Vec<Letter>>
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 forbatch
- the limit of items in each pagepage
- the page number
Sourcepub async fn get_letters_by_replying_to(
&self,
id: usize,
batch: usize,
page: usize,
) -> Result<Vec<Letter>>
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 forbatch
- the limit of items in each pagepage
- the page number
Sourcepub async fn fill_letters(
&self,
letters: Vec<Letter>,
) -> Result<Vec<(User, Letter)>>
pub async fn fill_letters( &self, letters: Vec<Letter>, ) -> Result<Vec<(User, Letter)>>
Fill a list of letters with their owner.
Sourcepub async fn create_letter(&self, data: Letter) -> Result<Letter>
pub async fn create_letter(&self, data: Letter) -> Result<Letter>
pub async fn delete_letter(&self, id: usize, user: &User) -> Result<()>
pub async fn update_letter_read_by( &self, id: usize, x: Vec<usize>, ) -> Result<()>
pub async fn incr_letter_likes(&self, id: usize) -> Result<()>
pub async fn incr_letter_dislikes(&self, id: usize) -> Result<()>
pub async fn decr_letter_likes(&self, id: usize) -> Result<()>
pub async fn decr_letter_dislikes(&self, id: usize) -> Result<()>
Source§impl DataManager
impl DataManager
pub async fn get_membership_by_id( &self, id: usize, ) -> Result<CommunityMembership>
Sourcepub async fn fill_communities(
&self,
list: Vec<CommunityMembership>,
) -> Result<Vec<Community>>
pub async fn fill_communities( &self, list: Vec<CommunityMembership>, ) -> Result<Vec<Community>>
Replace a list of community memberships with the proper community.
Sourcepub async fn fill_users(
&self,
list: Vec<CommunityMembership>,
) -> Result<Vec<(CommunityMembership, User)>>
pub async fn fill_users( &self, list: Vec<CommunityMembership>, ) -> Result<Vec<(CommunityMembership, User)>>
Replace a list of community memberships with the proper user.
Sourcepub async fn get_membership_by_owner_community(
&self,
owner: usize,
community: usize,
) -> Result<CommunityMembership>
pub async fn get_membership_by_owner_community( &self, owner: usize, community: usize, ) -> Result<CommunityMembership>
Get a community membership by owner
and community
.
Sourcepub async fn get_membership_by_owner_community_no_void(
&self,
owner: usize,
community: usize,
) -> Result<CommunityMembership>
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
.
Sourcepub async fn get_memberships_by_owner(
&self,
owner: usize,
) -> Result<Vec<CommunityMembership>>
pub async fn get_memberships_by_owner( &self, owner: usize, ) -> Result<Vec<CommunityMembership>>
Get all community memberships by owner
.
Sourcepub async fn get_memberships_by_community(
&self,
community: usize,
community_owner: usize,
batch: usize,
page: usize,
) -> Result<Vec<CommunityMembership>>
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
.
Sourcepub 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,
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
data
- a mockCommunityMembership
object to insert
Sourcepub async fn delete_membership(&self, id: usize, user: &User) -> Result<()>
pub async fn delete_membership(&self, id: usize, user: &User) -> Result<()>
Delete a membership given its id
Sourcepub async fn delete_membership_force(&self, id: usize) -> Result<()>
pub async fn delete_membership_force(&self, id: usize) -> Result<()>
Delete a membership given its id
Sourcepub async fn update_membership_role(
&self,
id: usize,
new_role: CommunityPermission,
) -> Result<()>
pub async fn update_membership_role( &self, id: usize, new_role: CommunityPermission, ) -> Result<()>
Update a membership’s role given its id
Source§impl DataManager
impl DataManager
pub async fn get_notification_by_id(&self, id: usize) -> Result<Notification>
Sourcepub async fn get_notifications_by_owner(
&self,
owner: usize,
) -> Result<Vec<Notification>>
pub async fn get_notifications_by_owner( &self, owner: usize, ) -> Result<Vec<Notification>>
Get all notifications by owner
.
Sourcepub async fn get_notifications_by_owner_paginated(
&self,
owner: usize,
batch: usize,
page: usize,
) -> Result<Vec<Notification>>
pub async fn get_notifications_by_owner_paginated( &self, owner: usize, 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: usize, 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: usize, 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_by_id(&self, id: usize) -> Result<Poll>
Sourcepub async fn create_poll(&self, data: Poll) -> Result<usize>
pub async fn create_poll(&self, data: Poll) -> Result<usize>
pub async fn delete_poll(&self, id: usize, user: &User) -> Result<()>
pub async fn cache_clear_poll(&self, poll: &Poll)
pub async fn incr_votes_a_count(&self, id: usize) -> Result<()>
pub async fn decr_votes_a_count(&self, id: usize) -> Result<()>
pub async fn incr_votes_b_count(&self, id: usize) -> Result<()>
pub async fn decr_votes_b_count(&self, id: usize) -> Result<()>
pub async fn incr_votes_c_count(&self, id: usize) -> Result<()>
pub async fn decr_votes_c_count(&self, id: usize) -> Result<()>
pub async fn incr_votes_d_count(&self, id: usize) -> Result<()>
pub async fn decr_votes_d_count(&self, id: usize) -> Result<()>
Source§impl DataManager
impl DataManager
pub async fn get_pollvote_by_id(&self, id: usize) -> Result<PollVote>
pub async fn get_pollvote_by_owner_poll( &self, id: usize, poll_id: usize, ) -> Result<PollVote>
Sourcepub async fn create_pollvote(&self, data: PollVote) -> Result<usize>
pub async fn create_pollvote(&self, data: PollVote) -> Result<usize>
pub async fn delete_pollvote(&self, id: usize, user: User) -> Result<()>
Source§impl DataManager
impl DataManager
pub async fn get_post_view_by_id(&self, id: usize) -> Result<PostView>
Sourcepub async fn get_post_view_by_owner_post(
&self,
owner: usize,
post: usize,
) -> Result<PostView>
pub async fn get_post_view_by_owner_post( &self, owner: usize, post: usize, ) -> Result<PostView>
Get a post view by owner
and post
.
Sourcepub async fn create_post_view(&self, data: PostView) -> Result<usize>
pub async fn create_post_view(&self, data: PostView) -> Result<usize>
pub async fn delete_post_view(&self, id: usize, user: &User) -> Result<()>
Source§impl DataManager
impl DataManager
pub async fn get_post_by_id(&self, id: usize) -> Result<Post>
Sourcepub async fn get_replies_by_post(
&self,
id: usize,
batch: usize,
page: usize,
sort: &str,
) -> Result<Vec<Post>>
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 onbatch
- the limit of posts in each pagepage
- the page number
Sourcepub async fn get_post_reposting(
&self,
post: &Post,
ignore_users: &[usize],
user: &Option<User>,
) -> (bool, Option<(User, Post)>)
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).
Sourcepub 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)>)>>
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.
Sourcepub async fn get_post_poll(
&self,
post: &Post,
user: &Option<User>,
) -> Result<Option<(Poll, bool, bool)>>
pub async fn get_post_poll( &self, post: &Post, user: &Option<User>, ) -> Result<Option<(Poll, bool, bool)>>
Sourcepub async fn get_post_stack(
&self,
seen_stacks: &mut HashMap<usize, UserStack>,
post: &Post,
as_user_id: usize,
) -> (bool, Option<UserStack>)
pub async fn get_post_stack( &self, seen_stacks: &mut HashMap<usize, UserStack>, post: &Post, as_user_id: usize, ) -> (bool, Option<UserStack>)
Sourcepub 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>)>>
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.
Sourcepub async fn fill_posts_with_community(
&self,
posts: Vec<Post>,
user_id: usize,
ignore_users: &[usize],
user: &Option<User>,
) -> Result<(Vec<FullPost>, f64, usize)>
pub async fn fill_posts_with_community( &self, posts: Vec<Post>, user_id: usize, ignore_users: &[usize], user: &Option<User>, ) -> Result<(Vec<FullPost>, f64, usize)>
Complete a vector of just posts with their owner and community as well.
Sourcepub fn posts_muted_phrase_filter(
&self,
posts: &Vec<FullPost>,
muted: Option<&Vec<String>>,
) -> Vec<FullPost> ⓘ
pub fn posts_muted_phrase_filter( &self, posts: &Vec<FullPost>, muted: Option<&Vec<String>>, ) -> Vec<FullPost> ⓘ
Update posts which contain a muted phrase.
Sourcepub fn posts_owner_filter(&self, posts: &Vec<FullPost>) -> Vec<FullPost> ⓘ
pub fn posts_owner_filter(&self, posts: &Vec<FullPost>) -> Vec<FullPost> ⓘ
Filter to update posts to clean their owner for public APIs.
Sourcepub async fn get_posts_by_user(
&self,
id: usize,
batch: usize,
page: usize,
) -> Result<Vec<Post>>
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 tobatch
- the limit of posts in each pagepage
- the page number
Sourcepub async fn get_popular_posts_by_user(
&self,
id: usize,
batch: usize,
page: usize,
) -> Result<Vec<Post>>
pub async fn get_popular_posts_by_user( &self, id: usize, 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: usize,
batch: usize,
page: usize,
) -> Result<Vec<Post>>
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 tobatch
- the limit of posts in each pagepage
- the page number
Sourcepub async fn get_replies_by_user(
&self,
id: usize,
batch: usize,
page: usize,
user: &Option<User>,
) -> Result<Vec<Post>>
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 tobatch
- the limit of posts in each pagepage
- the page number
Sourcepub async fn get_media_posts_by_user(
&self,
id: usize,
batch: usize,
page: usize,
user: &Option<User>,
) -> Result<Vec<Post>>
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 tobatch
- the limit of posts in each pagepage
- the page number
Sourcepub async fn get_posts_by_user_searched(
&self,
id: usize,
batch: usize,
page: usize,
text_query: &str,
user: &Option<&User>,
) -> Result<Vec<Post>>
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 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,
batch: usize,
page: usize,
text_query: &str,
) -> Result<Vec<Post>>
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 pagepage
- the page numbertext_query
- the search query
Sourcepub async fn get_posts_by_user_tag(
&self,
id: usize,
tag: &str,
batch: usize,
page: usize,
) -> Result<Vec<Post>>
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 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: usize,
tag: &str,
batch: usize,
page: usize,
) -> Result<Vec<Post>>
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 totag
- the tag to filter bybatch
- the limit of posts in each pagepage
- the page number
Sourcepub async fn get_posts_by_community(
&self,
id: usize,
batch: usize,
page: usize,
user: &Option<User>,
) -> Result<Vec<Post>>
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 tobatch
- the limit of posts in each pagepage
- the page number
Sourcepub async fn get_posts_by_community_topic(
&self,
id: usize,
topic: usize,
batch: usize,
page: usize,
user: &Option<User>,
) -> Result<Vec<Post>>
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 totopic
- the ID of the topic the requested posts belong tobatch
- the limit of posts in each pagepage
- the page number
Sourcepub async fn get_posts_by_stack(
&self,
id: usize,
batch: usize,
before: usize,
) -> Result<Vec<Post>>
pub async fn get_posts_by_stack( &self, id: usize, batch: usize, before: 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 tobatch
- the limit of posts in each pagebefore
- the timestamp to pull posts before
Sourcepub async fn get_pinned_posts_by_community(
&self,
id: usize,
) -> Result<Vec<Post>>
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
Sourcepub async fn get_pinned_posts_by_community_topic(
&self,
id: usize,
topic: usize,
) -> Result<Vec<Post>>
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 totopic
- the ID of the topic the requested posts belong to
Sourcepub async fn get_pinned_posts_by_user(&self, id: usize) -> Result<Vec<Post>>
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
Sourcepub async fn get_posts_by_question(
&self,
id: usize,
batch: usize,
page: usize,
) -> Result<Vec<Post>>
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 tobatch
- the limit of posts in each pagepage
- the page number
Sourcepub async fn get_post_by_owner_question(
&self,
owner: usize,
question: usize,
) -> Result<Post>
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 ownerquestion
- the ID of the post question
Sourcepub async fn get_quoting_posts_by_quoting(
&self,
id: usize,
batch: usize,
page: usize,
) -> Result<Vec<Post>>
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 quotedbatch
- the limit of posts in each pagepage
- the page number
Sourcepub async fn get_reposts_by_quoting(
&self,
id: usize,
batch: usize,
page: usize,
) -> Result<Vec<Post>>
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 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,
batch: usize,
as_user: &Option<User>,
before_time: usize,
) -> Result<Vec<Post>>
pub async fn get_latest_posts( &self, batch: 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 pagepage
- the page number
Sourcepub async fn get_latest_forum_posts(
&self,
batch: usize,
page: usize,
as_user: &Option<User>,
) -> Result<Vec<Post>>
pub async fn get_latest_forum_posts( &self, batch: usize, page: usize, as_user: &Option<User>, ) -> Result<Vec<Post>>
Get forum 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_communities(
&self,
id: usize,
batch: usize,
before: usize,
user: &User,
) -> Result<Vec<Post>>
pub async fn get_posts_from_user_communities( &self, id: usize, batch: usize, before: usize, user: &User, ) -> Result<Vec<Post>>
Get posts from all communities the given user is in.
§Arguments
id
- the ID of the userbatch
- the limit of posts in each pagebefore
- the timestamp to pull posts before
Sourcepub async fn get_posts_from_user_following(
&self,
id: usize,
batch: usize,
before: usize,
) -> Result<Vec<Post>>
pub async fn get_posts_from_user_following( &self, id: usize, batch: usize, before: 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 pagebefore
- the timestamp to pull posts before
Sourcepub async fn get_posts_from_stack(
&self,
id: usize,
batch: usize,
page: usize,
sort: StackSort,
) -> Result<Vec<Post>>
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 stackbatch
- the limit of posts in each pagepage
- the page number
Sourcepub async fn check_can_post(&self, community: &Community, uid: usize) -> bool
pub async fn check_can_post(&self, community: &Community, uid: usize) -> bool
Check if the given uid
can post in the given community
.
Sourcepub async fn check_can_post_with_access(
&self,
community: &Community,
access: &CommunityWriteAccess,
uid: usize,
) -> bool
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
.
Sourcepub async fn create_post(&self, data: Post) -> Result<usize>
pub async fn create_post(&self, data: Post) -> Result<usize>
pub async fn delete_post(&self, id: usize, user: User) -> Result<()>
pub async fn fake_delete_post( &self, id: usize, user: User, is_deleted: bool, ) -> Result<()>
pub async fn update_post_is_open( &self, id: usize, user: User, is_open: bool, ) -> Result<()>
pub async fn update_post_context( &self, id: usize, user: User, x: PostContext, ) -> Result<()>
pub async fn update_post_content( &self, id: usize, user: User, x: String, ) -> Result<()>
pub async fn update_post_title( &self, id: usize, user: User, x: String, ) -> Result<()>
pub async fn incr_post_likes(&self, id: usize) -> Result<()>
pub async fn incr_post_dislikes(&self, id: usize) -> Result<()>
pub async fn decr_post_likes(&self, id: usize) -> Result<()>
pub async fn decr_post_dislikes(&self, id: usize) -> Result<()>
pub async fn incr_post_comments(&self, id: usize) -> Result<()>
pub async fn decr_post_comments(&self, id: usize) -> Result<()>
pub async fn incr_post_views(&self, id: usize) -> Result<()>
pub async fn decr_post_views(&self, id: usize) -> Result<()>
Source§impl DataManager
impl DataManager
pub async fn get_profile_view_by_id(&self, id: usize) -> Result<ProfileView>
Sourcepub async fn get_profile_view_by_owner_profile(
&self,
owner: usize,
profile: usize,
) -> Result<ProfileView>
pub async fn get_profile_view_by_owner_profile( &self, owner: usize, profile: usize, ) -> Result<ProfileView>
Get a profile view by owner
and profile
.
Sourcepub async fn create_profile_view(&self, data: ProfileView) -> Result<usize>
pub async fn create_profile_view(&self, data: ProfileView) -> Result<usize>
pub async fn delete_profile_view(&self, id: usize, user: &User) -> Result<()>
Source§impl DataManager
impl DataManager
pub async fn get_question_by_id(&self, id: usize) -> 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>,
ignore_users: &[usize],
) -> Result<Vec<(Question, User, Option<(User, Post)>)>>
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.
Sourcepub fn questions_owner_filter(
&self,
questions: &Vec<(Question, User, Option<(User, Post)>)>,
) -> Vec<(Question, User, Option<(User, Post)>)>
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.
Sourcepub async fn get_questions_by_owner(
&self,
owner: usize,
) -> Result<Vec<Question>>
pub async fn get_questions_by_owner( &self, owner: usize, ) -> Result<Vec<Question>>
Get all questions by owner
.
Sourcepub async fn get_questions_by_owner_paginated(
&self,
owner: usize,
batch: usize,
page: usize,
) -> Result<Vec<Question>>
pub async fn get_questions_by_owner_paginated( &self, owner: usize, batch: usize, page: usize, ) -> Result<Vec<Question>>
Get all questions by owner
(paginated).
Sourcepub async fn get_questions_by_receiver(
&self,
receiver: usize,
) -> Result<Vec<Question>>
pub async fn get_questions_by_receiver( &self, receiver: usize, ) -> Result<Vec<Question>>
Get all questions by receiver
.
Sourcepub async fn get_questions_by_community(
&self,
community: usize,
batch: usize,
page: usize,
) -> Result<Vec<Question>>
pub async fn get_questions_by_community( &self, community: usize, batch: usize, page: usize, ) -> Result<Vec<Question>>
Get all global questions by community
.
Sourcepub async fn get_questions_from_user_following(
&self,
id: usize,
batch: usize,
page: usize,
) -> Result<Vec<Question>>
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.
Sourcepub async fn get_questions_from_user_communities(
&self,
id: usize,
batch: usize,
page: usize,
) -> Result<Vec<Question>>
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.
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 from all communities, 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 from all communities, 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
Sourcepub async fn create_question(
&self,
data: Question,
drawings: Vec<Vec<u8>>,
) -> Result<usize>
pub async fn create_question( &self, data: Question, drawings: Vec<Vec<u8>>, ) -> Result<usize>
pub async fn delete_question(&self, id: usize, user: &User) -> Result<()>
pub async fn delete_all_questions(&self, user: &User) -> Result<()>
pub async fn incr_question_answer_count(&self, id: usize) -> Result<()>
pub async fn decr_question_answer_count(&self, id: usize) -> Result<()>
pub async fn incr_question_likes(&self, id: usize) -> Result<()>
pub async fn incr_question_dislikes(&self, id: usize) -> Result<()>
pub async fn decr_question_likes(&self, id: usize) -> Result<()>
pub async fn decr_question_dislikes(&self, id: usize) -> Result<()>
Source§impl DataManager
impl DataManager
pub async fn get_reaction_by_id(&self, id: usize) -> Result<Reaction>
Sourcepub async fn fill_reactions(
&self,
reactions: &Vec<Reaction>,
ignore_users: Vec<usize>,
) -> Result<Vec<(Reaction, User)>>
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.
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: usize,
asset: usize,
) -> Result<Reaction>
pub async fn get_reaction_by_owner_asset( &self, owner: usize, asset: usize, ) -> 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: usize, user: &User) -> Result<()>
Source§impl DataManager
impl DataManager
pub async fn get_report_by_id(&self, selector: usize) -> 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: usize, user: User) -> Result<()>
Source§impl DataManager
impl DataManager
pub async fn get_request_by_id_linked_asset( &self, id: usize, linked_asset: usize, ) -> Result<ActionRequest>
Sourcepub async fn get_requests_by_owner(
&self,
owner: usize,
) -> Result<Vec<ActionRequest>>
pub async fn get_requests_by_owner( &self, owner: usize, ) -> Result<Vec<ActionRequest>>
Get all action requests by owner
.
Sourcepub async fn get_requests_by_owner_paginated(
&self,
owner: usize,
batch: usize,
page: usize,
) -> Result<Vec<ActionRequest>>
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).
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: usize, linked_asset: usize, user: &User, force: bool, ) -> Result<()>
pub async fn delete_all_requests(&self, user: &User) -> Result<()>
Source§impl DataManager
impl DataManager
pub async fn get_stackblock_by_id(&self, id: usize) -> Result<StackBlock>
pub async fn get_user_stack_blocked_users(&self, user_id: usize) -> Vec<usize>
Sourcepub async fn fill_stackblocks_receivers(
&self,
stack: usize,
) -> Result<Vec<usize>>
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).
Sourcepub async fn get_stackblocks_by_initiator(
&self,
initiator: usize,
) -> Vec<StackBlock>
pub async fn get_stackblocks_by_initiator( &self, initiator: usize, ) -> Vec<StackBlock>
Get all stack blocks created by the given initiator
.
Sourcepub async fn get_stackblock_by_initiator_stack(
&self,
initiator: usize,
stack: usize,
) -> Result<StackBlock>
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).
Sourcepub async fn create_stackblock(&self, data: StackBlock) -> Result<()>
pub async fn create_stackblock(&self, data: StackBlock) -> Result<()>
pub async fn delete_stackblock(&self, id: usize, user: User) -> Result<()>
pub async fn delete_stackblock_sudo(&self, id: usize) -> Result<()>
Source§impl DataManager
impl DataManager
pub const MAXIMUM_FREE_STACK_USERS: usize = 50usize
pub async fn get_stack_by_id(&self, selector: usize) -> Result<UserStack>
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>>
pub async fn get_stack_users( &self, id: usize, batch: usize, page: usize, ) -> Result<Vec<User>>
Sourcepub async fn get_stacks_by_user(&self, id: usize) -> Result<Vec<UserStack>>
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
Sourcepub async fn create_stack(&self, data: UserStack) -> Result<UserStack>
pub async fn create_stack(&self, data: UserStack) -> Result<UserStack>
pub async fn delete_stack(&self, id: usize, user: &User) -> Result<()>
Sourcepub async fn clone_stack(&self, owner: usize, stack: usize) -> Result<UserStack>
pub async fn clone_stack(&self, owner: usize, stack: usize) -> Result<UserStack>
Clone the given stack.
pub async fn update_stack_name( &self, id: usize, user: &User, x: &str, ) -> Result<()>
pub async fn update_stack_users( &self, id: usize, user: &User, x: Vec<usize>, ) -> Result<()>
pub async fn update_stack_privacy( &self, id: usize, user: &User, x: StackPrivacy, ) -> Result<()>
pub async fn update_stack_mode( &self, id: usize, user: &User, x: StackMode, ) -> Result<()>
pub async fn update_stack_sort( &self, id: usize, user: &User, x: StackSort, ) -> Result<()>
Source§impl DataManager
impl DataManager
pub async fn get_user_warning_by_id( &self, selector: usize, ) -> Result<UserWarning>
Sourcepub async fn get_user_warnings_by_user(
&self,
user: usize,
batch: usize,
page: usize,
) -> Result<Vec<UserWarning>>
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 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: usize, user: User) -> Result<()>
Source§impl DataManager
impl DataManager
pub async fn get_userblock_by_id(&self, id: usize) -> Result<UserBlock>
Sourcepub async fn fill_userblocks_receivers(
&self,
list: Vec<UserBlock>,
) -> Result<Vec<User>>
pub async fn fill_userblocks_receivers( &self, list: Vec<UserBlock>, ) -> Result<Vec<User>>
Fill a vector of user blocks with their receivers.
Sourcepub async fn get_userblock_by_initiator_receiver(
&self,
initiator: usize,
receiver: usize,
) -> Result<UserBlock>
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).
Sourcepub async fn get_userblock_by_receiver_initiator(
&self,
receiver: usize,
initiator: usize,
) -> Result<UserBlock>
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).
Sourcepub async fn get_userblocks_receivers(
&self,
initiator: usize,
associated: &Vec<usize>,
do_associated: bool,
) -> Vec<usize>
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
.
Sourcepub async fn get_userblocks_by_initiator(
&self,
initiator: usize,
) -> Vec<UserBlock>
pub async fn get_userblocks_by_initiator( &self, initiator: usize, ) -> Vec<UserBlock>
Get all user blocks created by the given initiator
.
Sourcepub async fn get_userblocks_initiator_by_receivers(
&self,
receiver: usize,
) -> Vec<usize>
pub async fn get_userblocks_initiator_by_receivers( &self, receiver: usize, ) -> Vec<usize>
Get the owner of all user blocks for the given receiver
.
Sourcepub async fn create_userblock(&self, data: UserBlock) -> Result<()>
pub async fn create_userblock(&self, data: UserBlock) -> Result<()>
pub async fn delete_userblock(&self, id: usize, user: User) -> Result<()>
pub async fn delete_userblock_sudo(&self, id: usize) -> Result<()>
Source§impl DataManager
impl DataManager
pub async fn get_userfollow_by_id(&self, id: usize) -> Result<UserFollow>
Sourcepub fn userfollows_user_filter(
&self,
x: &Vec<(UserFollow, User)>,
) -> Vec<(UserFollow, User)>
pub fn userfollows_user_filter( &self, x: &Vec<(UserFollow, User)>, ) -> Vec<(UserFollow, User)>
Filter to update userfollows to clean their users for public APIs.
Sourcepub async fn get_userfollow_by_initiator_receiver(
&self,
initiator: usize,
receiver: usize,
) -> Result<UserFollow>
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).
Sourcepub async fn get_userfollow_by_receiver_initiator(
&self,
receiver: usize,
initiator: usize,
) -> Result<UserFollow>
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).
Sourcepub async fn get_userfollows_by_initiator(
&self,
id: usize,
batch: usize,
page: usize,
) -> Result<Vec<UserFollow>>
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 userbatch
- the limit of userfollows in each pagepage
- the page number
Sourcepub async fn get_userfollows_by_initiator_all(
&self,
id: usize,
) -> Result<Vec<UserFollow>>
pub async fn get_userfollows_by_initiator_all( &self, id: usize, ) -> Result<Vec<UserFollow>>
Sourcepub async fn get_userfollows_by_receiver(
&self,
id: usize,
batch: usize,
page: usize,
) -> Result<Vec<UserFollow>>
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 userbatch
- the limit of userfollows in each pagepage
- the page number
Sourcepub async fn get_userfollows_by_receiver_all(
&self,
id: usize,
) -> Result<Vec<UserFollow>>
pub async fn get_userfollows_by_receiver_all( &self, id: usize, ) -> Result<Vec<UserFollow>>
Sourcepub async fn fill_userfollows_with_receiver(
&self,
userfollows: Vec<UserFollow>,
as_user: &Option<User>,
do_check: bool,
) -> Result<Vec<(UserFollow, User)>>
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.
Sourcepub async fn fill_userfollows_with_initiator(
&self,
userfollows: Vec<UserFollow>,
as_user: &Option<User>,
do_check: bool,
) -> Result<Vec<(UserFollow, User)>>
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.
Sourcepub async fn create_userfollow(
&self,
data: UserFollow,
initiator: &User,
force: bool,
) -> Result<FollowResult>
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 mockUserFollow
object to insertforce
- if we should skip the request stage
pub async fn delete_userfollow( &self, id: usize, user: &User, is_deleting_user: bool, ) -> Result<()>
pub async fn delete_userfollow_sudo( &self, id: usize, user_id: usize, ) -> 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 !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