Skip to content

Commit 5a32f00

Browse files
committed
Rename create_device -> upsert_device
1 parent c649603 commit 5a32f00

File tree

8 files changed

+20
-20
lines changed

8 files changed

+20
-20
lines changed

crates/handlers/src/compat/login.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ pub(crate) async fn post(
411411
// Now we can create the device on the homeserver, without holding the
412412
// transaction
413413
if let Err(err) = homeserver
414-
.create_device(
414+
.upsert_device(
415415
&user.username,
416416
device.as_str(),
417417
session.human_name.as_deref(),

crates/handlers/src/graphql/mutations/oauth2_session.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ impl OAuth2SessionMutations {
215215
for scope in &*session.scope {
216216
if let Some(device) = Device::from_scope_token(scope) {
217217
homeserver
218-
.create_device(&user.username, device.as_str(), None)
218+
.upsert_device(&user.username, device.as_str(), None)
219219
.await
220220
.context("Failed to provision device")?;
221221
}

crates/handlers/src/oauth2/token.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ async fn authorization_code_grant(
578578
for scope in &*session.scope {
579579
if let Some(device) = Device::from_scope_token(scope) {
580580
homeserver
581-
.create_device(
581+
.upsert_device(
582582
&browser_session.user.username,
583583
device.as_str(),
584584
Some(&device_name),
@@ -957,7 +957,7 @@ async fn device_code_grant(
957957
for scope in &*session.scope {
958958
if let Some(device) = Device::from_scope_token(scope) {
959959
homeserver
960-
.create_device(&browser_session.user.username, device.as_str(), None)
960+
.upsert_device(&browser_session.user.username, device.as_str(), None)
961961
.await
962962
.map_err(RouteError::ProvisionDeviceFailed)?;
963963
}

crates/matrix-synapse/src/legacy.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ impl HomeserverConnection for SynapseConnection {
308308
}
309309

310310
#[tracing::instrument(
311-
name = "homeserver.create_device",
311+
name = "homeserver.upsert_device",
312312
skip_all,
313313
fields(
314314
matrix.homeserver = self.homeserver,
@@ -317,7 +317,7 @@ impl HomeserverConnection for SynapseConnection {
317317
),
318318
err(Debug),
319319
)]
320-
async fn create_device(
320+
async fn upsert_device(
321321
&self,
322322
localpart: &str,
323323
device_id: &str,
@@ -513,7 +513,7 @@ impl HomeserverConnection for SynapseConnection {
513513
// Then, create the devices that are missing. There is no batching API to do
514514
// this, so we do this sequentially, which is fine as the API is idempotent.
515515
for device_id in devices.difference(&existing_devices) {
516-
self.create_device(localpart, device_id, None).await?;
516+
self.upsert_device(localpart, device_id, None).await?;
517517
}
518518

519519
Ok(())

crates/matrix-synapse/src/modern.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ impl HomeserverConnection for SynapseConnection {
227227
}
228228

229229
#[tracing::instrument(
230-
name = "homeserver.create_device",
230+
name = "homeserver.upsert_device",
231231
skip_all,
232232
fields(
233233
matrix.homeserver = self.homeserver,
@@ -236,7 +236,7 @@ impl HomeserverConnection for SynapseConnection {
236236
),
237237
err(Debug),
238238
)]
239-
async fn create_device(
239+
async fn upsert_device(
240240
&self,
241241
localpart: &str,
242242
device_id: &str,
@@ -257,7 +257,7 @@ impl HomeserverConnection for SynapseConnection {
257257
};
258258

259259
let response = self
260-
.post("_synapse/mas/create_device")
260+
.post("_synapse/mas/upsert_device")
261261
.json(&body)
262262
.send_traced()
263263
.await

crates/matrix/src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ pub trait HomeserverConnection: Send + Sync {
254254
///
255255
/// Returns an error if the homeserver is unreachable or the device could
256256
/// not be created.
257-
async fn create_device(
257+
async fn upsert_device(
258258
&self,
259259
localpart: &str,
260260
device_id: &str,
@@ -396,14 +396,14 @@ impl<T: HomeserverConnection + Send + Sync + ?Sized> HomeserverConnection for &T
396396
(**self).is_localpart_available(localpart).await
397397
}
398398

399-
async fn create_device(
399+
async fn upsert_device(
400400
&self,
401401
localpart: &str,
402402
device_id: &str,
403403
initial_display_name: Option<&str>,
404404
) -> Result<(), anyhow::Error> {
405405
(**self)
406-
.create_device(localpart, device_id, initial_display_name)
406+
.upsert_device(localpart, device_id, initial_display_name)
407407
.await
408408
}
409409

@@ -474,14 +474,14 @@ impl<T: HomeserverConnection + ?Sized> HomeserverConnection for Arc<T> {
474474
(**self).is_localpart_available(localpart).await
475475
}
476476

477-
async fn create_device(
477+
async fn upsert_device(
478478
&self,
479479
localpart: &str,
480480
device_id: &str,
481481
initial_display_name: Option<&str>,
482482
) -> Result<(), anyhow::Error> {
483483
(**self)
484-
.create_device(localpart, device_id, initial_display_name)
484+
.upsert_device(localpart, device_id, initial_display_name)
485485
.await
486486
}
487487

crates/matrix/src/mock.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ impl crate::HomeserverConnection for HomeserverConnection {
109109
Ok(!users.contains_key(&mxid))
110110
}
111111

112-
async fn create_device(
112+
async fn upsert_device(
113113
&self,
114114
localpart: &str,
115115
device_id: &str,
@@ -223,7 +223,7 @@ mod tests {
223223
assert_eq!(conn.mxid("test"), mxid);
224224

225225
assert!(conn.query_user("test").await.is_err());
226-
assert!(conn.create_device("test", device, None).await.is_err());
226+
assert!(conn.upsert_device("test", device, None).await.is_err());
227227
assert!(conn.delete_device("test", device).await.is_err());
228228

229229
let request = ProvisionRequest::new("test", "test")
@@ -254,9 +254,9 @@ mod tests {
254254
assert!(conn.delete_device("test", device).await.is_ok());
255255

256256
// Create the device
257-
assert!(conn.create_device("test", device, None).await.is_ok());
257+
assert!(conn.upsert_device("test", device, None).await.is_ok());
258258
// Create the same device again
259-
assert!(conn.create_device("test", device, None).await.is_ok());
259+
assert!(conn.upsert_device("test", device, None).await.is_ok());
260260

261261
// XXX: there is no API to query devices yet in the trait
262262
// Delete the device

crates/matrix/src/readonly.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ impl<C: HomeserverConnection> HomeserverConnection for ReadOnlyHomeserverConnect
4040
self.inner.is_localpart_available(localpart).await
4141
}
4242

43-
async fn create_device(
43+
async fn upsert_device(
4444
&self,
4545
_localpart: &str,
4646
_device_id: &str,

0 commit comments

Comments
 (0)