Send a DM that contains the story media + a text reaction.
(sender: str, recipient: str, story_row, reaction_text: str)
| 18774 | |
| 18775 | if (not has_file) and has_gif_url: |
| 18776 | info = _discussion_store_remote_gif_tx(conn, msg_id, gif_url) |
| 18777 | saved_paths.append(info["stored_path"]) |
| 18778 | |
| 18779 | conn.commit() |
| 18780 | _discussion_mark_sent(me) |
| 18781 | |
| 18782 | if is_ajax: |
| 18783 | r = conn.execute( |
| 18784 | "SELECT id, sender, body_enc, created_at, has_voice, has_file FROM discussion_messages WHERE id=?", |
| 18785 | (msg_id,), |
| 18786 | ).fetchone() |
| 18787 | if r is None: |
| 18788 | return jsonify(ok=False, error="not_found"), 404 |
| 18789 | msg = _discussion_build_message_dict(conn, dict(r), me) |
| 18790 | html_row = _render_discussion_row_html(msg, me) |
| 18791 | return jsonify(ok=True, id=msg_id, html=html_row) |
| 18792 | |
| 18793 | return redirect(url_for("discussion")) |
| 18794 | |
| 18795 | except Exception as e: |
| 18796 | try: |
| 18797 | conn.rollback() |
| 18798 | except Exception: |
| 18799 | pass |
| 18800 | for sp in saved_paths: |
| 18801 | try: |
| 18802 | if sp and os.path.exists(sp): |
| 18803 | os.remove(sp) |
| 18804 | except Exception: |
| 18805 | pass |
| 18806 | log.exception("discussion_send failed: %s", e) |
| 18807 | if is_ajax: |
| 18808 | return jsonify(ok=False, error=_("Send failed.")), 500 |
| 18809 | flash(_("Send failed.")) |
| 18810 | return redirect(url_for("discussion")) |
| 18811 | finally: |
| 18812 | try: |
| 18813 | conn.close() |
| 18814 | except Exception: |
| 18815 | pass |
| 18816 | |
| 18817 | |
| 18818 | @app.route("/api/discussion/since") |
| 18819 | @login_required |
| 18820 | def api_discussion_since(): |
| 18821 | _feature_tables_init() |
| 18822 | me = current_user() |
| 18823 | try: |
no test coverage detected