pub struct ChatId(u32);
Expand description
Chat ID, including reserved IDs.
Some chat IDs are reserved to identify special chat types. This type can represent both the special as well as normal chats.
Tuple Fields§
§0: u32
Implementations§
source§impl ChatId
impl ChatId
sourcepub fn is_unset(self) -> bool
pub fn is_unset(self) -> bool
An unset ChatId
This is transitional and should not be used in new code.
sourcepub fn is_special(self) -> bool
pub fn is_special(self) -> bool
Whether the chat ID signifies a special chat.
This kind of chat ID can not be used for real chats.
sourcepub fn is_trash(self) -> bool
pub fn is_trash(self) -> bool
Chat ID for messages which need to be deleted.
Messages which should be deleted get this chat ID and are deleted later. Deleted messages need to stay around as long as they are not deleted on the server so that their rfc724_mid remains known and downloading them again can be avoided.
sourcepub fn is_archived_link(self) -> bool
pub fn is_archived_link(self) -> bool
Chat ID signifying there are any number of archived chats.
This chat ID can be returned in a Chatlist
and signals to
the UI to include a link to the archived chats.
sourcepub fn is_alldone_hint(self) -> bool
pub fn is_alldone_hint(self) -> bool
Virtual chat ID signalling there are only archived chats.
This can be included in the chatlist if the
DC_GCL_ADD_ALLDONE_HINT
flag is used to build the
Chatlist
.
sourcepub(crate) fn lookup_by_message(msg: &Message) -> Option<Self>
pub(crate) fn lookup_by_message(msg: &Message) -> Option<Self>
Returns ChatId
of a chat that msg
belongs to.
sourcepub async fn lookup_by_contact(
context: &Context,
contact_id: ContactId,
) -> Result<Option<Self>>
pub async fn lookup_by_contact( context: &Context, contact_id: ContactId, ) -> Result<Option<Self>>
Returns the ChatId
for the 1:1 chat with contact_id
if it exists and is not blocked.
If the chat does not exist or is blocked, None
is returned.
sourcepub(crate) async fn get_for_contact(
context: &Context,
contact_id: ContactId,
) -> Result<Self>
pub(crate) async fn get_for_contact( context: &Context, contact_id: ContactId, ) -> Result<Self>
Returns the ChatId
for the 1:1 chat with contact_id
.
If the chat does not yet exist an unblocked chat (Blocked::Not
) is created.
This is an internal API, if a user action needs to get a chat
ChatId::create_for_contact
should be used as this also scales up the
Contact
’s origin.
sourcepub async fn create_for_contact(
context: &Context,
contact_id: ContactId,
) -> Result<Self>
pub async fn create_for_contact( context: &Context, contact_id: ContactId, ) -> Result<Self>
Returns the unblocked 1:1 chat with contact_id
.
This should be used when a user action creates a chat 1:1, it ensures the chat
exists, is unblocked and scales the Contact
’s origin.
sourcepub(crate) async fn create_for_contact_with_blocked(
context: &Context,
contact_id: ContactId,
create_blocked: Blocked,
) -> Result<Self>
pub(crate) async fn create_for_contact_with_blocked( context: &Context, contact_id: ContactId, create_blocked: Blocked, ) -> Result<Self>
Same as create_for_contact()
with an additional create_blocked
parameter
that is used in case the chat does not exist or to unblock existing chats.
create_blocked
won’t block already unblocked chats again.
sourcepub(crate) async fn create_multiuser_record(
context: &Context,
chattype: Chattype,
grpid: &str,
grpname: &str,
create_blocked: Blocked,
create_protected: ProtectionStatus,
param: Option<String>,
timestamp: i64,
) -> Result<Self>
pub(crate) async fn create_multiuser_record( context: &Context, chattype: Chattype, grpid: &str, grpname: &str, create_blocked: Blocked, create_protected: ProtectionStatus, param: Option<String>, timestamp: i64, ) -> Result<Self>
Create a group or mailinglist raw database record with the given parameters. The function does not add SELF nor checks if the record already exists.
async fn set_selfavatar_timestamp( self, context: &Context, timestamp: i64, ) -> Result<()>
sourcepub(crate) async fn set_blocked(
self,
context: &Context,
new_blocked: Blocked,
) -> Result<bool>
pub(crate) async fn set_blocked( self, context: &Context, new_blocked: Blocked, ) -> Result<bool>
Updates chat blocked status.
Returns true if the value was modified.
sourcepub async fn block(self, context: &Context) -> Result<()>
pub async fn block(self, context: &Context) -> Result<()>
Blocks the chat as a result of explicit user action.
pub(crate) async fn block_ex(self, context: &Context, sync: Sync) -> Result<()>
pub(crate) async fn unblock_ex( self, context: &Context, sync: Sync, ) -> Result<()>
sourcepub async fn accept(self, context: &Context) -> Result<()>
pub async fn accept(self, context: &Context) -> Result<()>
Accept the contact request.
Unblocks the chat and scales up origin of contacts.
pub(crate) async fn accept_ex(self, context: &Context, sync: Sync) -> Result<()>
sourcepub(crate) async fn inner_set_protection(
self,
context: &Context,
protect: ProtectionStatus,
) -> Result<bool>
pub(crate) async fn inner_set_protection( self, context: &Context, protect: ProtectionStatus, ) -> Result<bool>
Sets protection without sending a message.
Returns whether the protection status was actually modified.
sourcepub(crate) async fn add_protection_msg(
self,
context: &Context,
protect: ProtectionStatus,
contact_id: Option<ContactId>,
timestamp_sort: i64,
) -> Result<()>
pub(crate) async fn add_protection_msg( self, context: &Context, protect: ProtectionStatus, contact_id: Option<ContactId>, timestamp_sort: i64, ) -> Result<()>
Adds an info message to the chat, telling the user that the protection status changed.
Params:
contact_id
: In a 1:1 chat, pass the chat partner’s contact id.timestamp_sort
is used as the timestamp of the added message and should be the timestamp of the change happening.
sourceasync fn set_protection_for_timestamp_sort(
self,
context: &Context,
protect: ProtectionStatus,
timestamp_sort: i64,
contact_id: Option<ContactId>,
) -> Result<()>
async fn set_protection_for_timestamp_sort( self, context: &Context, protect: ProtectionStatus, timestamp_sort: i64, contact_id: Option<ContactId>, ) -> Result<()>
Sets protection and adds a message.
timestamp_sort
is used as the timestamp of the added message
and should be the timestamp of the change happening.
sourcepub(crate) async fn set_protection(
self,
context: &Context,
protect: ProtectionStatus,
timestamp_sent: i64,
contact_id: Option<ContactId>,
) -> Result<()>
pub(crate) async fn set_protection( self, context: &Context, protect: ProtectionStatus, timestamp_sent: i64, contact_id: Option<ContactId>, ) -> Result<()>
Sets protection and sends or adds a message.
timestamp_sent
is the “sent” timestamp of a message caused the protection state change.
sourcepub(crate) async fn set_protection_for_contact(
context: &Context,
contact_id: ContactId,
timestamp: i64,
) -> Result<()>
pub(crate) async fn set_protection_for_contact( context: &Context, contact_id: ContactId, timestamp: i64, ) -> Result<()>
Sets the 1:1 chat with the given address to ProtectionStatus::Protected,
and posts a SystemMessage::ChatProtectionEnabled
into it.
If necessary, creates a hidden chat for this.
sourcepub async fn set_visibility(
self,
context: &Context,
visibility: ChatVisibility,
) -> Result<()>
pub async fn set_visibility( self, context: &Context, visibility: ChatVisibility, ) -> Result<()>
Archives or unarchives a chat.
pub(crate) async fn set_visibility_ex( self, context: &Context, sync: Sync, visibility: ChatVisibility, ) -> Result<()>
sourcepub async fn unarchive_if_not_muted(
self,
context: &Context,
msg_state: MessageState,
) -> Result<()>
pub async fn unarchive_if_not_muted( self, context: &Context, msg_state: MessageState, ) -> Result<()>
Unarchives a chat that is archived and not muted.
Needed after a message is added to a chat so that the chat gets a normal visibility again.
msg_state
is the state of the message. Matters only for incoming messages currently. For
multiple outgoing messages the function may be called once with MessageState::Undefined.
Sending an appropriate event is up to the caller.
Also emits DC_EVENT_MSGS_CHANGED for DC_CHAT_ID_ARCHIVED_LINK when the number of archived
chats with unread messages increases (which is possible if the chat is muted).
sourcepub(crate) fn emit_msg_event(
self,
context: &Context,
msg_id: MsgId,
important: bool,
)
pub(crate) fn emit_msg_event( self, context: &Context, msg_id: MsgId, important: bool, )
Emits an appropriate event for a message. important
is whether a notification should be
shown.
sourcepub async fn set_draft(
self,
context: &Context,
msg: Option<&mut Message>,
) -> Result<()>
pub async fn set_draft( self, context: &Context, msg: Option<&mut Message>, ) -> Result<()>
Sets draft message.
Passing None
as message just deletes the draft
sourceasync fn get_draft_msg_id(self, context: &Context) -> Result<Option<MsgId>>
async fn get_draft_msg_id(self, context: &Context) -> Result<Option<MsgId>>
Returns ID of the draft message, if there is one.
sourcepub async fn get_draft(self, context: &Context) -> Result<Option<Message>>
pub async fn get_draft(self, context: &Context) -> Result<Option<Message>>
Returns draft message, if there is one.
sourceasync fn maybe_delete_draft(self, context: &Context) -> Result<bool>
async fn maybe_delete_draft(self, context: &Context) -> Result<bool>
Deletes draft message, if there is one.
Returns true
, if message was deleted, false
otherwise.
sourceasync fn do_set_draft(
self,
context: &Context,
msg: &mut Message,
) -> Result<bool>
async fn do_set_draft( self, context: &Context, msg: &mut Message, ) -> Result<bool>
Set provided message as draft message for specified chat. Returns true if the draft was added or updated in place.
sourcepub async fn get_msg_cnt(self, context: &Context) -> Result<usize>
pub async fn get_msg_cnt(self, context: &Context) -> Result<usize>
Returns number of messages in a chat.
sourcepub async fn get_fresh_msg_cnt(self, context: &Context) -> Result<usize>
pub async fn get_fresh_msg_cnt(self, context: &Context) -> Result<usize>
Returns the number of fresh messages in the chat.
sourcepub(crate) async fn get_timestamp(
self,
context: &Context,
) -> Result<Option<i64>>
pub(crate) async fn get_timestamp( self, context: &Context, ) -> Result<Option<i64>>
Returns timestamp of the latest message in the chat.
sourcepub async fn get_similar_chat_ids(
self,
context: &Context,
) -> Result<Vec<(ChatId, f64)>>
pub async fn get_similar_chat_ids( self, context: &Context, ) -> Result<Vec<(ChatId, f64)>>
Returns a list of active similar chat IDs sorted by similarity metric.
Jaccard similarity coefficient is used to estimate similarity of chat member sets.
Chat is considered active if something was posted there within the last 42 days.
sourcepub async fn get_similar_chatlist(self, context: &Context) -> Result<Chatlist>
pub async fn get_similar_chatlist(self, context: &Context) -> Result<Chatlist>
Returns similar chats as a Chatlist
.
pub(crate) async fn get_param(self, context: &Context) -> Result<Params>
sourcepub(crate) async fn is_unpromoted(self, context: &Context) -> Result<bool>
pub(crate) async fn is_unpromoted(self, context: &Context) -> Result<bool>
Returns true if the chat is not promoted.
sourcepub(crate) async fn is_promoted(self, context: &Context) -> Result<bool>
pub(crate) async fn is_promoted(self, context: &Context) -> Result<bool>
Returns true if the chat is promoted.
sourcepub async fn is_self_talk(self, context: &Context) -> Result<bool>
pub async fn is_self_talk(self, context: &Context) -> Result<bool>
Returns true if chat is a saved messages chat.
sourcepub async fn is_device_talk(self, context: &Context) -> Result<bool>
pub async fn is_device_talk(self, context: &Context) -> Result<bool>
Returns true if chat is a device chat.
sourcepub(crate) async fn get_member_list_timestamp(
self,
context: &Context,
) -> Result<i64>
pub(crate) async fn get_member_list_timestamp( self, context: &Context, ) -> Result<i64>
Returns chat member list timestamp.
async fn parent_query<T, F>( self, context: &Context, fields: &str, state_out_min: MessageState, f: F, ) -> Result<Option<T>>
async fn get_parent_mime_headers( self, context: &Context, state_out_min: MessageState, ) -> Result<Option<(String, String, String)>>
sourcepub async fn get_encryption_info(self, context: &Context) -> Result<String>
pub async fn get_encryption_info(self, context: &Context) -> Result<String>
Returns multi-line text summary of encryption preferences of all chat contacts.
This can be used to find out if encryption is not available because keys for some users are missing or simply because the majority of the users in a group prefer plaintext emails.
To get more verbose summary for a contact, including its key fingerprint, use Contact::get_encrinfo
.
sourcepub fn to_u32(self) -> u32
pub fn to_u32(self) -> u32
Bad evil escape hatch.
Avoid using this, eventually types should be cleaned up enough that it is no longer necessary.
pub(crate) async fn reset_gossiped_timestamp( self, context: &Context, ) -> Result<()>
sourcepub async fn get_gossiped_timestamp(self, context: &Context) -> Result<i64>
pub async fn get_gossiped_timestamp(self, context: &Context) -> Result<i64>
Get timestamp of the last gossip sent in the chat. Zero return value means that gossip was never sent.
pub(crate) async fn set_gossiped_timestamp( self, context: &Context, timestamp: i64, ) -> Result<()>
sourcepub async fn is_protected(self, context: &Context) -> Result<ProtectionStatus>
pub async fn is_protected(self, context: &Context) -> Result<ProtectionStatus>
Returns true if the chat is protected.
sourcepub(crate) async fn calc_sort_timestamp(
self,
context: &Context,
message_timestamp: i64,
always_sort_to_bottom: bool,
received: bool,
incoming: bool,
) -> Result<i64>
pub(crate) async fn calc_sort_timestamp( self, context: &Context, message_timestamp: i64, always_sort_to_bottom: bool, received: bool, incoming: bool, ) -> Result<i64>
Returns the sort timestamp for a new message in the chat.
message_timestamp
should be either the message “sent” timestamp or a timestamp of the
corresponding event in case of a system message (usually the current system time).
always_sort_to_bottom
makes this adjust the returned timestamp up so that the message goes
to the chat bottom.
received
– whether the message is received. Otherwise being sent.
incoming
– whether the message is incoming.
sourcepub(crate) fn spawn_securejoin_wait(self, context: &Context, timeout: u64)
pub(crate) fn spawn_securejoin_wait(self, context: &Context, timeout: u64)
Spawns a task checking after a timeout whether the SecureJoin has finished for the 1:1 chat and otherwise notifying the user accordingly.
source§impl ChatId
impl ChatId
sourcepub async fn get_ephemeral_timer(self, context: &Context) -> Result<Timer>
pub async fn get_ephemeral_timer(self, context: &Context) -> Result<Timer>
Get ephemeral message timer value in seconds.
Trait Implementations§
source§impl<'de> Deserialize<'de> for ChatId
impl<'de> Deserialize<'de> for ChatId
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>,
source§impl FromSql for ChatId
impl FromSql for ChatId
Allow converting an SQLite integer directly into ChatId.
source§fn column_result(value: ValueRef<'_>) -> FromSqlResult<Self>
fn column_result(value: ValueRef<'_>) -> FromSqlResult<Self>
source§impl Ord for ChatId
impl Ord for ChatId
source§impl PartialOrd for ChatId
impl PartialOrd for ChatId
source§impl ToSql for ChatId
impl ToSql for ChatId
impl Copy for ChatId
impl Eq for ChatId
impl StructuralPartialEq for ChatId
Auto Trait Implementations§
impl Freeze for ChatId
impl RefUnwindSafe for ChatId
impl Send for ChatId
impl Sync for ChatId
impl Unpin for ChatId
impl UnwindSafe for ChatId
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,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.