diff --git a/backend/api/views/notifications.py b/backend/api/views/notifications.py index 0a658e1b6..f9c1166cf 100644 --- a/backend/api/views/notifications.py +++ b/backend/api/views/notifications.py @@ -65,6 +65,39 @@ def get_unread_dm_count(id): return create_response(data={"notifications": unread_message_number}) +@notifications.route("/unread_alert_group/", methods=["GET"]) +def send_unread_alert_group(id): + try: + email = None + user_record = PartnerProfile.objects(Q(id=id)).first() + if user_record is not None: + email = user_record.email + else: + user_record = Hub.objects(Q(id=id)).first() + if user_record is not None: + email = user_record.email + if (user_record is not None) and user_record.email_notifications: + res, res_msg = send_email( + recipient=email, + data={ + "number_unread": "1", + user_record.preferred_language: True, + "subject": TRANSLATIONS[user_record.preferred_language][ + "unread_message" + ], + }, + template_id=GROUPCHAT_TAGGED_MESSAGE_TEMPLATE, + ) + if not res: + msg = "Failed to send unread message alert email " + res_msg + logger.info(msg) + except Exception as e: + logger.info(e) + return create_response(status=422, message="failed") + + return create_response(status=200, message="Success") + + @notifications.route("/unread_alert/", methods=["GET"]) # @all_users def send_unread_alert(id): @@ -103,7 +136,7 @@ def send_unread_alert(id): "unread_message" ], }, - template_id=GROUPCHAT_TAGGED_MESSAGE_TEMPLATE, + template_id=UNREAD_MESSAGE_TEMPLATE, ) if not res: msg = "Failed to send unread message alert email " + res_msg diff --git a/frontend/src/components/GroupMessageChatArea.js b/frontend/src/components/GroupMessageChatArea.js index b74a80a3d..da38ed0d3 100644 --- a/frontend/src/components/GroupMessageChatArea.js +++ b/frontend/src/components/GroupMessageChatArea.js @@ -6,7 +6,7 @@ import { SendOutlined } from "@ant-design/icons"; import EmojiPicker from "emoji-picker-react"; import { useAuth } from "utils/hooks/useAuth"; import { - sendNotifyUnreadMessage, + sendNotifyGroupMessage, downloadBlob, getLibraryFile, } from "utils/api"; @@ -173,7 +173,7 @@ function GroupMessageChatArea(props) { setTimeout(() => { particiants.forEach((user) => { if (user._id.$oid !== profileId) { - sendNotifyUnreadMessage(user._id.$oid); + // sendNotifyGroupMessage(user._id.$oid, false); } }); }, 0); @@ -181,7 +181,7 @@ function GroupMessageChatArea(props) { } else { tagUsers.map((tag_id) => { if (tag_id !== profileId) { - sendNotifyUnreadMessage(tag_id); + sendNotifyGroupMessage(tag_id, true); } return false; }); @@ -197,15 +197,6 @@ function GroupMessageChatArea(props) { temp[block_id] = false; setReplyInputFlags(temp); setRefreshFlag(!refreshFlag); - setTagUsers([]); - if (tagUsers.length > 0) { - tagUsers.map((tag_id) => { - if (tag_id !== profileId) { - sendNotifyUnreadMessage(tag_id); - } - return false; - }); - } return; } @@ -247,7 +238,7 @@ function GroupMessageChatArea(props) { if (tagUsers.length > 0) { tagUsers.map((tag_id) => { if (tag_id !== profileId) { - sendNotifyUnreadMessage(tag_id); + sendNotifyGroupMessage(tag_id, true); } return false; }); @@ -256,7 +247,7 @@ function GroupMessageChatArea(props) { setTimeout(() => { particiants.forEach((user) => { if (user._id.$oid !== profileId) { - sendNotifyUnreadMessage(user._id.$oid); + // sendNotifyGroupMessage(user._id.$oid, false); } }); }, 0); diff --git a/frontend/src/components/MessagesChatArea.js b/frontend/src/components/MessagesChatArea.js index 5a7ade012..f28906ea1 100644 --- a/frontend/src/components/MessagesChatArea.js +++ b/frontend/src/components/MessagesChatArea.js @@ -609,6 +609,7 @@ function MessagesChatArea(props) { {accountData && ( <>