mirror of
https://git.sr.ht/~tsileo/microblog.pub
synced 2024-12-22 05:04:27 +00:00
Show in reply to admin button
This commit is contained in:
parent
ad62b79da9
commit
d058c1ba26
5 changed files with 40 additions and 6 deletions
17
app/admin.py
17
app/admin.py
|
@ -76,10 +76,23 @@ async def get_lookup(
|
|||
request: Request,
|
||||
query: str | None = None,
|
||||
db_session: AsyncSession = Depends(get_db_session),
|
||||
) -> templates.TemplateResponse:
|
||||
) -> templates.TemplateResponse | RedirectResponse:
|
||||
ap_object = None
|
||||
actors_metadata = {}
|
||||
if query:
|
||||
requested_object = await boxes.get_anybox_object_by_ap_id(db_session, query)
|
||||
if requested_object:
|
||||
if (
|
||||
requested_object.ap_type == "Create"
|
||||
and requested_object.relates_to_anybox_object
|
||||
):
|
||||
query = requested_object.relates_to_anybox_object.ap_id
|
||||
return RedirectResponse(
|
||||
request.url_for("admin_object") + f"?ap_id={query}",
|
||||
status_code=302,
|
||||
)
|
||||
# TODO(ts): redirect to admin_profile if the actor is in DB
|
||||
|
||||
ap_object = await lookup(db_session, query)
|
||||
if ap_object.ap_type in ap.ACTOR_TYPES:
|
||||
actors_metadata = await get_actors_metadata(
|
||||
|
@ -266,7 +279,7 @@ async def admin_outbox(
|
|||
cursor: str | None = None,
|
||||
) -> templates.TemplateResponse:
|
||||
where = [
|
||||
models.OutboxObject.ap_type.not_in(["Accept", "Delete"]),
|
||||
models.OutboxObject.ap_type.not_in(["Accept", "Delete", "Update"]),
|
||||
models.OutboxObject.is_deleted.is_(False),
|
||||
]
|
||||
if filter_by:
|
||||
|
|
16
app/boxes.py
16
app/boxes.py
|
@ -455,7 +455,21 @@ async def get_outbox_object_by_ap_id(
|
|||
) -> models.OutboxObject | None:
|
||||
return (
|
||||
await db_session.execute(
|
||||
select(models.OutboxObject).where(models.OutboxObject.ap_id == ap_id)
|
||||
select(models.OutboxObject)
|
||||
.where(models.OutboxObject.ap_id == ap_id)
|
||||
.options(
|
||||
joinedload(models.OutboxObject.outbox_object_attachments).options(
|
||||
joinedload(models.OutboxObjectAttachment.upload)
|
||||
),
|
||||
joinedload(models.OutboxObject.relates_to_inbox_object).options(
|
||||
joinedload(models.InboxObject.actor),
|
||||
),
|
||||
joinedload(models.OutboxObject.relates_to_outbox_object).options(
|
||||
joinedload(models.OutboxObject.outbox_object_attachments).options(
|
||||
joinedload(models.OutboxObjectAttachment.upload)
|
||||
),
|
||||
),
|
||||
)
|
||||
)
|
||||
).scalar_one_or_none() # type: ignore
|
||||
|
||||
|
|
|
@ -64,9 +64,8 @@ _RESIZED_CACHE: MutableMapping[tuple[str, int], tuple[bytes, str, Any]] = LFUCac
|
|||
# TODO(ts):
|
||||
#
|
||||
# Next:
|
||||
# - [ ] show [reply to @truc] next to visiblity
|
||||
# - support update post with history
|
||||
# - update actor support
|
||||
# - hash config/profile to detect when to send Update actor
|
||||
#
|
||||
# - [ ] block support
|
||||
# - [ ] prevent SSRF (urlutils from little-boxes)
|
||||
|
|
|
@ -162,7 +162,7 @@ class OutboxObject(Base, BaseObject):
|
|||
# Never actually delete from the outbox
|
||||
is_deleted = Column(Boolean, nullable=False, default=False)
|
||||
|
||||
# Used for Like, Announce and Undo activities
|
||||
# Used for Create, Like, Announce and Undo activities
|
||||
relates_to_inbox_object_id = Column(
|
||||
Integer,
|
||||
ForeignKey("inbox.id"),
|
||||
|
|
|
@ -332,6 +332,14 @@
|
|||
|
||||
<nav class="flexbox activity-bar">
|
||||
<ul>
|
||||
|
||||
{% if object.in_reply_to and is_admin %}
|
||||
<li>
|
||||
<a href="{{ url_for("get_lookup") }}?query={{ object.in_reply_to }}" title="{{ object.in_reply_to }}">in reply to {{ object.in_reply_to|truncate(16, True) }}</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
|
||||
{% if not is_admin or object.is_from_outbox %}<li><div><a href="{{ object.url }}"{% if object.is_from_inbox %} rel="nofollow"{% endif %}>permalink</a></div></li>{% endif %}
|
||||
{% if object.is_from_outbox %}
|
||||
{% if object.likes_count %}
|
||||
|
|
Loading…
Reference in a new issue