notifications.rst 1.4 KB

123456789101112131415161718192021222324252627282930313233
  1. =============
  2. Notifications
  3. =============
  4. Modern site in which users interact with each other needs quick and efficient notifications system to let users know of each other actions as quickly as possible.
  5. Misago implements such system and exposes simple as part of it, located in :py:mod:`misago.notifications`:
  6. notify_user
  7. -----------
  8. .. function:: notify_user(user, message, url, trigger, formats=None, sender=None, update_user=True)
  9. * ``user:`` User to notify.
  10. * ``message:`` Notification message.
  11. * ``url:`` Link user should follow to read message.
  12. * ``trigger:`` short text used to identify this message for ``read_user_notification`` function.
  13. * ``formats:`` Optional. Dict of formats for ``message`` argument that should be boldened.
  14. * ``sender:`` Optional. User that notification origins from.
  15. * ``update_user:``Optional. Boolean controlling if to call ``user.update`` after setting notification, or not.
  16. read_user_notification
  17. ----------------------
  18. .. function:: read_user_notification(user, trigger, atomic=True)
  19. Sets user notification identified by ``trigger`` as read. This function checks internally if user has new notifications before it queries database.
  20. * ``user:`` User to whom notification belongs to
  21. * ``trigger:`` Short text used to identify messages to trigger as read.
  22. * ``atomic:`` Lets you control if you should wrap this in dedicated transaction.