- Move /image-proxy to public (unauthenticated) route so CachedNetworkImage can fetch proxied GIFs without Bearer token (fixes 401 errors) - Expand image proxy SSRF allowlist to include i.imgur.com + media.giphy.com - Broaden GIF filter in gif_picker: accept i.redd.it, preview.redd.it, i.imgur.com URLs (not just .gif extension) so Reddit posts actually show - Change GIF search hint to 'Search GIFs…' (no subreddit mention) - Add i.imgur.com + media.giphy.com to client-side needsProxy() list - Create lib/widgets/composer/composer_bar.dart — single ComposerBar widget with ComposerConfig presets (publicPost/comment/threadReply/chat/privatePost) that handles text, GIF picker, image picker, upload, and send button uniformly - Apply ComposerBar to: group feed posts, group feed comments sheet, group thread reply bar, quips comment sheet, group chat bar - Remove all duplicate TextField+send-button+media-button implementations Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
48 lines
1.6 KiB
Dart
48 lines
1.6 KiB
Dart
class ApiConfig {
|
|
// Not const so we can normalize away accidentally-configured http/8080 URLs.
|
|
static final String baseUrl = _computeBaseUrl();
|
|
|
|
static String _computeBaseUrl() {
|
|
String raw = const String.fromEnvironment(
|
|
'API_BASE_URL',
|
|
defaultValue: 'https://api.sojorn.net/api/v1',
|
|
);
|
|
|
|
// Failsafe: migrate legacy domain if it slips in via environment or cache
|
|
if (raw.contains('gosojorn.com')) {
|
|
raw = raw.replaceAll('gosojorn.com', 'sojorn.net');
|
|
}
|
|
|
|
// Auto-upgrade any lingering http://api.sojorn.net:8080 (or plain http)
|
|
// to the public https endpoint behind nginx.
|
|
if (raw.startsWith('http://api.sojorn.net:8080')) {
|
|
return raw.replaceFirst(
|
|
'http://api.sojorn.net:8080',
|
|
'https://api.sojorn.net',
|
|
);
|
|
}
|
|
|
|
if (raw.startsWith('http://')) {
|
|
return 'https://${raw.substring('http://'.length)}';
|
|
}
|
|
|
|
return raw;
|
|
}
|
|
|
|
/// Wraps external GIF/image URLs (Reddit, GifCities) through the server proxy
|
|
/// so the client's IP is never sent to third-party origins.
|
|
static String proxyImageUrl(String url) {
|
|
return '$baseUrl/image-proxy?url=${Uri.encodeComponent(url)}';
|
|
}
|
|
|
|
/// Returns true if [url] is an external GIF that should be proxied.
|
|
static bool needsProxy(String url) {
|
|
return url.startsWith('https://i.redd.it/') ||
|
|
url.startsWith('https://preview.redd.it/') ||
|
|
url.startsWith('https://external-preview.redd.it/') ||
|
|
url.startsWith('https://blob.gifcities.org/gifcities/') ||
|
|
url.startsWith('https://i.imgur.com/') ||
|
|
url.startsWith('https://media.giphy.com/');
|
|
}
|
|
}
|