notifications.rst 1.5 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, type, 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. * ``type:`` short text used to identify this message for ``read_user_notifications`` function. For example ``see_thread_123`` notification will be read when user sees thread with ID 123 for first time.
  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. Defaults to ``True``.
  16. read_user_notifications
  17. -----------------------
  18. .. function:: read_user_notifications(user, types, atomic=True)
  19. Sets user notifications identified by ``types`` as read. This function checks internally if user has new notifications before it queries database.
  20. * ``user:`` User to whom notification belongs to
  21. * ``types:`` Short text or list of short texts used to identify notifications that will be set as read.
  22. * ``atomic:`` Lets you control if you should wrap this in dedicated transaction.