fix: send notification count updates when private read receipts change
This commit is contained in:
parent
9aa5e99a0f
commit
33215d6099
6 changed files with 107 additions and 85 deletions
|
@ -34,13 +34,14 @@ pub fn set_read_marker_route(
|
|||
)?;
|
||||
|
||||
if let Some(event) = &body.read_receipt {
|
||||
db.rooms.edus.room_read_set(
|
||||
db.rooms.edus.private_read_set(
|
||||
&body.room_id,
|
||||
&sender_id,
|
||||
db.rooms.get_pdu_count(event)?.ok_or(Error::BadRequest(
|
||||
ErrorKind::InvalidParam,
|
||||
"Event does not exist.",
|
||||
))?,
|
||||
&db.globals,
|
||||
)?;
|
||||
|
||||
let mut user_receipts = BTreeMap::new();
|
||||
|
@ -58,7 +59,7 @@ pub fn set_read_marker_route(
|
|||
},
|
||||
);
|
||||
|
||||
db.rooms.edus.roomlatest_update(
|
||||
db.rooms.edus.readreceipt_update(
|
||||
&sender_id,
|
||||
&body.room_id,
|
||||
AnyEvent::Ephemeral(AnyEphemeralRoomEvent::Receipt(
|
||||
|
|
|
@ -81,7 +81,12 @@ pub async fn sync_events_route(
|
|||
.rev()
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let send_notification_counts = !timeline_pdus.is_empty();
|
||||
let send_notification_counts = !timeline_pdus.is_empty()
|
||||
|| db
|
||||
.rooms
|
||||
.edus
|
||||
.last_privateread_update(&sender_id, &room_id)?
|
||||
> since;
|
||||
|
||||
// They /sync response doesn't always return all messages, so we say the output is
|
||||
// limited unless there are events in non_timeline_pdus
|
||||
|
@ -242,7 +247,7 @@ pub async fn sync_events_route(
|
|||
};
|
||||
|
||||
let notification_count = if send_notification_counts {
|
||||
if let Some(last_read) = db.rooms.edus.room_read_get(&room_id, &sender_id)? {
|
||||
if let Some(last_read) = db.rooms.edus.private_read_get(&room_id, &sender_id)? {
|
||||
Some(
|
||||
(db.rooms
|
||||
.pdus_since(&sender_id, &room_id, last_read)?
|
||||
|
@ -280,20 +285,15 @@ pub async fn sync_events_route(
|
|||
let mut edus = db
|
||||
.rooms
|
||||
.edus
|
||||
.roomlatests_since(&room_id, since)?
|
||||
.readreceipts_since(&room_id, since)?
|
||||
.filter_map(|r| r.ok()) // Filter out buggy events
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
if db
|
||||
.rooms
|
||||
.edus
|
||||
.last_roomactive_update(&room_id, &db.globals)?
|
||||
> since
|
||||
{
|
||||
if db.rooms.edus.last_typing_update(&room_id, &db.globals)? > since {
|
||||
edus.push(
|
||||
serde_json::from_str(
|
||||
&serde_json::to_string(&AnySyncEphemeralRoomEvent::Typing(
|
||||
db.rooms.edus.roomactives_all(&room_id)?,
|
||||
db.rooms.edus.typings_all(&room_id)?,
|
||||
))
|
||||
.expect("event is valid, we just created it"),
|
||||
)
|
||||
|
|
|
@ -16,7 +16,7 @@ pub fn create_typing_event_route(
|
|||
let sender_id = body.sender_id.as_ref().expect("user is authenticated");
|
||||
|
||||
if body.typing {
|
||||
db.rooms.edus.roomactive_add(
|
||||
db.rooms.edus.typing_add(
|
||||
&sender_id,
|
||||
&body.room_id,
|
||||
body.timeout.map(|d| d.as_millis() as u64).unwrap_or(30000)
|
||||
|
@ -26,7 +26,7 @@ pub fn create_typing_event_route(
|
|||
} else {
|
||||
db.rooms
|
||||
.edus
|
||||
.roomactive_remove(&sender_id, &body.room_id, &db.globals)?;
|
||||
.typing_remove(&sender_id, &body.room_id, &db.globals)?;
|
||||
}
|
||||
|
||||
Ok(create_typing_event::Response.into())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue