~tsileo/microblog.pub

d3f9e72801d9c394f17a526f149aa767ac59b46a — Thomas Sileo 8 months ago ba1bfe4
Fix reply content with mentions
3 files changed, 13 insertions(+), 4 deletions(-)

M blueprints/admin.py
M blueprints/api.py
M templates/layout.html
M blueprints/admin.py => blueprints/admin.py +10 -0
@@ 345,6 345,16 @@ def admin_new() -> _Response:
        domain = urlparse(actor.id).netloc
        # FIXME(tsileo): if reply of reply, fetch all participants
        content = f"@{actor.preferredUsername}@{domain} "
        if reply.has_type(ap.ActivityType.CREATE):
            reply = reply.get_object()
        for mention in reply.get_mentions():
            if mention.href in [actor.id, ID]:
                continue
            m = ap.fetch_remote_activity(mention.href)
            if m.has_type(ap.ACTOR_TYPES):
                d = urlparse(m.id).netloc
                content += f"@{m.preferredUsername}@{d} "

        thread = _build_thread(data)

    return htmlify(

M blueprints/api.py => blueprints/api.py +2 -2
@@ 531,8 531,8 @@ def api_new_note() -> _Response:

    raw_note = dict(
        attributedTo=MY_PERSON.id,
        cc=list(set(cc)),
        to=list(set(to)),
        cc=list(set(cc) - set([MY_PERSON.id])),
        to=list(set(to) - set([MY_PERSON.id])),
        summary=summary,
        content=content,
        tag=tags,

M templates/layout.html => templates/layout.html +1 -2
@@ 40,8 40,7 @@ dt, dd { font-size: 0.9em; }
 {% if unread_notifications_count %}
 ({{unread_notifications_count}})
 {% endif %}</a></li>
<!-- <li class="left"><a href="/admin/direct_messages"{% if request.path == url_for('admin.admin_direct_messages') %} class="selected" {% endif %}>DMs</a></li>
-->
<li class="left"><a href="/admin/direct_messages"{% if request.path == url_for('admin.admin_direct_messages') %} class="selected" {% endif %}>DMs</a></li>
<li class="left"><a href="/admin/lists"{% if request.path == url_for('admin.admin_lists') %} class="selected" {% endif %}>Lists</a></li>
<li class="left"><a href="/admin/bookmarks"{% if request.path == "/admin/bookmarks" %} class="selected" {% endif %}>Bookmarks</a></li>
<li class="left"><a href="/admin/lookup"{% if request.path == "/admin/lookup" %} class="selected" {% endif %}>Lookup</a></li>