Skip to content

Commit

Permalink
feat: added user notifcation signal (#234)
Browse files Browse the repository at this point in the history
  • Loading branch information
AhtishamShahid authored Jun 23, 2023
1 parent 5d936ba commit 8788be9
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ Change Log
Unreleased
----------

[8.2.0] - 2023-06-08
--------------------
Changed
~~~~~~~
* Added new USER_NOTIFICATION_REQUESTED event.

[8.1.0] - 2023-06-06
--------------------
Added
Expand Down
2 changes: 1 addition & 1 deletion openedx_events/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
more information about the project.
"""

__version__ = "8.1.0"
__version__ = "8.2.0"
22 changes: 22 additions & 0 deletions openedx_events/learning/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,3 +235,25 @@ class XBlockSkillVerificationData:
usage_key = attr.ib(type=UsageKey)
verified_skills = attr.ib(type=List[int], factory=list)
ignored_skills = attr.ib(type=List[int], factory=list)


@attr.s(frozen=True)
class UserNotificationData:
"""
Attributes defined for Open edX User Notification data object.
Arguments:
user_ids (List(int)): identifier of the user to which the notification belongs.
notification_type (str): type of the notification.
context (dict): additional structured information about the context in
which this topic is used, such as the section, subsection etc.
content_url (str): url of the content.
app_name (str): name of the app.
"""

user_ids = attr.ib(type=List[int])
notification_type = attr.ib(type=str)
content_url = attr.ib(type=str)
app_name = attr.ib(type=str)
course_key = attr.ib(type=CourseKey)
context = attr.ib(type=dict, factory=dict)
14 changes: 14 additions & 0 deletions openedx_events/learning/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
CourseEnrollmentData,
PersistentCourseGradeData,
UserData,
UserNotificationData,
XBlockSkillVerificationData,
)
from openedx_events.tooling import OpenEdxPublicSignal
Expand Down Expand Up @@ -161,3 +162,16 @@
"xblock_info": XBlockSkillVerificationData,
}
)

# .. event_type: org.openedx.learning.user.notification.requested.v1
# .. event_name: USER_NOTIFICATION
# .. event_description: Can be fired from apps to send user notifications.
# .. event_data: UserNotificationSendListData
# Warning: This event is currently incompatible with the event bus, list/dict cannot be serialized yet
#
USER_NOTIFICATION_REQUESTED = OpenEdxPublicSignal(
event_type="org.openedx.learning.user.notification.requested.v1",
data={
"notification_data": UserNotificationData,
}
)
1 change: 1 addition & 0 deletions openedx_events/tooling.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"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"
]


Expand Down

0 comments on commit 8788be9

Please sign in to comment.