read.py 644 B

12345678910111213141516
  1. from rest_framework.response import Response
  2. from misago.readtracker.threadstracker import make_posts_read_aware, read_thread
  3. def post_read_endpoint(request, thread, post):
  4. make_posts_read_aware(request.user, thread, [post])
  5. if not post.is_read:
  6. read_thread(request.user, thread, post)
  7. if thread.subscription and thread.subscription.last_read_on < post.posted_on:
  8. thread.subscription.last_read_on = post.posted_on
  9. thread.subscription.save()
  10. return Response({
  11. 'thread_is_read': thread.last_post_on <= post.posted_on,
  12. })
  13. return Response({'thread_is_read': True})