Struct collab2::db::Database

source ·
pub struct Database { /* private fields */ }

Implementations§

source§

impl Database

source

pub async fn create_access_token( &self, user_id: UserId, access_token_hash: &str, max_access_token_count: usize ) -> Result<AccessTokenId>

source

pub async fn get_access_token( &self, access_token_id: AccessTokenId ) -> Result<Model>

source§

impl Database

source

pub async fn join_channel_buffer( &self, channel_id: ChannelId, user_id: UserId, connection: ConnectionId ) -> Result<JoinChannelBufferResponse>

source

pub async fn rejoin_channel_buffers( &self, buffers: &[ChannelBufferVersion], user_id: UserId, connection_id: ConnectionId ) -> Result<Vec<RejoinedChannelBuffer>>

source

pub async fn clear_stale_channel_buffer_collaborators( &self, channel_id: ChannelId, server_id: ServerId ) -> Result<RefreshedChannelBuffer>

source

pub async fn leave_channel_buffer( &self, channel_id: ChannelId, connection: ConnectionId ) -> Result<LeftChannelBuffer>

source

pub async fn channel_buffer_connection_lost( &self, connection: ConnectionId, tx: &DatabaseTransaction ) -> Result<()>

source

pub async fn leave_channel_buffers( &self, connection: ConnectionId ) -> Result<Vec<LeftChannelBuffer>>

source

pub async fn leave_channel_buffer_internal( &self, channel_id: ChannelId, connection: ConnectionId, tx: &DatabaseTransaction ) -> Result<LeftChannelBuffer>

source

pub async fn get_channel_buffer_collaborators( &self, channel_id: ChannelId ) -> Result<Vec<UserId>>

source

pub async fn update_channel_buffer( &self, channel_id: ChannelId, user: UserId, operations: &[Operation] ) -> Result<(Vec<ConnectionId>, Vec<UserId>, i32, Vec<VectorClockEntry>)>

source

pub async fn get_channel_buffer( &self, channel_id: ChannelId, tx: &DatabaseTransaction ) -> Result<Model>

source

pub async fn observe_buffer_version( &self, buffer_id: BufferId, user_id: UserId, epoch: i32, version: &[VectorClockEntry] ) -> Result<()>

source

pub async fn unseen_channel_buffer_changes( &self, user_id: UserId, channel_ids: &[ChannelId], tx: &DatabaseTransaction ) -> Result<Vec<UnseenChannelBufferChange>>

source

pub async fn get_latest_operations_for_buffers( &self, buffer_ids: impl IntoIterator<Item = BufferId>, tx: &DatabaseTransaction ) -> Result<Vec<Model>>

source§

impl Database

source

pub async fn create_channel( &self, name: &str, parent_channel_id: Option<ChannelId>, admin_id: UserId ) -> Result<CreateChannelResult>

source

pub async fn join_channel( &self, channel_id: ChannelId, user_id: UserId, connection: ConnectionId, environment: &str ) -> Result<(JoinRoom, Option<MembershipUpdated>, ChannelRole)>

source

pub async fn set_channel_visibility( &self, channel_id: ChannelId, visibility: ChannelVisibility, admin_id: UserId ) -> Result<SetChannelVisibilityResult>

source

pub async fn delete_channel( &self, channel_id: ChannelId, user_id: UserId ) -> Result<(Vec<ChannelId>, Vec<UserId>)>

source

pub async fn invite_channel_member( &self, channel_id: ChannelId, invitee_id: UserId, inviter_id: UserId, role: ChannelRole ) -> Result<InviteMemberResult>

source

pub async fn rename_channel( &self, channel_id: ChannelId, admin_id: UserId, new_name: &str ) -> Result<RenameChannelResult>

source

pub async fn respond_to_channel_invite( &self, channel_id: ChannelId, user_id: UserId, accept: bool ) -> Result<RespondToChannelInvite>

source

pub async fn remove_channel_member( &self, channel_id: ChannelId, member_id: UserId, admin_id: UserId ) -> Result<RemoveChannelMemberResult>

source

pub async fn get_channel_invites_for_user( &self, user_id: UserId ) -> Result<Vec<Channel>>

source

pub async fn get_channels_for_user( &self, user_id: UserId ) -> Result<ChannelsForUser>

source

pub async fn get_user_channels( &self, user_id: UserId, ancestor_channel: Option<&Model>, tx: &DatabaseTransaction ) -> Result<ChannelsForUser>

source

pub async fn set_channel_member_role( &self, channel_id: ChannelId, admin_id: UserId, for_user: UserId, role: ChannelRole ) -> Result<SetMemberRoleResult>

source

pub async fn get_channel_participant_details( &self, channel_id: ChannelId, user_id: UserId ) -> Result<Vec<ChannelMember>>

source

pub async fn get_channel_participants( &self, channel: &Model, tx: &DatabaseTransaction ) -> Result<Vec<UserId>>

source

pub async fn check_user_is_channel_admin( &self, channel: &Model, user_id: UserId, tx: &DatabaseTransaction ) -> Result<ChannelRole>

source

pub async fn check_user_is_channel_member( &self, channel: &Model, user_id: UserId, tx: &DatabaseTransaction ) -> Result<ChannelRole>

source

pub async fn check_user_is_channel_participant( &self, channel: &Model, user_id: UserId, tx: &DatabaseTransaction ) -> Result<ChannelRole>

source

pub async fn pending_invite_for_channel( &self, channel: &Model, user_id: UserId, tx: &DatabaseTransaction ) -> Result<Option<Model>>

source

pub async fn public_parent_channel( &self, channel: &Model, tx: &DatabaseTransaction ) -> Result<Option<Model>>

source

pub async fn public_ancestors_including_self( &self, channel: &Model, tx: &DatabaseTransaction ) -> Result<Vec<Model>>

source

pub async fn channel_role_for_user( &self, channel: &Model, user_id: UserId, tx: &DatabaseTransaction ) -> Result<Option<ChannelRole>>

source

pub async fn get_channel( &self, channel_id: ChannelId, user_id: UserId ) -> Result<Channel>

Returns the channel with the given ID

source

pub async fn get_channel_internal( &self, channel_id: ChannelId, tx: &DatabaseTransaction ) -> Result<Model>

source

pub async fn move_channel( &self, channel_id: ChannelId, new_parent_id: Option<ChannelId>, admin_id: UserId ) -> Result<Option<MoveChannelResult>>

Move a channel from one parent to another

source§

impl Database

source

pub async fn get_contacts(&self, user_id: UserId) -> Result<Vec<Contact>>

source

pub async fn is_user_busy(&self, user_id: UserId) -> Result<bool>

source

pub async fn has_contact( &self, user_id_1: UserId, user_id_2: UserId ) -> Result<bool>

source

pub async fn send_contact_request( &self, sender_id: UserId, receiver_id: UserId ) -> Result<NotificationBatch>

source

pub async fn remove_contact( &self, requester_id: UserId, responder_id: UserId ) -> Result<(bool, Option<NotificationId>)>

Returns a bool indicating whether the removed contact had originally accepted or not

Deletes the contact identified by the requester and responder ids, and then returns whether the deleted contact had originally accepted or was a pending contact request.

Arguments
  • requester_id - The user that initiates this request
  • responder_id - The user that will be removed
source

pub async fn dismiss_contact_notification( &self, user_id: UserId, contact_user_id: UserId ) -> Result<()>

source

pub async fn respond_to_contact_request( &self, responder_id: UserId, requester_id: UserId, accept: bool ) -> Result<NotificationBatch>

source§

impl Database

source

pub async fn join_channel_chat( &self, channel_id: ChannelId, connection_id: ConnectionId, user_id: UserId ) -> Result<()>

source

pub async fn channel_chat_connection_lost( &self, connection_id: ConnectionId, tx: &DatabaseTransaction ) -> Result<()>

source

pub async fn leave_channel_chat( &self, channel_id: ChannelId, connection_id: ConnectionId, _user_id: UserId ) -> Result<()>

source

pub async fn get_channel_messages( &self, channel_id: ChannelId, user_id: UserId, count: usize, before_message_id: Option<MessageId> ) -> Result<Vec<ChannelMessage>>

source

pub async fn get_channel_messages_by_id( &self, user_id: UserId, message_ids: &[MessageId] ) -> Result<Vec<ChannelMessage>>

source

pub async fn create_channel_message( &self, channel_id: ChannelId, user_id: UserId, body: &str, mentions: &[ChatMention], timestamp: OffsetDateTime, nonce: u128 ) -> Result<CreatedChannelMessage>

source

pub async fn observe_channel_message( &self, channel_id: ChannelId, user_id: UserId, message_id: MessageId ) -> Result<NotificationBatch>

source

pub async fn unseen_channel_messages( &self, user_id: UserId, channel_ids: &[ChannelId], tx: &DatabaseTransaction ) -> Result<Vec<UnseenChannelMessage>>

source

pub async fn remove_channel_message( &self, channel_id: ChannelId, message_id: MessageId, user_id: UserId ) -> Result<Vec<ConnectionId>>

source§

impl Database

source

pub async fn initialize_notification_kinds(&mut self) -> Result<()>

source

pub async fn get_notifications( &self, recipient_id: UserId, limit: usize, before_id: Option<NotificationId> ) -> Result<Vec<Notification>>

source

pub async fn create_notification( &self, recipient_id: UserId, notification: Notification, avoid_duplicates: bool, tx: &DatabaseTransaction ) -> Result<Option<(UserId, Notification)>>

Create a notification. If avoid_duplicates is set to true, then avoid creating a new notification if the given recipient already has an unread notification with the given kind and entity id.

source

pub async fn remove_notification( &self, recipient_id: UserId, notification: Notification, tx: &DatabaseTransaction ) -> Result<Option<NotificationId>>

Remove an unread notification with the given recipient, kind and entity id.

source

pub async fn mark_notification_as_read_with_response( &self, recipient_id: UserId, notification: &Notification, response: bool, tx: &DatabaseTransaction ) -> Result<Option<(UserId, Notification)>>

Populate the response for the notification with the given kind and entity id.

source

pub async fn mark_notification_as_read( &self, recipient_id: UserId, notification: &Notification, tx: &DatabaseTransaction ) -> Result<Option<(UserId, Notification)>>

source

pub async fn mark_notification_as_read_by_id( &self, recipient_id: UserId, notification_id: NotificationId ) -> Result<NotificationBatch>

source§

impl Database

source

pub async fn project_count_excluding_admins(&self) -> Result<usize>

source

pub async fn share_project( &self, room_id: RoomId, connection: ConnectionId, worktrees: &[WorktreeMetadata] ) -> Result<RoomGuard<(ProjectId, Room)>>

source

pub async fn unshare_project( &self, project_id: ProjectId, connection: ConnectionId ) -> Result<RoomGuard<(Room, Vec<ConnectionId>)>>

source

pub async fn update_project( &self, project_id: ProjectId, connection: ConnectionId, worktrees: &[WorktreeMetadata] ) -> Result<RoomGuard<(Room, Vec<ConnectionId>)>>

source

pub async fn update_worktree( &self, update: &UpdateWorktree, connection: ConnectionId ) -> Result<RoomGuard<Vec<ConnectionId>>>

source

pub async fn update_diagnostic_summary( &self, update: &UpdateDiagnosticSummary, connection: ConnectionId ) -> Result<RoomGuard<Vec<ConnectionId>>>

source

pub async fn start_language_server( &self, update: &StartLanguageServer, connection: ConnectionId ) -> Result<RoomGuard<Vec<ConnectionId>>>

source

pub async fn update_worktree_settings( &self, update: &UpdateWorktreeSettings, connection: ConnectionId ) -> Result<RoomGuard<Vec<ConnectionId>>>

source

pub async fn join_project( &self, project_id: ProjectId, connection: ConnectionId ) -> Result<RoomGuard<(Project, ReplicaId)>>

source

pub async fn leave_project( &self, project_id: ProjectId, connection: ConnectionId ) -> Result<RoomGuard<(Room, LeftProject)>>

source

pub async fn project_collaborators( &self, project_id: ProjectId, connection_id: ConnectionId ) -> Result<RoomGuard<Vec<ProjectCollaborator>>>

source

pub async fn project_connection_ids( &self, project_id: ProjectId, connection_id: ConnectionId ) -> Result<RoomGuard<HashSet<ConnectionId>>>

source

pub async fn room_id_for_project(&self, project_id: ProjectId) -> Result<RoomId>

source

pub async fn check_room_participants( &self, room_id: RoomId, leader_id: ConnectionId, follower_id: ConnectionId ) -> Result<()>

source

pub async fn follow( &self, room_id: RoomId, project_id: ProjectId, leader_connection: ConnectionId, follower_connection: ConnectionId ) -> Result<RoomGuard<Room>>

source

pub async fn unfollow( &self, room_id: RoomId, project_id: ProjectId, leader_connection: ConnectionId, follower_connection: ConnectionId ) -> Result<RoomGuard<Room>>

source§

impl Database

source

pub async fn clear_stale_room_participants( &self, room_id: RoomId, new_server_id: ServerId ) -> Result<RoomGuard<RefreshedRoom>>

source

pub async fn incoming_call_for_user( &self, user_id: UserId ) -> Result<Option<IncomingCall>>

source

pub async fn create_room( &self, user_id: UserId, connection: ConnectionId, live_kit_room: &str, release_channel: &str ) -> Result<Room>

source

pub async fn call( &self, room_id: RoomId, calling_user_id: UserId, calling_connection: ConnectionId, called_user_id: UserId, initial_project_id: Option<ProjectId> ) -> Result<RoomGuard<(Room, IncomingCall)>>

source

pub async fn call_failed( &self, room_id: RoomId, called_user_id: UserId ) -> Result<RoomGuard<Room>>

source

pub async fn decline_call( &self, expected_room_id: Option<RoomId>, user_id: UserId ) -> Result<Option<RoomGuard<Room>>>

source

pub async fn cancel_call( &self, room_id: RoomId, calling_connection: ConnectionId, called_user_id: UserId ) -> Result<RoomGuard<Room>>

source

pub async fn join_room( &self, room_id: RoomId, user_id: UserId, connection: ConnectionId, enviroment: &str ) -> Result<RoomGuard<JoinRoom>>

source

pub async fn channel_id_for_room( &self, room_id: RoomId ) -> Result<Option<ChannelId>>

source

pub async fn rejoin_room( &self, rejoin_room: RejoinRoom, user_id: UserId, connection: ConnectionId ) -> Result<RoomGuard<RejoinedRoom>>

source

pub async fn leave_room( &self, connection: ConnectionId ) -> Result<Option<RoomGuard<LeftRoom>>>

source

pub async fn update_room_participant_location( &self, room_id: RoomId, connection: ConnectionId, location: ParticipantLocation ) -> Result<RoomGuard<Room>>

source

pub async fn connection_lost(&self, connection: ConnectionId) -> Result<()>

source

pub async fn room_connection_lost( &self, connection: ConnectionId, tx: &DatabaseTransaction ) -> Result<()>

source

pub async fn get_room( &self, room_id: RoomId, tx: &DatabaseTransaction ) -> Result<Room>

source

pub async fn room_connection_ids( &self, room_id: RoomId, connection_id: ConnectionId ) -> Result<RoomGuard<HashSet<ConnectionId>>>

source§

impl Database

source

pub async fn create_server(&self, environment: &str) -> Result<ServerId>

source

pub async fn stale_server_resource_ids( &self, environment: &str, new_server_id: ServerId ) -> Result<(Vec<RoomId>, Vec<ChannelId>)>

source

pub async fn delete_stale_servers( &self, environment: &str, new_server_id: ServerId ) -> Result<()>

source§

impl Database

source

pub async fn create_user( &self, email_address: &str, admin: bool, params: NewUserParams ) -> Result<NewUserResult>

source

pub async fn get_user_by_id(&self, id: UserId) -> Result<Option<Model>>

source

pub async fn get_users_by_ids(&self, ids: Vec<UserId>) -> Result<Vec<Model>>

source

pub async fn get_user_by_github_login( &self, github_login: &str ) -> Result<Option<User>>

source

pub async fn get_or_create_user_by_github_account( &self, github_login: &str, github_user_id: Option<i32>, github_email: Option<&str> ) -> Result<Option<User>>

source

pub async fn get_all_users(&self, page: u32, limit: u32) -> Result<Vec<User>>

source

pub async fn get_user_metrics_id(&self, id: UserId) -> Result<String>

source

pub async fn set_user_connected_once( &self, id: UserId, connected_once: bool ) -> Result<()>

source

pub async fn destroy_user(&self, id: UserId) -> Result<()>

source

pub async fn fuzzy_search_users( &self, name_query: &str, limit: u32 ) -> Result<Vec<User>>

source

pub fn fuzzy_like_string(string: &str) -> String

source

pub async fn create_user_flag(&self, flag: &str) -> Result<FlagId>

source

pub async fn add_user_flag(&self, user: UserId, flag: FlagId) -> Result<()>

source

pub async fn get_user_flags(&self, user: UserId) -> Result<Vec<String>>

source§

impl Database

source

pub async fn new(options: ConnectOptions, executor: Executor) -> Result<Self>

source

pub async fn migrate( &self, migrations_path: &Path, ignore_checksum_mismatch: bool ) -> Result<Vec<(Migration, Duration)>>

source

pub async fn initialize_static_data(&mut self) -> Result<()>

source

pub async fn transaction<F, Fut, T>(&self, f: F) -> Result<T>where F: Send + Fn(TransactionHandle) -> Fut, Fut: Send + Future<Output = Result<T>>,

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

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

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

fn in_current_span(self) -> Instrumented<Self>

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

impl<T> Instrument for T

source§

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

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

fn in_current_span(self) -> Instrumented<Self>

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

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

source§

fn into(self) -> U

Calls U::from(self).

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

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

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

§

type Error = Infallible

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

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

Performs the conversion.
source§

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

§

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

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

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

Performs the conversion.
§

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

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

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

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<T> WithSubscriber for T

source§

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

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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