Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions forum/backends/mongodb/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1046,6 +1046,15 @@ def create_comment(cls, data: dict[str, Any]) -> str:
parent_id=data.get("parent_id"),
)

# Update thread's last activity timestamp to mark it as having new activity
comment_thread_id = data.get("comment_thread_id")
if comment_thread_id:
CommentThread().update(
comment_thread_id,
last_activity_at=datetime.now(),
skip_timestamp_update=True
)

if data.get("parent_id"):
cls.update_stats_for_course(data["author_id"], data["course_id"], replies=1)
else:
Expand Down
2 changes: 2 additions & 0 deletions forum/backends/mongodb/threads.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ def update(
close_reason_code: Optional[str] = None,
closed_by_id: Optional[str] = None,
group_id: Optional[int] = None,
last_activity_at: Optional[datetime] = None,
skip_timestamp_update: bool = False,
) -> int:
"""
Expand Down Expand Up @@ -258,6 +259,7 @@ def update(
("close_reason_code", close_reason_code),
("closed_by_id", closed_by_id),
("group_id", group_id),
("last_activity_at", last_activity_at),
]
update_data: dict[str, Any] = {
field: value for field, value in fields if value is not None
Expand Down
Loading