| 14361 | _validate_chat_voice_upload(voice) |
| 14362 | except ValueError as ve: |
| 14363 | msg = "Unsupported voice file type." |
| 14364 | if str(ve) == "forbidden_type": |
| 14365 | msg = "Forbidden file type." |
| 14366 | if is_ajax: |
| 14367 | return jsonify(ok=False, error=msg), 400 |
| 14368 | flash(msg) |
| 14369 | return redirect(url_for("chat_with", username=username)) |
| 14370 | if chosen_file and getattr(chosen_file, "filename", ""): |
| 14371 | try: |
| 14372 | _validate_chat_file_upload(chosen_file) |
| 14373 | except ValueError as ve: |
| 14374 | msg = "Unsupported file type." |
| 14375 | if str(ve) == "forbidden_type": |
| 14376 | msg = "Forbidden file type." |
| 14377 | if is_ajax: |
| 14378 | return jsonify(ok=False, error=msg), 400 |
| 14379 | flash(msg) |
| 14380 | return redirect(url_for("chat_with", username=username)) |
| 14381 | |