text: # -*- coding: utf-8 -*-
  """
      :author: Grey Li (李辉)
      :url: http://greyli.com
      :copyright: © 2018 Grey Li <withlihui@gmail.com>
      :license: MIT, see LICENSE for more details.
  
  笔记：
      推送通知，在数据库新建Notification即可。
  """
  from flask import url_for
  
  from albumy.extensions import db
  from albumy.models import Notification
  
  
  def push_follow_notification(follower, receiver):
      """推送关注提醒"""
      message = 'User <a href="%s">%s</a> 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 = '<a href="%s#comments">This photo</a> 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 <a href="%s">%s</a> collected your <a href="%s">photo</a>' % \
                (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()
  