pub struct Chat {
pub id: ChatId,
pub typ: Chattype,
pub name: String,
pub visibility: ChatVisibility,
pub grpid: String,
pub blocked: Blocked,
pub param: Params,
is_sending_locations: bool,
pub mute_duration: MuteDuration,
}Expand description
An object representing a single chat in memory.
Chat objects are created using eg. Chat::load_from_db
and are not updated on database changes;
if you want an update, you have to recreate the object.
Fields§
§id: ChatIdDatabase ID.
typ: ChattypeChat type, e.g. 1:1 chat, group chat, mailing list.
name: StringChat name.
visibility: ChatVisibilityWhether the chat is archived or pinned.
grpid: StringGroup ID. For Chattype::Mailinglist – mailing list address. Empty for 1:1 chats and
ad-hoc groups.
blocked: BlockedWhether the chat is blocked, unblocked or a contact request.
param: ParamsAdditional chat parameters stored in the database.
is_sending_locations: boolIf location streaming is enabled in the chat.
mute_duration: MuteDurationDuration of the chat being muted.
Implementations§
Source§impl Chat
impl Chat
Sourcepub async fn load_from_db(context: &Context, chat_id: ChatId) -> Result<Self>
pub async fn load_from_db(context: &Context, chat_id: ChatId) -> Result<Self>
Loads chat from the database by its ID.
Sourcepub fn is_self_talk(&self) -> bool
pub fn is_self_talk(&self) -> bool
Returns whether this is the saved messages chat
Sourcepub fn is_device_talk(&self) -> bool
pub fn is_device_talk(&self) -> bool
Returns true if chat is a device chat.
Sourcepub fn is_mailing_list(&self) -> bool
pub fn is_mailing_list(&self) -> bool
Returns true if chat is a mailing list.
Sourcepub(crate) async fn why_cant_send(
&self,
context: &Context,
) -> Result<Option<CantSendReason>>
pub(crate) async fn why_cant_send( &self, context: &Context, ) -> Result<Option<CantSendReason>>
Returns None if user can send messages to this chat.
Otherwise returns a reason useful for logging.
pub(crate) async fn why_cant_send_ex( &self, context: &Context, skip_fn: &(dyn Send + Sync + Fn(&CantSendReason) -> bool), ) -> Result<Option<CantSendReason>>
Sourcepub async fn can_send(&self, context: &Context) -> Result<bool>
pub async fn can_send(&self, context: &Context) -> Result<bool>
Returns true if can send to the chat.
This function can be used by the UI to decide whether to display the input box.
Sourcepub async fn is_self_in_chat(&self, context: &Context) -> Result<bool>
pub async fn is_self_in_chat(&self, context: &Context) -> Result<bool>
Checks if the user is part of a chat and has basically the permissions to edit the chat therefore. The function does not check if the chat type allows editing of concrete elements.
pub(crate) async fn update_param(&mut self, context: &Context) -> Result<()>
Sourcepub fn get_mailinglist_addr(&self) -> Option<&str>
pub fn get_mailinglist_addr(&self) -> Option<&str>
Returns mailing list address where messages are sent to.
Sourcepub async fn get_profile_image(
&self,
context: &Context,
) -> Result<Option<PathBuf>>
pub async fn get_profile_image( &self, context: &Context, ) -> Result<Option<PathBuf>>
Returns profile image path for the chat.
Sourcepub async fn get_color(&self, context: &Context) -> Result<u32>
pub async fn get_color(&self, context: &Context) -> Result<u32>
Returns chat avatar color.
For 1:1 chats, the color is calculated from the contact’s address for address-contacts and from the OpenPGP key fingerprint for key-contacts. For group chats the color is calculated from the grpid, if present, or the chat name.
Sourcepub async fn get_info(&self, context: &Context) -> Result<ChatInfo>
pub async fn get_info(&self, context: &Context) -> Result<ChatInfo>
Returns a struct describing the current state of the chat.
This is somewhat experimental, even more so than the rest of deltachat, and the data returned is still subject to change.
Sourcepub fn get_visibility(&self) -> ChatVisibility
pub fn get_visibility(&self) -> ChatVisibility
Returns chat visibilitiy, e.g. whether it is archived or pinned.
Sourcepub fn is_contact_request(&self) -> bool
pub fn is_contact_request(&self) -> bool
Returns true if chat is a contact request.
Messages cannot be sent to such chat and read receipts are not sent until the chat is manually unblocked.
Sourcepub fn is_unpromoted(&self) -> bool
pub fn is_unpromoted(&self) -> bool
Returns true if the chat is not promoted.
Sourcepub fn is_promoted(&self) -> bool
pub fn is_promoted(&self) -> bool
Returns true if the chat is promoted. This means a message has been sent to it and it not only exists on the users device.
Sourcepub async fn is_encrypted(&self, context: &Context) -> Result<bool>
pub async fn is_encrypted(&self, context: &Context) -> Result<bool>
Returns true if the chat is encrypted.
Sourcepub fn is_sending_locations(&self) -> bool
pub fn is_sending_locations(&self) -> bool
Returns true if location streaming is enabled in the chat.
Sourcepub(crate) async fn member_list_timestamp(
&self,
context: &Context,
) -> Result<i64>
pub(crate) async fn member_list_timestamp( &self, context: &Context, ) -> Result<i64>
Returns chat member list timestamp.
Sourcepub(crate) async fn member_list_is_stale(
&self,
context: &Context,
) -> Result<bool>
pub(crate) async fn member_list_is_stale( &self, context: &Context, ) -> Result<bool>
Returns true if member list is stale, i.e. has not been updated for 60 days.
This is used primarily to detect the case where the user just restored an old backup.
Sourceasync fn prepare_msg_raw(
&mut self,
context: &Context,
msg: &mut Message,
update_msg_id: Option<MsgId>,
) -> Result<()>
async fn prepare_msg_raw( &mut self, context: &Context, msg: &mut Message, update_msg_id: Option<MsgId>, ) -> Result<()>
Adds missing values to the msg object, writes the record to the database.
If update_msg_id is set, that record is reused;
if update_msg_id is None, a new record is created.
Sourcepub(crate) async fn sync_contacts(&self, context: &Context) -> Result<()>
pub(crate) async fn sync_contacts(&self, context: &Context) -> Result<()>
Sends a SyncAction synchronising chat contacts to other devices.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Chat
impl<'de> Deserialize<'de> for Chat
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for Chat
impl RefUnwindSafe for Chat
impl Send for Chat
impl Sync for Chat
impl Unpin for Chat
impl UnwindSafe for Chat
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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,
§impl<T> CompatExt for T
impl<T> CompatExt for T
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.