Send a notification when a follow action happens

This commit is contained in:
2018-07-09 14:32:38 +02:00
parent 379a5b1bb0
commit 3bd381692b
2 changed files with 14 additions and 1 deletions

View File

@@ -272,7 +272,7 @@ class CalendarSocialApp(Flask):
"""View for following a user
"""
from .models import db, Profile, User, UserFollow
from .models import db, Profile, User, UserFollow, Notification, NotificationAction
profile = current_user.profile
@@ -284,6 +284,13 @@ class CalendarSocialApp(Flask):
followed_id=profile,
accepted_at=datetime.utcnow())
db.session.add(follow)
notification = Notification(profile=profile,
actor=current_user.profile,
item=profile,
action=NotificationAction.follow)
db.session.add(notification)
db.session.commit()
return redirect(url_for('display_profile', username=username))