From 2d752bb0d99784a671f9160ebea5bc7ce502e76c Mon Sep 17 00:00:00 2001 From: Hank Grabowski Date: Mon, 20 Mar 2023 09:58:02 -0400 Subject: [PATCH] Add PHP Debugging header toggle to client/globals --- lib/friendica_client/friendica_client.dart | 30 ++++++++++------------ lib/globals.dart | 2 ++ 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/lib/friendica_client/friendica_client.dart b/lib/friendica_client/friendica_client.dart index bffb02b..8c5d920 100644 --- a/lib/friendica_client/friendica_client.dart +++ b/lib/friendica_client/friendica_client.dart @@ -552,6 +552,9 @@ class RemoteFileClient extends FriendicaClient { final postUri = Uri.parse('https://$serverName/api/friendica/photo/create'); final request = http.MultipartRequest('POST', postUri); request.headers['Authorization'] = _profile.credentials.authHeaderValue; + if (usePhpDebugging) { + request.headers['Cookie'] = 'XDEBUG_SESSION=PHPSTORM;path=/'; + } request.fields['desc'] = description; request.fields['album'] = album; request.files.add(await http.MultipartFile.fromBytes( @@ -645,7 +648,6 @@ class StatusesClient extends FriendicaClient { final url = Uri.parse('https://$serverName/api/v1/statuses'); final body = { 'status': text, - 'visibility': 'public', if (spoilerText.isNotEmpty) 'spoiler_text': spoilerText, if (inReplyToId.isNotEmpty) 'in_reply_to_id': inReplyToId, if (mediaIds.isNotEmpty) 'media_ids': mediaIds, @@ -839,10 +841,7 @@ abstract class FriendicaClient { try { final response = await http.get( url, - headers: { - 'Authorization': _profile.credentials.authHeaderValue, - 'Content-Type': 'application/json; charset=UTF-8' - }, + headers: _header, ); if (response.statusCode != 200) { @@ -866,10 +865,7 @@ abstract class FriendicaClient { try { final response = await http.post( url, - headers: { - 'Authorization': _profile.credentials.authHeaderValue, - 'Content-Type': 'application/json; charset=UTF-8' - }, + headers: _header, body: jsonEncode(body), ); @@ -891,10 +887,7 @@ abstract class FriendicaClient { try { final response = await http.put( url, - headers: { - 'Authorization': _profile.credentials.authHeaderValue, - 'Content-Type': 'application/json; charset=UTF-8' - }, + headers: _header, body: jsonEncode(body), ); @@ -916,10 +909,7 @@ abstract class FriendicaClient { try { final response = await http.delete( url, - headers: { - 'Authorization': _profile.credentials.authHeaderValue, - 'Content-Type': 'application/json; charset=UTF-8' - }, + headers: _header, body: jsonEncode(body), ); @@ -950,4 +940,10 @@ abstract class FriendicaClient { )) .execErrorCastAsync(); } + + Map get _header => { + 'Authorization': _profile.credentials.authHeaderValue, + 'Content-Type': 'application/json; charset=UTF-8', + if (usePhpDebugging) 'Cookie': 'XDEBUG_SESSION=PHPSTORM;path=/', + }; } diff --git a/lib/globals.dart b/lib/globals.dart index 9b8e705..dbacb83 100644 --- a/lib/globals.dart +++ b/lib/globals.dart @@ -15,6 +15,8 @@ final useImagePicker = kIsWeb || Platform.isAndroid || Platform.isIOS; final useVideoPlayer = kIsWeb || Platform.isAndroid || Platform.isIOS; +final usePhpDebugging = true; + Future showConfirmDialog(BuildContext context, String caption) { return showDialog( context: context,