save name of user or community when creating notification subscription #20

This commit is contained in:
rimu 2024-04-22 21:00:04 +12:00
parent 708edd51b6
commit a1442afaf5
2 changed files with 4 additions and 2 deletions

View file

@ -1173,7 +1173,8 @@ def community_notification(community_id: int):
db.session.commit() db.session.commit()
else: # no subscription yet, so make one else: # no subscription yet, so make one
if not community.user_is_banned(current_user): if not community.user_is_banned(current_user):
new_notification = NotificationSubscription(user_id=current_user.id, entity_id=community.id, type=NOTIF_COMMUNITY) new_notification = NotificationSubscription(name=community.title, user_id=current_user.id, entity_id=community.id,
type=NOTIF_COMMUNITY)
db.session.add(new_notification) db.session.add(new_notification)
db.session.commit() db.session.commit()

View file

@ -233,7 +233,8 @@ def user_notification(user_id: int):
db.session.commit() db.session.commit()
else: # no subscription yet, so make one else: # no subscription yet, so make one
if user.id != current_user.id and not user.has_blocked_user(current_user.id): if user.id != current_user.id and not user.has_blocked_user(current_user.id):
new_notification = NotificationSubscription(user_id=current_user.id, entity_id=user.id, type=NOTIF_USER) new_notification = NotificationSubscription(name=user.display_name(), user_id=current_user.id,
entity_id=user.id, type=NOTIF_USER)
db.session.add(new_notification) db.session.add(new_notification)
db.session.commit() db.session.commit()