Two bugs, both mine. The profile page arrived unstyled because its CSS was in a <style> block. default-src 'self' covers style-src, 'self' does not permit inline, so the browser dropped the whole block without a word — the photo loaded because img-src allows same-origin, which is what made the screenshot look like a half-working page rather than a blocked one. The third time this policy has silently made something inert, after two rounds of inline event handlers. Moved to static/profile.css, where the policy allows it, and test_templates.py now fails on an inline <style> the way it already does on an inline onclick. Private messages had an "Abrir conversación" button that created an empty conversation and sent you to a page where you then had to type. It bought nothing and littered the inbox with rows reading "Sin mensajes todavía" for people nobody had written to. A conversation is now addressed by the person — /privados/con/<member_id> — and the page always carries the history and the box together. The row is created by the first message, not by looking at somebody's name. That also makes the access rule structural instead of checked. Every lookup is scoped to the member doing the looking, so there is no query that could return somebody else's correspondence, and the two helpers that took a conversation id are gone. A third person opening the same URL now sees their own empty conversation, which the tests assert directly rather than asserting a 404. 281 tests. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NizVpJ2dwzCbjCrTLCjeHn
45 lines
1.5 KiB
HTML
45 lines
1.5 KiB
HTML
{% extends "base.html" %}
|
|
{% block title %}Privados{% endblock %}
|
|
|
|
{% block main %}
|
|
<div class="feed-head">
|
|
<h1>Mensajes privados</h1>
|
|
</div>
|
|
|
|
{% if people %}
|
|
{# GET, not POST: choosing somebody to write to is navigation, not a change.
|
|
It also means no conversation is created just because a name was picked. #}
|
|
<form class="card" method="get" action="{{ url_for('messages.pick') }}">
|
|
<label for="para">Escribir a</label>
|
|
<select id="para" name="member_id">
|
|
{% for person in people %}
|
|
<option value="{{ person.id }}">{{ person.display_name }}</option>
|
|
{% endfor %}
|
|
</select>
|
|
<button class="btn" type="submit">Escribir</button>
|
|
</form>
|
|
{% endif %}
|
|
|
|
{% if not conversations %}
|
|
<p class="muted">Todavía no tienes conversaciones privadas.</p>
|
|
{% endif %}
|
|
|
|
{% for c in conversations %}
|
|
<article class="card">
|
|
<a class="card__title" href="{{ url_for('messages.talk', member_id=c.other_id) }}">
|
|
{{ c.other_name }}
|
|
{% if c.unread %}<span class="tag">{{ c.unread }}</span>{% endif %}
|
|
</a>
|
|
<p class="muted small">{{ excerpt(c.last_body) or 'Sin mensajes todavía.' }}</p>
|
|
<div class="card__meta">
|
|
{% if c.last_at %}<time>{{ c.last_at }}</time>{% endif %}
|
|
<form method="post" action="{{ url_for('messages.block', member_id=c.other_id) }}"
|
|
data-confirm="Al bloquear a {{ c.other_name }} ninguno de los dos podrá escribir al otro. ¿Seguro?">
|
|
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
|
|
<button class="linkish linkish--danger" type="submit">Bloquear</button>
|
|
</form>
|
|
</div>
|
|
</article>
|
|
{% endfor %}
|
|
{% endblock %}
|