Skip to content

Commit 6253fa7

Browse files
committed
Add notification system
1 parent 2c1da64 commit 6253fa7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+4632
-143
lines changed

backend/api/urls.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
path("blog/", include("blog.urls")),
2323
path("messages/", include("messages.urls")),
2424
path("moderation/", include("moderation.urls")),
25+
path("notifications/", include("notifications.urls")),
2526
path("core/", include("core.urls")),
2627
path("privacy_policy/", PrivacyPolicyView.as_view(), name="privacy_policy"),
2728
path("terms_of_service/", TermsOfServiceView.as_view(), name="terms_of_service"),

backend/backend/settings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ def get_secret(secret_name, default=None):
6969
"messages.apps.MessagesConfig",
7070
"moderation",
7171
"navbar",
72+
"notifications",
7273
"users",
7374
"presence",
7475
"channels",

backend/blog/celery_config.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
"""
2+
Celery configuration for blog app tasks.
3+
"""
4+
5+
from celery import Celery
6+
from django.conf import settings
7+
8+
# Blog-specific task routing
9+
BLOG_TASK_ROUTES = {
10+
'blog.tasks.process_blog_post_creation': {'queue': 'blog_posts'},
11+
'blog.tasks.process_blog_post_update': {'queue': 'blog_posts'},
12+
'blog.tasks.process_blog_post_deletion': {'queue': 'blog_posts'},
13+
'blog.tasks.process_content_analysis': {'queue': 'content_analysis'},
14+
'blog.tasks.send_post_notifications': {'queue': 'notifications'},
15+
}
16+
17+
# Rate limiting for blog tasks
18+
BLOG_TASK_ANNOTATIONS = {
19+
'blog.tasks.process_blog_post_creation': {'rate_limit': '10/m'},
20+
'blog.tasks.process_blog_post_update': {'rate_limit': '20/m'},
21+
'blog.tasks.process_blog_post_deletion': {'rate_limit': '15/m'},
22+
'blog.tasks.process_content_analysis': {'rate_limit': '5/m'},
23+
'blog.tasks.send_post_notifications': {'rate_limit': '30/m'},
24+
}
25+
26+
# Retry configuration
27+
BLOG_TASK_RETRY_KWARGS = {
28+
'max_retries': 3,
29+
'countdown': 60,
30+
'retry_backoff': True,
31+
'retry_backoff_max': 600,
32+
'retry_jitter': True,
33+
}
34+
35+
def configure_blog_celery(app: Celery):
36+
"""
37+
Configure Celery app with blog-specific settings.
38+
"""
39+
# Update task routes
40+
current_routes = getattr(app.conf, 'task_routes', {})
41+
current_routes.update(BLOG_TASK_ROUTES)
42+
app.conf.task_routes = current_routes
43+
44+
# Update task annotations
45+
current_annotations = getattr(app.conf, 'task_annotations', {})
46+
current_annotations.update(BLOG_TASK_ANNOTATIONS)
47+
app.conf.task_annotations = current_annotations
48+
49+
# Set default retry kwargs for blog tasks
50+
app.conf.task_default_retry_delay = 60
51+
app.conf.task_max_retries = 3
52+
53+
return app

0 commit comments

Comments
 (0)