Skip to content
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

Add ability to send emails and notifications from the Messaging Center #3259

Merged
merged 3 commits into from
Jul 2, 2024

Conversation

mathjazz
Copy link
Collaborator

@mathjazz mathjazz commented Jun 19, 2024

Fix #3243.
Fix #2072.

This is the first part of the implementation of the Messaging Center. It allows for sending emails and in-app notifications from /messaging/. Locally emails are sent to stdout.

Note that until we implement recipient filters (#3244), the recipient of the messages is the sender.

While the development is in progress, the page is not linked from the UI.

Also included:

  • Factor out check-box CSS
  • Make .notification selectors in style.css and main.js more specific

Note that until we implement recipient filters, the recipient of the messages is the sender.

Also included:
- Factor out check-box CSS
- Make .notification selectors in style.css and main.js more specific
@mathjazz mathjazz requested a review from eemeli June 19, 2024 15:33
Copy link
Member

@eemeli eemeli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks fine. A bit sad that we're extending the jQuery dependency, but it's probably the least worst option. Some inline comments might require some fixing.

pontoon/base/static/css/check-box.css Outdated Show resolved Hide resolved
import html2text


def html_to_plain_text_with_links(html):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would just inline this and consider DRY much later, but that's mostly just me.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm planning to use this function in the email script, at least for the time being.

return JsonResponse(dict(form.errors.items()))

# TODO: implement recipient filters
from django.contrib.auth.models import User
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this not a top-level import?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be.

body = form.cleaned_data.get("body")

if is_notification:
identifier = uuid.uuid4().hex
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this actually used for anything?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that allows us to find all instances of the same notification (one instance is created for each user as per django-notifications-hq).

To implement #3246, we'll need a new data model and than we can drop this.

msg = EmailMultiAlternatives(
subject=subject,
body=text,
from_email="Mozilla L10n Team <team@pontoon.mozilla.com>",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This probably should not be hard-coded?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed.

@mathjazz
Copy link
Collaborator Author

@eemeli Please let me know if the CSS changes look good.

@mathjazz mathjazz requested a review from eemeli June 20, 2024 17:02
@bcolsson
Copy link
Collaborator

It looks like we're hardcoding the unsubscribe footer for all emails here. In the spec the plan is to have the ability to flag a message as transactional or not, then only attach the footer when an email is not transactional.

I also realize that this was not covered by the spec, but do we also plan to adjust how messages sent as notifications appear in a users Notifications window? Testing this out it seems like a project is required and is defaulting to Pontoon Intro. Perhaps we could use only [user] has sent a message. in this instance?
Screenshot 2024-06-21 at 17 03 45

@mathjazz
Copy link
Collaborator Author

mathjazz commented Jun 24, 2024

It looks like we're hardcoding the unsubscribe footer for all emails here. In the spec the plan is to have the ability to flag a message as transactional or not, then only attach the footer when an email is not transactional.

I was planning to add support for transactional email in a separate PR, which would also include special handling of the footer. I'll see if I can find some time today to amend this PR with this change.

I also realize that this was not covered by the spec, but do we also plan to adjust how messages sent as notifications appear in a users Notifications window? Testing this out it seems like a project is required and is defaulting to Pontoon Intro. Perhaps we could use only [user] has sent a message. in this instance?

I assume you tested on stage (which uses an old version of this patch). I'll deploy the current state of the PR. Should be up in 5 minutes.

@bcolsson
Copy link
Collaborator

I'm okay with adding it to a later PR, but I didn't see an issue tracking this, so wanted to make sure this would be covered.

I assume you tested on stage (which uses an old version of this patch). I'll deploy the current state of the PR. Should be up in 5 minutes.

Thanks, yes that was what I was doing. Looks good now. 👍

@mathjazz
Copy link
Collaborator Author

mathjazz commented Jul 2, 2024

Filed #3268.

@mathjazz mathjazz merged commit 4fd99f4 into mozilla:main Jul 2, 2024
4 checks passed
@mathjazz mathjazz deleted the 3243-messaging-center-send branch July 2, 2024 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add ability to send messages to Pontoon users Add ability to send manual notifications via email
3 participants