mirror of
https://git.sr.ht/~tsileo/microblog.pub
synced 2024-12-22 05:04:27 +00:00
Add notification for follow requests status
This commit is contained in:
parent
cf95836d2d
commit
4046fa0506
5 changed files with 30 additions and 2 deletions
12
app/boxes.py
12
app/boxes.py
|
@ -1105,6 +1105,18 @@ async def save_to_inbox(
|
|||
ap_actor_id=actor.ap_id,
|
||||
)
|
||||
db_session.add(following)
|
||||
|
||||
notif_type = (
|
||||
models.NotificationType.FOLLOW_REQUEST_ACCEPTED
|
||||
if activity_ro.ap_type == "Accept"
|
||||
else models.NotificationType.FOLLOW_REQUEST_REJECTED
|
||||
)
|
||||
notif = models.Notification(
|
||||
notification_type=notif_type,
|
||||
actor_id=actor.id,
|
||||
inbox_object_id=inbox_object.id,
|
||||
)
|
||||
db_session.add(notif)
|
||||
else:
|
||||
logger.info(
|
||||
"Received an Accept for an unsupported activity: "
|
||||
|
|
|
@ -78,7 +78,6 @@ _RESIZED_CACHE: MutableMapping[tuple[str, int], tuple[bytes, str, Any]] = LFUCac
|
|||
# Next:
|
||||
# - show pending follow request (and prevent double follow?)
|
||||
# - UI support for updating posts
|
||||
# - Support for processing update
|
||||
# - Article support
|
||||
# - Fix tests
|
||||
# - Fix SQL tx in the codebase
|
||||
|
|
|
@ -479,11 +479,18 @@ class Webmention(Base):
|
|||
class NotificationType(str, enum.Enum):
|
||||
NEW_FOLLOWER = "new_follower"
|
||||
UNFOLLOW = "unfollow"
|
||||
|
||||
FOLLOW_REQUEST_ACCEPTED = "follow_request_accepted"
|
||||
FOLLOW_REQUEST_REJECTED = "follow_request_rejected"
|
||||
|
||||
LIKE = "like"
|
||||
UNDO_LIKE = "undo_like"
|
||||
|
||||
ANNOUNCE = "announce"
|
||||
UNDO_ANNOUNCE = "undo_announce"
|
||||
|
||||
MENTION = "mention"
|
||||
|
||||
NEW_WEBMENTION = "new_webmention"
|
||||
UPDATED_WEBMENTION = "updated_webmention"
|
||||
DELETED_WEBMENTION = "deleted_webmention"
|
||||
|
|
|
@ -22,6 +22,16 @@
|
|||
<a style="font-weight:bold;" href="{{ notif.actor.url }}">{{ notif.actor.display_name }}</a> unfollowed you
|
||||
</div>
|
||||
{{ utils.display_actor(notif.actor, actors_metadata) }}
|
||||
{%- elif notif.notification_type.value == "follow_request_accepted" %}
|
||||
<div class="actor-action" title="{{ notif.created_at.isoformat() }}">
|
||||
<a style="font-weight:bold;" href="{{ notif.actor.url }}">{{ notif.actor.display_name }}</a> accepted your follow request
|
||||
</div>
|
||||
{{ utils.display_actor(notif.actor, actors_metadata) }}
|
||||
{%- elif notif.notification_type.value == "follow_request_rejected" %}
|
||||
<div class="actor-action" title="{{ notif.created_at.isoformat() }}">
|
||||
<a style="font-weight:bold;" href="{{ notif.actor.url }}">{{ notif.actor.display_name }}</a> rejected your follow request
|
||||
</div>
|
||||
{{ utils.display_actor(notif.actor, actors_metadata) }}
|
||||
{% elif notif.notification_type.value == "like" %}
|
||||
<div class="actor-action" title="{{ notif.created_at.isoformat() }}">
|
||||
<a style="font-weight:bold;" href="{{ notif.actor.url }}">{{ notif.actor.display_name }}</a> liked a post
|
||||
|
|
Loading…
Reference in a new issue