Skip to content

Commit

Permalink
notify webxdc info messages as needed
Browse files Browse the repository at this point in the history
  • Loading branch information
r10s committed Nov 19, 2024
1 parent f753dbd commit 1a8cc10
Showing 1 changed file with 27 additions and 13 deletions.
40 changes: 27 additions & 13 deletions src/webxdc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,20 +315,33 @@ impl Context {

if can_info_msg {
if let Some(ref info) = status_update_item.info {
if let Some(info_msg_id) =
self.get_overwritable_info_msg_id(instance, from_id).await?
{
chat::update_msg_text_and_timestamp(
self,
instance.chat_id,
info_msg_id,
info.as_str(),
timestamp,
)
.await?;
let overwritable_info =
self.get_overwritable_info_msg_id(instance, from_id).await?;
let notify_list = status_update_item.notify;

if notify_list.is_none() && overwritable_info.is_some() {
if let Some(overwritable_info) = overwritable_info {
chat::update_msg_text_and_timestamp(
self,
instance.chat_id,
overwritable_info,
info.as_str(),
timestamp,
)
.await?;
}
} else {
// TODO: change add_info_msg_with_cmd() to emit DC_EVENT_INCOMING_MSG if update.notify refers to us
chat::add_info_msg_with_cmd(
let notify = if let Some(notify_list) = notify_list {
if let Ok(self_addr) = self.get_primary_self_addr().await {
notify_list.contains(&self_addr)
} else {
false
}
} else {
false
};

chat::add_info_msg_with_importance(
self,
instance.chat_id,
info.as_str(),
Expand All @@ -337,6 +350,7 @@ impl Context {
None,
Some(instance),
Some(from_id),
notify,
)
.await?;
}
Expand Down

0 comments on commit 1a8cc10

Please sign in to comment.