Skip to content

🚶🏿 Fix notification for partner message #1294

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

Merged
merged 3 commits into from
May 24, 2025
Merged
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
28 changes: 26 additions & 2 deletions backend/api/views/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@
Specializations,
)
from api.utils.request_utils import send_email
from api.utils.constants import Account, MENTOR_CONTACT_ME, TRANSLATIONS
from api.utils.constants import (
Account,
MENTOR_CONTACT_ME,
TRANSLATIONS,
UNREAD_MESSAGE_TEMPLATE,
)
from api.utils.require_auth import all_users
from api.utils.translate import get_translated_options
from api.core import create_response, logger
Expand Down Expand Up @@ -112,9 +117,28 @@ def create_message():
return create_response(status=422, message=msg)

socketio.emit(data["recipient_id"], json.loads(message.to_json()))

email_sent_status = ""
try:
recipient = PartnerProfile.objects.get(id=data["recipient_id"])
res, res_msg = send_email(
recipient.email,
data={
"number_unread": "1",
recipient.preferred_language: True,
"subject": TRANSLATIONS[recipient.preferred_language]["unread_message"],
},
template_id=UNREAD_MESSAGE_TEMPLATE,
)
print("send mail status message----------", res_msg)
logger.info(res_msg)
except:
email_sent_status = ", But failed to send message"

print("email_sent_status", email_sent_status)
return create_response(
status=201,
message=f"Successfully saved message",
message=f"Successfully saved message" + email_sent_status,
)


Expand Down