forked from gergely/calendar-social
Send a notification when a follow action happens
This commit is contained in:
@@ -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))
|
||||
|
Reference in New Issue
Block a user