# -*- coding: utf-8 -*- """ :author: Grey Li (李辉) :url: http://greyli.com :copyright: © 2018 Grey Li :license: MIT, see LICENSE for more details. """ from flask import url_for from albumy.extensions import db from albumy.models import Notification def push_follow_notification(follower, receiver): message = 'User %s followed you.' % \ (url_for('user.index', username=follower.username), follower.username) notification = Notification(message=message, receiver=receiver) db.session.add(notification) db.session.commit() def push_comment_notification(photo_id, receiver, page=1): message = 'This photo has new comment/reply.' % \ (url_for('main.show_photo', photo_id=photo_id, page=page)) notification = Notification(message=message, receiver=receiver) db.session.add(notification) db.session.commit() def push_collect_notification(collector, photo_id, receiver): message = 'User %s collected your photo' % \ (url_for('user.index', username=collector.username), collector.username, url_for('main.show_photo', photo_id=photo_id)) notification = Notification(message=message, receiver=receiver) db.session.add(notification) db.session.commit()