Skip to content

Commit

Permalink
Remove ServiceIdType
Browse files Browse the repository at this point in the history
  • Loading branch information
gferon committed Oct 31, 2024
1 parent 1b55abc commit 029b52e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 34 deletions.
8 changes: 4 additions & 4 deletions src/account_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use hmac::{Hmac, Mac};
use libsignal_protocol::{
kem, Aci, GenericSignedPreKey, IdentityKey, IdentityKeyPair,
IdentityKeyStore, KeyPair, KyberPreKeyRecord, PrivateKey, ProtocolStore,
PublicKey, SenderKeyStore, SignedPreKeyRecord, Timestamp,
PublicKey, SenderKeyStore, ServiceIdKind, SignedPreKeyRecord, Timestamp,
};
use prost::Message;
use serde::{Deserialize, Serialize};
Expand All @@ -30,8 +30,8 @@ use crate::proto::{DeviceName, SyncMessage};
use crate::provisioning::generate_registration_id;
use crate::push_service::{
AvatarWrite, DeviceActivationRequest, DeviceInfo, HttpAuthOverride,
RecaptchaAttributes, RegistrationMethod, ReqwestExt, ServiceIdType,
VerifyAccountResponse, DEFAULT_DEVICE_ID,
RecaptchaAttributes, RegistrationMethod, ReqwestExt, VerifyAccountResponse,
DEFAULT_DEVICE_ID,
};
use crate::sender::OutgoingPushMessage;
use crate::service_address::ServiceIdExt;
Expand Down Expand Up @@ -94,7 +94,7 @@ impl AccountManager {
>(
&mut self,
protocol_store: &mut P,
service_id_type: ServiceIdType,
service_id_kind: ServiceIdKind,
csprng: &mut R,
use_last_resort_key: bool,
) -> Result<(), ServiceError> {
Expand Down
21 changes: 0 additions & 21 deletions src/push_service/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,6 @@ use crate::{
utils::{serde_optional_base64, serde_phone_number},
};

#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)]
pub enum ServiceIdType {
/// Account Identity (ACI)
///
/// An account UUID without an associated phone number, probably in the future to a username
AccountIdentity,
/// Phone number identity (PNI)
///
/// A UUID associated with a phone number
PhoneNumberIdentity,
}

impl fmt::Display for ServiceIdType {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
ServiceIdType::AccountIdentity => f.write_str("aci"),
ServiceIdType::PhoneNumberIdentity => f.write_str("pni"),
}
}
}

#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct ServiceIds {
#[serde(rename = "uuid")]
Expand Down
5 changes: 2 additions & 3 deletions src/push_service/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ use zkgroup::ZkGroupDeserializationFailure;
use crate::groups_v2::GroupDecodingError;

use super::{
MismatchedDevices, ProofRequired, RegistrationLockFailure, ServiceIdType,
StaleDevices,
MismatchedDevices, ProofRequired, RegistrationLockFailure, StaleDevices,
};

#[derive(thiserror::Error, Debug)]
Expand All @@ -18,7 +17,7 @@ pub enum ServiceError {
InvalidUrl(#[from] url::ParseError),

#[error("wrong address type: {0}")]
InvalidAddressType(ServiceIdType),
InvalidAddressType(ServiceIdKind),

Check failure on line 20 in src/push_service/error.rs

View workflow job for this annotation

GitHub Actions / clippy

cannot find type `ServiceIdKind` in this scope

error[E0412]: cannot find type `ServiceIdKind` in this scope --> src/push_service/error.rs:20:24 | 20 | InvalidAddressType(ServiceIdKind), | ^^^^^^^^^^^^^ not found in this scope | help: consider importing one of these enums | 1 + use crate::protocol::ServiceIdKind; | 1 + use libsignal_protocol::ServiceIdKind; |

#[error("Error sending request: {reason}")]
SendError { reason: String },
Expand Down
12 changes: 6 additions & 6 deletions src/push_service/keys.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::collections::HashMap;

use libsignal_protocol::{
IdentityKey, PreKeyBundle, SenderCertificate, ServiceId,
IdentityKey, PreKeyBundle, SenderCertificate, ServiceId, ServiceIdKind,
};
use reqwest::Method;
use serde::Deserialize;
Expand All @@ -16,7 +16,7 @@ use crate::{

use super::{
response::ReqwestExt, HttpAuthOverride, PushService, SenderCertificateJson,
ServiceError, ServiceIdType, VerifyAccountResponse,
ServiceError, VerifyAccountResponse,
};

#[derive(Debug, Deserialize, Default)]
Expand All @@ -29,11 +29,11 @@ pub struct PreKeyStatus {
impl PushService {
pub async fn get_pre_key_status(
&mut self,
service_id_type: ServiceIdType,
service_id_kind: ServiceIdKind,
) -> Result<PreKeyStatus, ServiceError> {
self.request(
Method::GET,
Endpoint::service(format!("/v2/keys?identity={}", service_id_type)),
Endpoint::service(format!("/v2/keys?identity={}", service_id_kind)),
HttpAuthOverride::NoOverride,
)?
.send()
Expand All @@ -47,12 +47,12 @@ impl PushService {

pub async fn register_pre_keys(
&mut self,
service_id_type: ServiceIdType,
service_id_kind: ServiceIdKind,
pre_key_state: PreKeyState,
) -> Result<(), ServiceError> {
self.request(
Method::PUT,
Endpoint::service(format!("/v2/keys?identity={}", service_id_type)),
Endpoint::service(format!("/v2/keys?identity={}", service_id_kind)),
HttpAuthOverride::NoOverride,
)?
.json(&pre_key_state)
Expand Down

0 comments on commit 029b52e

Please sign in to comment.