Files
indiekit-endpoint-activitypub/views/partials/ap-notification-card.njk
Ricardo d20dea2dc8 feat: notification management — clear, mark read, dismiss, TTL retention
- Add "Mark all read" and "Clear all" toolbar buttons on notifications page
- Add per-notification dismiss (×) button
- Remove auto-mark-all-as-read on page load (explicit action only)
- Add 30-day TTL index on createdAt for automatic notification cleanup
- New config option: notificationRetentionDays (default 30)
2026-02-21 20:00:05 +01:00

66 lines
2.1 KiB
Plaintext

{# Notification card partial #}
<div class="ap-notification{% if not item.read %} ap-notification--unread{% endif %}">
{# Dismiss button #}
<form method="post" action="{{ mountPath }}/admin/reader/notifications/delete" class="ap-notification__dismiss">
<input type="hidden" name="_csrf" value="{{ csrfToken }}">
<input type="hidden" name="uid" value="{{ item.uid }}">
<button type="submit" class="ap-notification__dismiss-btn" title="{{ __('activitypub.notifications.dismiss') }}">&times;</button>
</form>
{# Type icon #}
<div class="ap-notification__icon">
{% if item.type == "like" %}
{% elif item.type == "boost" %}
🔁
{% elif item.type == "follow" %}
👤
{% elif item.type == "reply" %}
💬
{% elif item.type == "mention" %}
@
{% endif %}
</div>
{# Notification body #}
<div class="ap-notification__body">
<span class="ap-notification__actor">
<a href="{{ item.actorUrl }}">{{ item.actorName }}</a>
</span>
<span class="ap-notification__action">
{% if item.type == "like" %}
{{ __("activitypub.notifications.liked") }}
{% elif item.type == "boost" %}
{{ __("activitypub.notifications.boostedPost") }}
{% elif item.type == "follow" %}
{{ __("activitypub.notifications.followedYou") }}
{% elif item.type == "reply" %}
{{ __("activitypub.notifications.repliedTo") }}
{% elif item.type == "mention" %}
{{ __("activitypub.notifications.mentionedYou") }}
{% endif %}
</span>
{% if item.targetUrl %}
<a href="{{ item.targetUrl }}" class="ap-notification__target">
{{ item.targetName or item.targetUrl }}
</a>
{% endif %}
{% if item.content and item.content.text %}
<div class="ap-notification__excerpt">
{{ item.content.text | truncate(200) }}
</div>
{% endif %}
</div>
{# Timestamp #}
{% if item.published %}
<time datetime="{{ item.published }}" class="ap-notification__time">
{{ item.published | date("PPp") }}
</time>
{% endif %}
</div>