Commit 750f118cfc
Unregistered key
Layout: unified · split
src/notifications.rs +7 −9
| @@ -70,7 +70,7 @@ pub async fn register_notifications( | |||
| 70 | let room_id = room.room_id().to_owned(); | 70 | let room_id = room.room_id().to_owned(); |
| 71 | match notification.event { | 71 | match notification.event { |
| 72 | RawAnySyncOrStrippedTimelineEvent::Sync(e) => { | 72 | RawAnySyncOrStrippedTimelineEvent::Sync(e) => { |
| 73 | match parse_full_notification(e, room, show_message).await { | 73 | match parse_full_notification(e, room, show_message, &store).await { |
| 74 | Ok((summary, body, server_ts)) => { | 74 | Ok((summary, body, server_ts)) => { |
| 75 | if server_ts < startup_ts { | 75 | if server_ts < startup_ts { |
| 76 | return; | 76 | return; |
| @@ -238,18 +238,16 @@ pub async fn parse_full_notification( | |||
| 238 | event: Raw<AnySyncTimelineEvent>, | 238 | event: Raw<AnySyncTimelineEvent>, |
| 239 | room: MatrixRoom, | 239 | room: MatrixRoom, |
| 240 | show_body: bool, | 240 | show_body: bool, |
| 241 | store: &AsyncProgramStore, | ||
| 241 | ) -> IambResult<(String, Option<String>, MilliSecondsSinceUnixEpoch)> { | 242 | ) -> IambResult<(String, Option<String>, MilliSecondsSinceUnixEpoch)> { |
| 242 | let event = event.deserialize().map_err(IambError::from)?; | 243 | let event = event.deserialize().map_err(IambError::from)?; |
| 243 | 244 | ||
| 244 | let server_ts = event.origin_server_ts(); | 245 | let server_ts = event.origin_server_ts(); |
| 245 | 246 | ||
| 246 | let sender_id = event.sender(); | 247 | let mut locked = store.lock().await; |
| 247 | let sender = room.get_member_no_sync(sender_id).await.map_err(IambError::from)?; | 248 | let ChatStore { rooms, settings, .. } = &mut locked.application; |
| 248 | 249 | let info = rooms.get_or_default(room.room_id().to_owned()); | |
| 249 | let sender_name = sender | 250 | let sender_name = settings.get_user_span(event.sender(), info).content; |
| 250 | .as_ref() | ||
| 251 | .and_then(|m| m.display_name()) | ||
| 252 | .unwrap_or_else(|| sender_id.localpart()); | ||
| 253 | 251 | ||
| 254 | let summary = if let Some(room_name) = room.cached_display_name() { | 252 | let summary = if let Some(room_name) = room.cached_display_name() { |
| 255 | if room.is_direct().await.map_err(IambError::from)? && sender_name == room_name.to_string() | 253 | if room.is_direct().await.map_err(IambError::from)? && sender_name == room_name.to_string() |
| @@ -263,7 +261,7 @@ pub async fn parse_full_notification( | |||
| 263 | }; | 261 | }; |
| 264 | 262 | ||
| 265 | let body = if show_body { | 263 | let body = if show_body { |
| 266 | event_notification_body(&event, sender_name).map(truncate) | 264 | event_notification_body(&event, &sender_name).map(truncate) |
| 267 | } else { | 265 | } else { |
| 268 | None | 266 | None |
| 269 | }; | 267 | }; |