| 14361 | flash("GIF too large (max 33MB).") |
| 14362 | return redirect(url_for("chat_with", username=username)) |
| 14363 | |
| 14364 | # Prefer an explicit file; otherwise accept GIF as a file attachment. |
| 14365 | chosen_file = ( |
| 14366 | upfile if (upfile and getattr(upfile, "filename", "")) else (gif if (gif and getattr(gif, "filename", "")) else None) |
| 14367 | ) |
| 14368 | |
| 14369 | if voice and getattr(voice, "filename", ""): |
| 14370 | try: |
| 14371 | _validate_chat_voice_upload(voice) |
| 14372 | except ValueError as ve: |
| 14373 | msg = "Unsupported voice file type." |
| 14374 | if str(ve) == "forbidden_type": |
| 14375 | msg = "Forbidden file type." |
| 14376 | if is_ajax: |
| 14377 | return jsonify(ok=False, error=msg), 400 |
| 14378 | flash(msg) |
| 14379 | return redirect(url_for("chat_with", username=username)) |
| 14380 | if chosen_file and getattr(chosen_file, "filename", ""): |
| 14381 | try: |