Skip to content

Commit

Permalink
Xhxag persona fixes (#1849)
Browse files Browse the repository at this point in the history
## deploy plan
- [ ] deploy backend
- [ ] deploy app
  • Loading branch information
beastoin authored Feb 21, 2025
2 parents db0e2e7 + f30bd66 commit a249c55
Show file tree
Hide file tree
Showing 19 changed files with 434 additions and 528 deletions.
15 changes: 8 additions & 7 deletions app/lib/backend/http/api/apps.dart
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,6 @@ Future<bool> checkPersonaUsername(String username) async {
}
}


Future<Map?> getTwitterProfileData(String handle) async {
var response = await makeApiCall(
url: '${Env.apiBaseUrl}v1/personas/twitter/profile?handle=$handle',
Expand All @@ -506,8 +505,7 @@ Future<Map?> getTwitterProfileData(String handle) async {
}
}


Future<bool> verifyTwitterOwnership(String username, String handle, String? personaId) async {
Future<(bool, String?)> verifyTwitterOwnership(String username, String handle, String? personaId) async {
var url = '${Env.apiBaseUrl}v1/personas/twitter/verify-ownership?username=$username&handle=$handle';
if (personaId != null) {
url += '&persona_id=$personaId';
Expand All @@ -519,17 +517,20 @@ Future<bool> verifyTwitterOwnership(String username, String handle, String? pers
method: 'GET',
);
try {
if (response == null || response.statusCode != 200) return false;
if (response == null || response.statusCode != 200) return (false, null);
log('verifyTwitterOwnership: ${response.body}');
return jsonDecode(response.body)['verified'];
var data = jsonDecode(response.body);
return (
(data['verified'] ?? false) as bool,
data['persona_id'] as String?,
);
} catch (e, stackTrace) {
debugPrint(e.toString());
CrashReporting.reportHandledCrash(e, stackTrace);
return false;
return (false, null);
}
}


Future<App?> getUserPersonaServer() async {
var response = await makeApiCall(
url: '${Env.apiBaseUrl}v1/personas',
Expand Down
10 changes: 10 additions & 0 deletions app/lib/backend/preferences.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@ class SharedPreferencesUtil {

set hasPersonaCreated(bool value) => saveBool('hasPersonaCreated', value);

String? get verifiedPersonaId => getString('verifiedPersonaId');

set verifiedPersonaId(String? value) {
if (value != null) {
_preferences?.setString('verifiedPersonaId', value);
} else {
_preferences?.remove('verifiedPersonaId');
}
}

set btDevice(BtDevice value) {
saveString('btDevice', jsonEncode(value.toJson()));
}
Expand Down
5 changes: 5 additions & 0 deletions app/lib/backend/schema/app.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:friend_private/utils/other/string_utils.dart';
import 'package:friend_private/widgets/extensions/string.dart';

class AppReview {
Expand Down Expand Up @@ -237,6 +238,10 @@ class App {
this.twitter,
});

String getName() {
return tryDecodingText(name);
}

String? getRatingAvg() => ratingAvg?.toStringAsFixed(1);

bool hasCapability(String capability) => capabilities.contains(capability);
Expand Down
4 changes: 3 additions & 1 deletion app/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,9 @@ class _DeciderWidgetState extends State<DeciderWidget> {
} else {
return const OnboardingWrapper();
}
} else if (SharedPreferencesUtil().hasOmiDevice == false && SharedPreferencesUtil().hasPersonaCreated) {
} else if (SharedPreferencesUtil().hasOmiDevice == false &&
SharedPreferencesUtil().hasPersonaCreated &&
SharedPreferencesUtil().verifiedPersonaId != null) {
return const PersonaProfilePage();
} else {
return const DeviceSelectionPage();
Expand Down
Loading

0 comments on commit a249c55

Please sign in to comment.