diff options
author | Evgeny Fadeev <evgeny.fadeev@gmail.com> | 2012-09-28 03:26:19 -0300 |
---|---|---|
committer | Evgeny Fadeev <evgeny.fadeev@gmail.com> | 2012-09-28 03:26:19 -0300 |
commit | d3883448985772e1de79bcf917fa27d17698f484 (patch) | |
tree | c9872676aad2cf4c702355a0d6fc50fc04069de8 | |
parent | 1b9dd8f37e3fdbe434237f05bf121838bcf27939 (diff) | |
download | askbot-d3883448985772e1de79bcf917fa27d17698f484.tar.gz askbot-d3883448985772e1de79bcf917fa27d17698f484.tar.bz2 askbot-d3883448985772e1de79bcf917fa27d17698f484.zip |
tried to fix the delayed notification issue
-rw-r--r-- | askbot/models/__init__.py | 11 | ||||
-rw-r--r-- | askbot/models/post.py | 5 |
2 files changed, 6 insertions, 10 deletions
diff --git a/askbot/models/__init__.py b/askbot/models/__init__.py index e7e9b013..c16087f7 100644 --- a/askbot/models/__init__.py +++ b/askbot/models/__init__.py @@ -3039,15 +3039,8 @@ def send_instant_notifications_about_activity_in_post( post = None, recipients = None, ): - if not django_settings.CELERY_ALWAYS_EAGER: - cache_key = 'instant-notification-%d' % post.thread.id - old_task_id = cache.cache.get(cache_key) - if old_task_id: - if not send_instant_notifications_about_activity_in_post.ignore_result: - send_instant_notifications_about_activity_in_post.update_state(state=states.REVOKED) - return - - + #reload object from the database + post = Post.objects.get(id=post.id) if post.is_approved() is False: return diff --git a/askbot/models/post.py b/askbot/models/post.py index 7073bf80..8b8ff76a 100644 --- a/askbot/models/post.py +++ b/askbot/models/post.py @@ -655,8 +655,11 @@ class Post(models.Model): [u for u in notify_sets['for_email'] if u.is_administrator()] if not settings.CELERY_ALWAYS_EAGER: - cache_key = 'instant-notification-%d' % self.thread.id + cache_key = 'instant-notification-%d-%d' % (self.thread.id, updated_by.id) + if cache.cache.get(cache_key): + return cache.cache.set(cache_key, True, settings.NOTIFICATION_DELAY_TIME) + from askbot.models import send_instant_notifications_about_activity_in_post send_instant_notifications_about_activity_in_post.apply_async(( update_activity, |