Skip to content

Commit 937dc64

Browse files
committed
Fixes
1 parent 7685b82 commit 937dc64

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

src/aps.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,13 @@ impl APSConnectionResource {
646646
}
647647

648648
pub async fn send(&self, message: APSMessage) -> Result<(), PushError> {
649+
info!("Attempting to send");
650+
// during init can be none
651+
let manager_lock = self.manager.lock().await;
652+
if let Some(manager_lock) = &*manager_lock {
653+
manager_lock.upgrade().unwrap().ensure_not_failed()?;
654+
}
655+
drop(manager_lock);
649656
let mut raw = message.to_raw();
650657
for message in &mut raw.body {
651658
message.update()?;

src/error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub enum PushError {
3737
KeyNotFound(String),
3838
#[error("Could not deliver message. The recipient does not have iMessage or you are being rate-limited. Rate limits can start at 0 users for brand new accounts. The only way to resolve a rate limit is patience, trying to reconfigure or re-install to 'fix' the rate limit will result in being temporarily blocked from iMessage.")]
3939
NoValidTargets,
40-
#[error("Failed to connect to APS {0}")]
40+
#[error("Aps connection failed. You need to re-setup your device. Go to Settings -> Change Apple Hardware. For self-hosted users, have your hardware code ready. ({0})")]
4141
APSConnectError(u8),
4242
#[error("TLS error {0}")]
4343
TLSError(#[from] rustls::Error),
@@ -62,7 +62,7 @@ pub enum PushError {
6262
MMCSGetFailed(Option<String>),
6363
#[error("Failed to authenticate. Try logging in to account.apple.com to fix your Apple Account or create a new one: {1:?} {0}")]
6464
MobileMeError(String, Option<String>),
65-
#[error("You need to add a trusted phone number to your Apple Account at account.apple.com. You may be unable to add your phone number. You can also create a new account at account.apple.com. If you get 'Your account cannot be created at this time,' you need to contact Apple Support. For assistance, join our Discord from our website.")]
65+
#[error("You need to add a trusted phone number to your Apple Account at account.apple.com. You may be unable to add your phone number. You can also create a new account at account.apple.com. If you get 'Your account cannot be created at this time,' you need to contact Apple Support. Do not mention OpenBubbles. For assistance, join our Discord from our website.")]
6666
UnauthorizedAccountError,
6767
#[error("Bad auth cert {0}")]
6868
AuthInvalid(IDSError),

src/util.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ pub static REQWEST: LazyLock<Client> = LazyLock::new(|| {
242242
});
243243

244244
pub static CARRIER_REQWEST: LazyLock<Client> = LazyLock::new(|| {
245+
// return build_proxy();
245246
let mut headers = HeaderMap::new();
246247
headers.insert("Accept-Language", HeaderValue::from_static("en-US,en;q=0.9"));
247248

@@ -1066,6 +1067,11 @@ impl<T: Resource + 'static> ResourceManager<T> {
10661067
pub async fn ensure_ready(&self) -> Result<(), PushError> {
10671068
// wait for any generation to finish
10681069
self.resource_state.subscribe().wait_for(|i| !matches!(i, ResourceState::Generating)).await.map_err(|_| PushError::ResourceClosed)?;
1070+
self.ensure_not_failed()
1071+
}
1072+
1073+
pub fn ensure_not_failed(&self) -> Result<(), PushError> {
1074+
info!("Ensuring not failed");
10691075
match &*self.resource_state.borrow() {
10701076
ResourceState::Failed(error) => Err(error.clone().into()),
10711077
ResourceState::Closed => Err(PushError::ResourceClosed),

0 commit comments

Comments
 (0)