(username: str)
| 18665 | # Size limits (33MB) for chat stability. |
| 18666 | if voice and getattr(voice, "filename", ""): |
| 18667 | vsz = _filestorage_size(voice) |
| 18668 | if vsz is not None and vsz > CHAT_MAX_BYTES: |
| 18669 | if is_ajax: |
| 18670 | return jsonify(ok=False, error=_("Voice message too large (max 33MB).")), 413 |
| 18671 | flash(_("Voice message too large (max 33MB).")) |
| 18672 | return redirect(url_for("discussion")) |
| 18673 | if upfile and getattr(upfile, "filename", ""): |
| 18674 | fsz = _filestorage_size(upfile) |
| 18675 | if fsz is not None and fsz > CHAT_MAX_BYTES: |
| 18676 | if is_ajax: |
| 18677 | return jsonify(ok=False, error=_("File too large (max 33MB).")), 413 |
| 18678 | flash(_("File too large (max 33MB).")) |
| 18679 | return redirect(url_for("discussion")) |
| 18680 | if gif and getattr(gif, "filename", ""): |
| 18681 | gsz = _filestorage_size(gif) |
| 18682 | if gsz is not None and gsz > CHAT_MAX_BYTES: |
| 18683 | if is_ajax: |
| 18684 | return jsonify(ok=False, error=_("GIF too large (max 33MB).")), 413 |
| 18685 | flash(_("GIF too large (max 33MB).")) |
| 18686 | return redirect(url_for("discussion")) |
| 18687 | |
| 18688 | chosen_file = ( |
| 18689 | upfile if (upfile and getattr(upfile, "filename", "")) else (gif if (gif and getattr(gif, "filename", "")) else None) |
| 18690 | ) |
| 18691 | |
| 18692 | if voice and getattr(voice, "filename", ""): |
| 18693 | try: |
| 18694 | _validate_chat_voice_upload(voice) |
| 18695 | except ValueError as ve: |
| 18696 | msg = _("Unsupported voice file type.") |
| 18697 | if str(ve) == "forbidden_type": |
| 18698 | msg = _("Forbidden file type.") |
no test coverage detected