Add PHP Debugging header toggle to client/globals

merge-requests/67/merge
Hank Grabowski 2023-03-20 09:58:02 -04:00
rodzic 2130e67c7f
commit 2d752bb0d9
2 zmienionych plików z 15 dodań i 17 usunięć

Wyświetl plik

@ -552,6 +552,9 @@ class RemoteFileClient extends FriendicaClient {
final postUri = Uri.parse('https://$serverName/api/friendica/photo/create'); final postUri = Uri.parse('https://$serverName/api/friendica/photo/create');
final request = http.MultipartRequest('POST', postUri); final request = http.MultipartRequest('POST', postUri);
request.headers['Authorization'] = _profile.credentials.authHeaderValue; request.headers['Authorization'] = _profile.credentials.authHeaderValue;
if (usePhpDebugging) {
request.headers['Cookie'] = 'XDEBUG_SESSION=PHPSTORM;path=/';
}
request.fields['desc'] = description; request.fields['desc'] = description;
request.fields['album'] = album; request.fields['album'] = album;
request.files.add(await http.MultipartFile.fromBytes( 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 url = Uri.parse('https://$serverName/api/v1/statuses');
final body = { final body = {
'status': text, 'status': text,
'visibility': 'public',
if (spoilerText.isNotEmpty) 'spoiler_text': spoilerText, if (spoilerText.isNotEmpty) 'spoiler_text': spoilerText,
if (inReplyToId.isNotEmpty) 'in_reply_to_id': inReplyToId, if (inReplyToId.isNotEmpty) 'in_reply_to_id': inReplyToId,
if (mediaIds.isNotEmpty) 'media_ids': mediaIds, if (mediaIds.isNotEmpty) 'media_ids': mediaIds,
@ -839,10 +841,7 @@ abstract class FriendicaClient {
try { try {
final response = await http.get( final response = await http.get(
url, url,
headers: { headers: _header,
'Authorization': _profile.credentials.authHeaderValue,
'Content-Type': 'application/json; charset=UTF-8'
},
); );
if (response.statusCode != 200) { if (response.statusCode != 200) {
@ -866,10 +865,7 @@ abstract class FriendicaClient {
try { try {
final response = await http.post( final response = await http.post(
url, url,
headers: { headers: _header,
'Authorization': _profile.credentials.authHeaderValue,
'Content-Type': 'application/json; charset=UTF-8'
},
body: jsonEncode(body), body: jsonEncode(body),
); );
@ -891,10 +887,7 @@ abstract class FriendicaClient {
try { try {
final response = await http.put( final response = await http.put(
url, url,
headers: { headers: _header,
'Authorization': _profile.credentials.authHeaderValue,
'Content-Type': 'application/json; charset=UTF-8'
},
body: jsonEncode(body), body: jsonEncode(body),
); );
@ -916,10 +909,7 @@ abstract class FriendicaClient {
try { try {
final response = await http.delete( final response = await http.delete(
url, url,
headers: { headers: _header,
'Authorization': _profile.credentials.authHeaderValue,
'Content-Type': 'application/json; charset=UTF-8'
},
body: jsonEncode(body), body: jsonEncode(body),
); );
@ -950,4 +940,10 @@ abstract class FriendicaClient {
)) ))
.execErrorCastAsync(); .execErrorCastAsync();
} }
Map<String, String> get _header => {
'Authorization': _profile.credentials.authHeaderValue,
'Content-Type': 'application/json; charset=UTF-8',
if (usePhpDebugging) 'Cookie': 'XDEBUG_SESSION=PHPSTORM;path=/',
};
} }

Wyświetl plik

@ -15,6 +15,8 @@ final useImagePicker = kIsWeb || Platform.isAndroid || Platform.isIOS;
final useVideoPlayer = kIsWeb || Platform.isAndroid || Platform.isIOS; final useVideoPlayer = kIsWeb || Platform.isAndroid || Platform.isIOS;
final usePhpDebugging = true;
Future<bool?> showConfirmDialog(BuildContext context, String caption) { Future<bool?> showConfirmDialog(BuildContext context, String caption) {
return showDialog<bool>( return showDialog<bool>(
context: context, context: context,