-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: [FC-0047] add mobile push notifications functionality #34971
feat: [FC-0047] add mobile push notifications functionality #34971
Conversation
Thanks for the pull request, @NiedielnitsevIvan! What's next?Please work through the following steps to get your changes ready for engineering review: 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. 🔘 Let us know that your PR is ready for review:Who will review my changes?This repository is currently maintained by Where can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:
When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
e9e1876
to
b325343
Compare
To fix pipelines, it is necessary to merge this PR in edx-ace and release a new version so that this PR can rely on it. |
eef6da0
to
b8c6acb
Compare
a437349
to
2718724
Compare
be2bc82
to
0d08485
Compare
0d08485
to
46082e8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contirbution.
I've added a review a long while ago, but for some reasons it's not showing up.
Please let me know whant do you think about the suggested change.
lms/djangoapps/discussion/tasks.py
Outdated
class CommentNotification(BaseMessageType): | ||
def __init__(self, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
self.options['transactional'] = True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Transactioanl should be used for important emails like password reset and others. I think in this case, CommentNotification
isn't transactional
class CommentNotification(BaseMessageType): | |
def __init__(self, *args, **kwargs): | |
super().__init__(*args, **kwargs) | |
self.options['transactional'] = True | |
class CommentNotification(BaseMessageType): | |
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, thanks.
{% load i18n %} | ||
{% blocktrans trimmed %}{{ comment_username }} commented to {{ thread_title }}:{% endblocktrans %} | ||
{{ comment_body_text }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would the message reach the device with a new line before {{ comment_body_text }}
or would it be converted to a space.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will be converted to a space.
@@ -0,0 +1,2 @@ | |||
{% load i18n %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please rename to title.txt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed.
@@ -19,7 +19,7 @@ | |||
import openedx.core.djangoapps.django_comment_common.comment_client as cc | |||
from common.djangoapps.student.tests.factories import CourseEnrollmentFactory, UserFactory | |||
from lms.djangoapps.discussion.signals.handlers import ENABLE_FORUM_NOTIFICATIONS_FOR_SITE_KEY | |||
from lms.djangoapps.discussion.tasks import _should_send_message, _track_notification_sent | |||
from lms.djangoapps.discussion.tasks import _is_first_comment, _should_send_message, _track_notification_sent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider breaking into new lines
from lms.djangoapps.discussion.tasks import _is_first_comment, _should_send_message, _track_notification_sent | |
from lms.djangoapps.discussion.tasks import ( | |
_is_first_comment, | |
_should_send_message, | |
_track_notification_sent, | |
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed.
assert actual_result is False | ||
|
||
should_email_send = _is_first_comment(comment_dict['id'], thread['id']) | ||
assert should_email_send is False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert should_email_send is False | |
assert not should_email_send |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed.
if email_params: | ||
email_params.update({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using message_params
instead to be less confusing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed.
from rest_framework import status | ||
from rest_framework.response import Response | ||
|
||
from edx_ace.push_notifications.views import GCMDeviceViewSet as GCMDeviceViewSetBase |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please provide a link to those classes, I couldn't find those in openedx/edx-ace#282
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class is imported from django-push-notifications into edx-ace so that there is no direct dependency, and in case of need, it can be changed in edx-ace without changing the implementation in the platform.
https://github.com/openedx/edx-ace/blob/master/edx_ace/push_notifications/views/__init__.py
|
||
|
||
@mobile_view() | ||
class GCMDeviceViewSet(GCMDeviceViewSetBase): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the security controls for this view?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Default for mobile_view decorator:
authentication_classes = (
JwtAuthentication,
BearerAuthenticationAllowInactiveUser,
SessionAuthenticationAllowInactiveUser
)
permission_classes = (IsAuthenticated,)
46082e8
to
cdbdd8c
Compare
61c2aca
to
d88d880
Compare
@NiedielnitsevIvan @GlugovGrGlib I see you're still actively pushing changes to this branch. Thank you for your efforts! Is there anything I can help with to push this work forward? I know I've delayed other pull requests so I want to double check that I'm not blocking this one. |
Hello @OmarIthawi with this latest commits we were able to address your comments from previous CR run and make all CI checks to pass. This PR is ready for the yet another review, hopefully final CR pass from your side. |
a1dcec7
to
480ccca
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@NiedielnitsevIvan you've done a really good job by refactoring the email
--> message
.
Thank you so much. This is very helpful. The pull request looks good and frankly ready to be merged.
I've added many small notes please check them.
Push notificaiton messages review
I recommend merging this pull request just to avoid any more delays and conflicts.
However, with all due respect, I think there's a little effort went into reviewing the UX of the notification messages. It's alright we're all engineers and aren't masters in business communications.
Therefore I recommend after merging this pull request, having someone with a User Experience skills and/or product management to review the push notification messages to ensure it's up to the current standards and provides an adequate experience to the user on their phone (cc: @e0d).
lms/djangoapps/discussion/tasks.py
Outdated
class CommentNotification(BaseMessageType): | ||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
class CommentNotification(BaseMessageType): | |
pass | |
class CommentNotification(BaseMessageType): | |
""" | |
Notify discussion participants of new comments. | |
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
@@ -0,0 +1,2 @@ | |||
{% load i18n %} | |||
{% blocktrans trimmed %}{{ comment_username }} replied to {{ thread_title }}{% endblocktrans %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, we're not including any excerpt? Depending on how much mobile notifications limit we have in mobile phones.
I'd recommed to add the comment's first 200 characters or so:
{% blocktrans trimmed %}{{ comment_username }} replied to {{ thread_title }}{% endblocktrans %} | |
{% blocktrans trimmed %}{{ comment_username }} replied to {{ thread_title }}: {{ comment_body_excerpt }}{% endblocktrans %} |
comment_body_excerpt
would be either the whole comment or part of it ending with ...
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, this was not in the text of the push notifications when they were approved, but if you insist, I added it.
from .views import GCMDeviceViewSet | ||
|
||
|
||
CREATE_GCM_DEVICE = GCMDeviceViewSet.as_view({'post': 'create'}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CREATE_GCM_DEVICE = GCMDeviceViewSet.as_view({'post': 'create'}) | |
create_gcm_device_post_view = GCMDeviceViewSet.as_view({'post': 'create'}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed.
CREATE_GCM_DEVICE = GCMDeviceViewSet.as_view({'post': 'create'}) | ||
|
||
|
||
urlpatterns = [ | ||
path('create-token/', CREATE_GCM_DEVICE, name='gcmdevice-list'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CREATE_GCM_DEVICE = GCMDeviceViewSet.as_view({'post': 'create'}) | |
urlpatterns = [ | |
path('create-token/', CREATE_GCM_DEVICE, name='gcmdevice-list'), | |
CREATE_GCM_DEVICE = GCMDeviceViewSet.as_view({'post': 'create'}) | |
urlpatterns = [ | |
path('create-token/', create_gcm_device_post_view, name='gcmdevice-list'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed.
@@ -0,0 +1,5 @@ | |||
{% load i18n %} | |||
{% autoescape off %} | |||
{% blocktrans %}Dear Student,{% endblocktrans %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formality isn't ideal in mobile in my opinion.
{% blocktrans %}Dear Student,{% endblocktrans %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.
@@ -0,0 +1,5 @@ | |||
{% load i18n %} | |||
{% autoescape off %} | |||
{% blocktrans %}Dear student,{% endblocktrans %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{% blocktrans %}Dear student,{% endblocktrans %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.
try: | ||
import firebase_admin # pylint: disable=import-outside-toplevel | ||
except ImportError: | ||
log.error('Could not import firebase_admin package.') | ||
return | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a core import that should be kept is a real import since the package is installed always in the requirements.
try: | |
import firebase_admin # pylint: disable=import-outside-toplevel | |
except ImportError: | |
log.error('Could not import firebase_admin package.') | |
return | |
import firebase_admin # pylint: disable=import-outside-toplevel |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
feat: [FC-0047] Add push notifications for user enroll feat: [FC-0047] Add push notifications for user unenroll feat: [FC-0047] Add push notifications for add course beta testers feat: [FC-0047] Add push notifications for remove course beta testers feat: [FC-0047] Add push notification event to discussions
480ccca
to
a6c1ebf
Compare
a6c1ebf
to
eef99a6
Compare
@NiedielnitsevIvan thank you so much for going above and beyond. Please let me know when the tests are fixed so we can go ahead and merge it. |
…t-push-notifications-chanel
…cations-chanel' of github.com:raccoongang/edx-platform into NiedielnitsevIvan/FC-0047/feature/implement-push-notifications-chanel
@OmarIthawi Checks are fixed. |
…t-push-notifications-chanel
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot @NiedielnitsevIvan! Looks good to me since last time, now the tests are fixed I give it ✅
@bmtcril as this PR is finally approved, could you please check and merge this PR? |
Thanks @GlugovGrGlib @NiedielnitsevIvan , I'm doing a last pass run through now. This seems to me to be a medium risk PR to land, so what I'd like to do is:
Thanks, this is looking great! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested LMS functionality locally, though I don't have the ability to actually trigger push notifications at this point I was able to confirm that things worked both with the new settings set and without them.
Merging on this is delayed while 2U works out issues on their side. Better to let the release queue clear than potentially get caught up in rollbacks and reverts while things get stable there. Discussion is happening in #cc-edx-platform if you'd like to follow along, but it seems likely it will take a day or two before we can merge. Sorry for the delay. |
2U Release Notice: This PR has been deployed to the edX staging environment in preparation for a release to production. |
2U Release Notice: This PR has been deployed to the edX production environment. |
1 similar comment
2U Release Notice: This PR has been deployed to the edX production environment. |
Description
This PR addressed to adding the ability to send push notifications to the OeX mobile app on IOS and Android, using edx-ace functionality and Firebase Cloud Messaging as a cloud provider.
Some push notifications are also added here directly, namely:
Useful information to include:
"Developer", and "Operator".
changes.
Supporting information
FC-0047
TBD
Testing instructions
push_notification
channel to ACE_ENABLED_CHANEL.Deadline
"None"
Other information