experimental group message support

This commit is contained in:
Dan Ballard 2023-10-14 20:10:23 -07:00
parent ce64bde436
commit 11485a3d8f
1 changed files with 8 additions and 0 deletions

View File

@ -18,6 +18,9 @@ pub trait EventHandler {
fn on_new_contact(&self, cwtch: &dyn libcwtch::CwtchLib, profile: &Profile, convo_id: ConversationID) {}
#[allow(unused_variables)]
fn on_new_message_from_contact(&self, cwtch: &dyn libcwtch::CwtchLib, profile: &Profile, conversation_id: ConversationID, handle: String, timestamp_received: DateTime<FixedOffset>, message: MessageWrapper) {}
#[allow(unused_variables)]
fn on_new_message_from_group(&self, cwtch: &dyn libcwtch::CwtchLib, profile: &Profile, conversation_id: ConversationID, handle: String, timestamp_sent: DateTime<FixedOffset>, message: MessageWrapper) {}
}
/// Cwtch bot
@ -192,6 +195,11 @@ impl Imp {
None => {},
}
}
Event::NewMessageFromGroup { profile_id, conversation_id, timestamp_sent, contact_id, index, message, content_hash, picture, nick, notification, } => {
if let Some(profile )= self.profile.as_ref() {
handler.on_new_message_from_group(self.cwtch.as_ref(), profile, conversation_id.clone(), nick.clone(), timestamp_sent.clone(), message.clone())
}
}
Event::ErrUnhandled { name, data } => eprintln!("unhandled event: {}!", name),
_ => (),
};