support timestamped appservice messaging

Co-authored-by: strawberry <strawberry@puppygock.gay>
Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
Matthias Ahouansou 2024-08-14 20:01:34 -04:00 committed by Jason Volk
parent 66679c7522
commit 2d9aab2e79
14 changed files with 69 additions and 5 deletions

View file

@ -403,6 +403,7 @@ pub(crate) async fn kick_user_route(
unsigned: None,
state_key: Some(body.user_id.to_string()),
redacts: None,
timestamp: None,
},
sender_user,
&body.room_id,
@ -465,6 +466,7 @@ pub(crate) async fn ban_user_route(
unsigned: None,
state_key: Some(body.user_id.to_string()),
redacts: None,
timestamp: None,
},
sender_user,
&body.room_id,
@ -512,6 +514,7 @@ pub(crate) async fn unban_user_route(
unsigned: None,
state_key: Some(body.user_id.to_string()),
redacts: None,
timestamp: None,
},
sender_user,
&body.room_id,
@ -1100,6 +1103,7 @@ async fn join_room_by_id_helper_local(
unsigned: None,
state_key: Some(sender_user.to_string()),
redacts: None,
timestamp: None,
},
sender_user,
room_id,
@ -1412,6 +1416,7 @@ pub(crate) async fn invite_helper(
unsigned: None,
state_key: Some(user_id.to_string()),
redacts: None,
timestamp: None,
},
sender_user,
room_id,
@ -1523,6 +1528,7 @@ pub(crate) async fn invite_helper(
unsigned: None,
state_key: Some(user_id.to_string()),
redacts: None,
timestamp: None,
},
sender_user,
room_id,
@ -1640,6 +1646,7 @@ pub async fn leave_room(services: &Services, user_id: &UserId, room_id: &RoomId,
unsigned: None,
state_key: Some(user_id.to_string()),
redacts: None,
timestamp: None,
},
user_id,
room_id,

View file

@ -84,6 +84,11 @@ pub(crate) async fn send_message_event_route(
unsigned: Some(unsigned),
state_key: None,
redacts: None,
timestamp: if body.appservice_info.is_some() {
body.timestamp
} else {
None
},
},
sender_user,
&body.room_id,

View file

@ -295,6 +295,7 @@ pub async fn update_displayname(
unsigned: None,
state_key: Some(user_id.to_string()),
redacts: None,
timestamp: None,
},
room_id,
))
@ -355,6 +356,7 @@ pub async fn update_avatar_url(
unsigned: None,
state_key: Some(user_id.to_string()),
redacts: None,
timestamp: None,
},
room_id,
))

View file

@ -34,6 +34,7 @@ pub(crate) async fn redact_event_route(
unsigned: None,
state_key: None,
redacts: Some(body.event_id.into()),
timestamp: None,
},
sender_user,
&body.room_id,

View file

@ -197,6 +197,7 @@ pub(crate) async fn create_room_route(
unsigned: None,
state_key: Some(String::new()),
redacts: None,
timestamp: None,
},
sender_user,
&room_id,
@ -225,6 +226,7 @@ pub(crate) async fn create_room_route(
unsigned: None,
state_key: Some(sender_user.to_string()),
redacts: None,
timestamp: None,
},
sender_user,
&room_id,
@ -262,6 +264,7 @@ pub(crate) async fn create_room_route(
unsigned: None,
state_key: Some(String::new()),
redacts: None,
timestamp: None,
},
sender_user,
&room_id,
@ -285,6 +288,7 @@ pub(crate) async fn create_room_route(
unsigned: None,
state_key: Some(String::new()),
redacts: None,
timestamp: None,
},
sender_user,
&room_id,
@ -311,6 +315,7 @@ pub(crate) async fn create_room_route(
unsigned: None,
state_key: Some(String::new()),
redacts: None,
timestamp: None,
},
sender_user,
&room_id,
@ -330,6 +335,7 @@ pub(crate) async fn create_room_route(
unsigned: None,
state_key: Some(String::new()),
redacts: None,
timestamp: None,
},
sender_user,
&room_id,
@ -352,6 +358,7 @@ pub(crate) async fn create_room_route(
unsigned: None,
state_key: Some(String::new()),
redacts: None,
timestamp: None,
},
sender_user,
&room_id,
@ -405,6 +412,7 @@ pub(crate) async fn create_room_route(
unsigned: None,
state_key: Some(String::new()),
redacts: None,
timestamp: None,
},
sender_user,
&room_id,
@ -427,6 +435,7 @@ pub(crate) async fn create_room_route(
unsigned: None,
state_key: Some(String::new()),
redacts: None,
timestamp: None,
},
sender_user,
&room_id,
@ -581,6 +590,7 @@ pub(crate) async fn upgrade_room_route(
unsigned: None,
state_key: Some(String::new()),
redacts: None,
timestamp: None,
},
sender_user,
&body.room_id,
@ -672,6 +682,7 @@ pub(crate) async fn upgrade_room_route(
unsigned: None,
state_key: Some(String::new()),
redacts: None,
timestamp: None,
},
sender_user,
&replacement_room,
@ -700,6 +711,7 @@ pub(crate) async fn upgrade_room_route(
unsigned: None,
state_key: Some(sender_user.to_string()),
redacts: None,
timestamp: None,
},
sender_user,
&replacement_room,
@ -728,6 +740,7 @@ pub(crate) async fn upgrade_room_route(
unsigned: None,
state_key: Some(String::new()),
redacts: None,
timestamp: None,
},
sender_user,
&replacement_room,
@ -786,6 +799,7 @@ pub(crate) async fn upgrade_room_route(
unsigned: None,
state_key: Some(String::new()),
redacts: None,
timestamp: None,
},
sender_user,
&body.room_id,

View file

@ -43,6 +43,11 @@ pub(crate) async fn send_state_event_for_key_route(
&body.event_type,
&body.body.body,
body.state_key.clone(),
if body.appservice_info.is_some() {
body.timestamp
} else {
None
},
)
.await?
.into(),
@ -172,7 +177,7 @@ pub(crate) async fn get_state_events_for_empty_key_route(
async fn send_state_event_for_key_helper(
services: &Services, sender: &UserId, room_id: &RoomId, event_type: &StateEventType,
json: &Raw<AnyStateEventContent>, state_key: String,
json: &Raw<AnyStateEventContent>, state_key: String, timestamp: Option<ruma::MilliSecondsSinceUnixEpoch>,
) -> Result<Arc<EventId>> {
allowed_to_send_state_event(services, room_id, event_type, json).await?;
let state_lock = services.rooms.state.mutex.lock(room_id).await;
@ -186,6 +191,7 @@ async fn send_state_event_for_key_helper(
unsigned: None,
state_key: Some(state_key),
redacts: None,
timestamp,
},
sender,
room_id,

View file

@ -139,6 +139,7 @@ pub(crate) async fn create_join_event_template_route(
unsigned: None,
state_key: Some(body.user_id.to_string()),
redacts: None,
timestamp: None,
},
&body.user_id,
&body.room_id,

View file

@ -57,6 +57,7 @@ pub(crate) async fn create_leave_event_template_route(
unsigned: None,
state_key: Some(body.user_id.to_string()),
redacts: None,
timestamp: None,
},
&body.user_id,
&body.room_id,