🔊 Trace events from Matrix client callbacks to domain methods

This commit is contained in:
2024-05-21 12:22:04 +02:00
parent b5da0ee992
commit cd6506fb03
11 changed files with 405 additions and 163 deletions

View File

@@ -9,7 +9,7 @@ use async_trait::async_trait;
use futures::future::{join, join_all};
use matrix_sdk::ruma::OwnedRoomId;
use matrix_sdk::RoomState as MatrixRoomState;
use tracing::{debug, error, trace};
use tracing::{debug, debug_span, error, instrument, trace};
use super::{
common::{Avatar, UserId},
@@ -18,7 +18,6 @@ use super::{
space::SpaceId,
store_interface::{RoomStoreConsumerInterface, RoomStoreProviderInterface},
};
use crate::infrastructure::services::mozaik_builder::create_mozaik;
pub type RoomId = OwnedRoomId;
@@ -150,6 +149,7 @@ impl Room {
self.state.map(|state| state == MatrixRoomState::Invited)
}
#[instrument(name = "Room", skip_all)]
fn add_invitation(&self, invitation: Invitation) {
self.members.borrow_mut().remove(&invitation.invitee_id);
@@ -240,17 +240,44 @@ impl Room {
#[async_trait(?Send)]
impl RoomMessagingConsumerInterface for Room {
#[instrument(name = "Room", skip_all)]
async fn on_invitation(&self, invitation: Invitation) {
trace!("on_invitation");
let sender_id = invitation.sender_id.clone();
self.add_invitation(invitation);
if self.is_direct.unwrap_or(false) {
debug!("1to1 conversation, using the {} avatar", &sender_id);
if let Ok(avatar) = self.gen_room_avatar_with_members().await {
debug!("Avatar successfully generated");
self.avatar.borrow_mut().clone_from(&avatar);
if let Some(store) = self.store.borrow().as_ref() {
store.on_new_avatar(avatar);
}
}
}
}
#[instrument(name = "Room", skip_all)]
async fn on_membership(&self, member: RoomMember) {
trace!("Room::on_membership({:?})", member);
trace!("on_membership");
self.add_member(member);
}
async fn on_new_topic(&self, topic: Option<String>) {
trace!("Room::on_new_topic({:?})", topic);
#[instrument(name = "Room", skip_all)]
async fn on_new_topic(&self, _topic: Option<String>) {
trace!("on_new_topic");
}
async fn on_new_name(&self, name: Option<String>) {
trace!("Room::on_new_name({:?})", name);
#[instrument(name = "Room", skip_all)]
async fn on_new_name(&self, _name: Option<String>) {
trace!("on_new_name");
}
#[instrument(name = "Room", skip_all)]
async fn on_new_avatar(&self, avatar: Option<Avatar>) {
trace!("on_new_avatar");
}
}