Skip to content

Commit 852c991

Browse files
committed
Incident fix
1 parent b4166ef commit 852c991

File tree

3 files changed

+47
-14
lines changed

3 files changed

+47
-14
lines changed

lib/app/layouts/settings/settings_page.dart

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,20 +1137,7 @@ class _SettingsPageState extends OptimizedState<SettingsPage> {
11371137
.primary)),
11381138
onPressed: () async {
11391139
Navigator.of(context).pop();
1140-
if (ss.settings.deviceIsHosted.value) {
1141-
String? ticket = await api.validateRelay(configRef: pushService.state!.osConfig);
1142-
if (ticket != null) {
1143-
var activated = await http.dio.post("https://hw.openbubbles.app/ticket/$ticket/release");
1144-
if (activated.statusCode == 200) {
1145-
pushService.markFailedToLogin(hw: true, ui: true);
1146-
return;
1147-
}
1148-
}
1149-
pushService.markFailedToLogin();
1150-
return;
1151-
} else {
1152-
pushService.markFailedToLogin(hw: true, ui: true);
1153-
}
1140+
pushService.markFailedToLogin(hw: true, ui: true);
11541141
}
11551142
),
11561143
],

lib/services/rustpush/rustpush_service.dart

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4784,6 +4784,7 @@ class RustPushService extends GetxService {
47844784
initAppLinks();
47854785
initMixPanel();
47864786
await initFuture;
4787+
Timer(const Duration(seconds: 2), checkIncident);
47874788
// pre-cache next FT link
47884789
if (pushService.state != null) api.getFtLink(facetime: pushService.state!.ftClient, usage: "next");
47894790
Logger.info("initDone");
@@ -4799,6 +4800,41 @@ class RustPushService extends GetxService {
47994800
Logger.info("finishInit");
48004801
}
48014802

4803+
void checkIncident() {
4804+
if (!File("$statePath/incident_affected").existsSync()) return;
4805+
showDialog(
4806+
context: Get.context!,
4807+
builder: (context) => AlertDialog(
4808+
title: Text(
4809+
"Action requried",
4810+
style: context.theme.textTheme.titleLarge,
4811+
),
4812+
backgroundColor: context.theme.colorScheme.properSurface,
4813+
content: Text("There's an issue with a recent update. A software bug corrupted part of the app's internal state and needs to be fixed before messaging can continue. You won't be able to send messages until you take action.\n\nYour data was not compromised, and this was not a security issue.\nWe recommend backing up any important messages before proceeding. Have your apple device and account authentication credentials ready.", style: context.theme.textTheme.bodyLarge),
4814+
actions: [
4815+
TextButton(
4816+
child: Text(
4817+
"Dismiss for now",
4818+
style: context.theme.textTheme.bodyLarge!.copyWith(color: context.theme.colorScheme.primary)
4819+
),
4820+
onPressed: () => Navigator.of(context).pop(),
4821+
),
4822+
TextButton(
4823+
child: Text(
4824+
"Fix",
4825+
style: context.theme.textTheme.bodyLarge!.copyWith(color: context.theme.colorScheme.primary)
4826+
),
4827+
onPressed: () async {
4828+
Navigator.of(context).pop();
4829+
pushService.markFailedToLogin(hw: true, logout: true, ui: true);
4830+
File("$statePath/incident_affected").deleteSync();
4831+
}
4832+
),
4833+
],
4834+
),
4835+
);
4836+
}
4837+
48024838
void initMixPanel() async {
48034839
if (ss.settings.finishedSetup.value && !ss.settings.deviceIsHosted.value) return;
48044840
mixpanel = await Mixpanel.init("d66dc2d8f2ad649fac2640ff059dc9f4", trackAutomaticEvents: false);
@@ -4899,6 +4935,7 @@ class RustPushService extends GetxService {
48994935

49004936
Future configured() async {
49014937
await handleRegistered();
4938+
Timer(const Duration(seconds: 2), checkIncident);
49024939
if (Platform.isAndroid) {
49034940
await mcs.invokeMethod("notify-native-configured");
49044941
}

rust/src/api/api.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ pub use icloud_auth::DefaultAnisetteProvider;
2525
use uniffi::HandleAlloc;
2626
use rand::Rng;
2727
use uuid::Uuid;
28+
use rustpush::KeyCache;
2829
use std::io::Seek;
2930
use async_recursion::async_recursion;
3031
use base64::prelude::*;
@@ -385,6 +386,14 @@ pub async fn make_imclient(path: String, conn: &APSConnection, users: &Vec<IDSUs
385386
let dir = PathBuf::from_str(&path).unwrap();
386387
let id_path = dir.join("id.plist");
387388

389+
let incident_path = dir.join("incident");
390+
if !incident_path.exists() {
391+
if plist::from_file::<_, KeyCache>(dir.join("id_cache.plist")).is_ok() {
392+
let _ = fs::File::create(dir.join("incident_affected"));
393+
}
394+
let _ = fs::File::create(incident_path);
395+
}
396+
388397
Arc::new(IMClient::new(conn.clone(), users.clone(), identity.clone(),
389398
&[&MADRID_SERVICE, &MULTIPLEX_SERVICE, &FACETIME_SERVICE, &VIDEO_SERVICE], dir.join("id_cache.plist"), conn.os_config.clone(), Box::new(move |updated_keys| {
390399
println!("updated keys!!!");

0 commit comments

Comments
 (0)