mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
feat(media-hosting): add multi-provider configurable upload with fallback
Add Random/Preferred/None modes, preferred provider selection, and provider-order fallback. Catbox/Imgur/PostImages on Android via WebView; Electron CDP automation for Imgur/PostImages. Hide upload controls on web runtime.
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import type { ProviderId } from './types';
|
||||
|
||||
export interface ProviderAttempt {
|
||||
provider: ProviderId;
|
||||
success: boolean;
|
||||
error?: string;
|
||||
}
|
||||
|
||||
export type TranslateFn = (key: string) => string;
|
||||
|
||||
/**
|
||||
* Formats aggregated error message when all providers fail (random mode).
|
||||
*/
|
||||
export function formatAggregatedError(attempts: ProviderAttempt[], t: TranslateFn): string {
|
||||
const details = attempts.map((a) => `${a.provider}: ${a.error ?? 'unknown'}`).join('; ');
|
||||
return `${t('upload_failed')}. ${t('upload_failed_all_providers')}: ${details}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats error for preferred mode with actionable guidance.
|
||||
*/
|
||||
export function formatPreferredModeError(errorMessage: string, t: TranslateFn): string {
|
||||
return `${t('upload_failed')}: ${errorMessage}. ${t('upload_failed_preferred_guidance')}`;
|
||||
}
|
||||
Reference in New Issue
Block a user