@celery_app.task(name='website.notifications.tasks.send_users_email', max_retries=0)
def send_users_email(send_type):
 grouped_emails = get_users_emails(send_type)
 if (not grouped_emails):
  return
 for group in grouped_emails:
  user = User.load(group['user_id'])
  if (not user):
   log_exception()
   continue
  info = group['info']
  notification_ids = [message['_id'] for message in info]
  sorted_messages = group_by_node(info)
  if sorted_messages:
   mails.send_mail(to_addr=user.username, mimetype='html', mail=mails.DIGEST, name=user.fullname, message=sorted_messages, callback=remove_notifications(email_notification_ids=notification_ids))

@ celery_app . task ( name = 'website.notifications.tasks.send_users_email' , max_retries = 0 ) def send_users_email ( send_type ) : grouped_emails = get_users_emails ( send_type ) if ( not grouped_emails ) : return for group in grouped_emails : user = User . load ( group [ 'user_id' ] ) if ( not user ) : log_exception ( ) continue info = group [ 'info' ] notification_ids = [ message [ '_id' ] for message in info ] sorted_messages = group_by_node ( info ) if sorted_messages : mails . send_mail ( to_addr = user . username , mimetype = 'html' , mail = mails . DIGEST , name = user . fullname , message = sorted_messages , callback = remove_notifications ( email_notification_ids = notification_ids ) )
find pending emails and amalgamates them into a single email .