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

@ -71,6 +71,7 @@ pub async fn create_admin_room(services: &Services) -> Result<()> {
unsigned: None,
state_key: Some(String::new()),
redacts: None,
timestamp: None,
},
server_user,
&room_id,
@ -99,6 +100,7 @@ pub async fn create_admin_room(services: &Services) -> Result<()> {
unsigned: None,
state_key: Some(server_user.to_string()),
redacts: None,
timestamp: None,
},
server_user,
&room_id,
@ -124,6 +126,7 @@ pub async fn create_admin_room(services: &Services) -> Result<()> {
unsigned: None,
state_key: Some(String::new()),
redacts: None,
timestamp: None,
},
server_user,
&room_id,
@ -143,6 +146,7 @@ pub async fn create_admin_room(services: &Services) -> Result<()> {
unsigned: None,
state_key: Some(String::new()),
redacts: None,
timestamp: None,
},
server_user,
&room_id,
@ -162,6 +166,7 @@ pub async fn create_admin_room(services: &Services) -> Result<()> {
unsigned: None,
state_key: Some(String::new()),
redacts: None,
timestamp: None,
},
server_user,
&room_id,
@ -181,6 +186,7 @@ pub async fn create_admin_room(services: &Services) -> Result<()> {
unsigned: None,
state_key: Some(String::new()),
redacts: None,
timestamp: None,
},
server_user,
&room_id,
@ -201,6 +207,7 @@ pub async fn create_admin_room(services: &Services) -> Result<()> {
unsigned: None,
state_key: Some(String::new()),
redacts: None,
timestamp: None,
},
server_user,
&room_id,
@ -221,6 +228,7 @@ pub async fn create_admin_room(services: &Services) -> Result<()> {
unsigned: None,
state_key: Some(String::new()),
redacts: None,
timestamp: None,
},
server_user,
&room_id,
@ -245,6 +253,7 @@ pub async fn create_admin_room(services: &Services) -> Result<()> {
unsigned: None,
state_key: Some(String::new()),
redacts: None,
timestamp: None,
},
server_user,
&room_id,
@ -271,6 +280,7 @@ pub async fn create_admin_room(services: &Services) -> Result<()> {
unsigned: None,
state_key: Some(String::new()),
redacts: None,
timestamp: None,
},
server_user,
&room_id,

View file

@ -50,6 +50,7 @@ impl super::Service {
unsigned: None,
state_key: Some(user_id.to_string()),
redacts: None,
timestamp: None,
},
server_user,
&room_id,
@ -75,6 +76,7 @@ impl super::Service {
unsigned: None,
state_key: Some(user_id.to_string()),
redacts: None,
timestamp: None,
},
user_id,
&room_id,
@ -100,6 +102,7 @@ impl super::Service {
unsigned: None,
state_key: Some(String::new()),
redacts: None,
timestamp: None,
},
server_user,
&room_id,
@ -119,6 +122,7 @@ impl super::Service {
unsigned: None,
state_key: None,
redacts: None,
timestamp: None,
},
server_user,
&room_id,

View file

@ -260,6 +260,7 @@ impl Service {
unsigned: None,
state_key: None,
redacts: None,
timestamp: None,
};
if let Err(e) = self
@ -289,6 +290,7 @@ impl Service {
unsigned: None,
state_key: None,
redacts: None,
timestamp: None,
};
self.services

View file

@ -350,6 +350,7 @@ impl Service {
unsigned: None,
state_key: Some(target_user.into()),
redacts: None,
timestamp: None,
};
Ok(self

View file

@ -638,6 +638,7 @@ impl Service {
unsigned,
state_key,
redacts,
timestamp,
} = pdu_builder;
let prev_events: Vec<_> = self
@ -705,9 +706,14 @@ impl Service {
room_id: room_id.to_owned(),
sender: sender.to_owned(),
origin: None,
origin_server_ts: utils::millis_since_unix_epoch()
.try_into()
.expect("time is valid"),
origin_server_ts: timestamp.map_or_else(
|| {
utils::millis_since_unix_epoch()
.try_into()
.expect("u64 fits into UInt")
},
|ts| ts.get(),
),
kind: event_type,
content,
state_key,