diff --git a/openedx_events/learning/data.py b/openedx_events/learning/data.py index 7e5d2f26..13b89b7e 100644 --- a/openedx_events/learning/data.py +++ b/openedx_events/learning/data.py @@ -296,3 +296,44 @@ class ProgramCertificateData: status = attr.ib(type=str) url = attr.ib(type=str) certificate_available_date = attr.ib(type=datetime, default=None) + + +@attr.s(frozen=True) +class DiscussionThreadData: + """ + Attributes defined for Open edX Discussion Thread data object. + + Arguments: + anonymous (bool): indicates whether the user is anonymous. + anonymous_to_peers (bool): indicates whether the user is anonymous to peers. + body (str): body of the discussion thread. + category_id (int): identifier of the category. + category_name (str): name of the category. + commentable_id (str): identifier of the commentable. + group_id (int): identifier of the group. + id (int): identifier of the discussion thread. + team_id (int): identifier of the team. + thread_type (str): type of the thread. + title (str): title of the thread. + title_truncated (bool): indicates whether the title is truncated. + truncated (bool): indicates whether the thread is truncated. + url (str): url of the thread. + """ + + anonymous = attr.ib(type=bool) + anonymous_to_peers = attr.ib(type=bool) + body = attr.ib(type=str) + category_id = attr.ib(type=int) + category_name = attr.ib(type=str) + commentable_id = attr.ib(type=str) + group_id = attr.ib(type=int) + id = attr.ib(type=int) + team_id = attr.ib(type=int) + thread_type = attr.ib(type=str) + title = attr.ib(type=str) + title_truncated = attr.ib(type=bool) + truncated = attr.ib(type=bool) + url = attr.ib(type=str) + user_course_roles = attr.ib(type=List[str], factory=list) + user_forums_roles = attr.ib(type=List[str], factory=list) + options = attr.ib(type=dict, factory=dict) diff --git a/openedx_events/learning/signals.py b/openedx_events/learning/signals.py index 5c139937..ab78748b 100644 --- a/openedx_events/learning/signals.py +++ b/openedx_events/learning/signals.py @@ -13,6 +13,7 @@ CohortData, CourseDiscussionConfigurationData, CourseEnrollmentData, + DiscussionThreadData, PersistentCourseGradeData, ProgramCertificateData, UserData, @@ -184,6 +185,18 @@ } ) +# .. event_type: org.openedx.learning.thread.created.v1 +# .. event_name: FORUM_THREAD_CREATED +# .. event_description: Emitted when a new thread is created in a discussion +# .. event_data: DiscussionThreadData +# Warning: This event is currently incompatible with the event bus, list/dict cannot be serialized yet +FORUM_THREAD_CREATED = OpenEdxPublicSignal( + event_type="org.openedx.learning.thread.created.v1", + data={ + "thread": DiscussionThreadData, + } +) + # .. event_type: org.openedx.learning.user.notification.requested.v1 # .. event_name: USER_NOTIFICATION # .. event_description: Can be fired from apps to send user notifications. diff --git a/openedx_events/tooling.py b/openedx_events/tooling.py index 35700ed3..e4ff108b 100644 --- a/openedx_events/tooling.py +++ b/openedx_events/tooling.py @@ -21,7 +21,8 @@ "org.openedx.learning.discussions.configuration.changed.v1", "org.openedx.content_authoring.course.certificate_config.changed.v1", "org.openedx.content_authoring.course.certificate_config.deleted.v1", - "org.openedx.learning.user.notification.requested.v1" + "org.openedx.learning.user.notification.requested.v1", + "org.openedx.learning.thread.created.v1", ]