You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@answer.apache.org by li...@apache.org on 2025/12/29 02:27:08 UTC

(answer) 02/02: fix(review): notifications from the specific external system will take precedence

This is an automated email from the ASF dual-hosted git repository.

linkinstar pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/answer.git

commit c8908b7b3405e1bd927c6019e35630526a29c484
Author: Douglas Cortez <do...@outlook.com>
AuthorDate: Fri Dec 26 12:18:26 2025 -0300

    fix(review): notifications from the specific external system will take precedence
---
 internal/service/notification/new_question_notification.go | 10 ++++++++++
 internal/service/notification_common/notification.go       |  8 ++++++++
 2 files changed, 18 insertions(+)

diff --git a/internal/service/notification/new_question_notification.go b/internal/service/notification/new_question_notification.go
index 085b3ec4..0a547187 100644
--- a/internal/service/notification/new_question_notification.go
+++ b/internal/service/notification/new_question_notification.go
@@ -238,6 +238,7 @@ func (ns *ExternalNotificationService) syncNewQuestionNotificationToPlugin(ctx c
 				}
 			}
 
+			// Get all external logins as fallback
 			externalLogins, err := ns.userExternalLoginRepo.GetUserExternalLoginList(ctx, subscriberUserID)
 			if err != nil {
 				log.Errorf("get user external login list failed for user %s: %v", subscriberUserID, err)
@@ -249,6 +250,15 @@ func (ns *ExternalNotificationService) syncNewQuestionNotificationToPlugin(ctx c
 				}
 			}
 
+			// Try to get external login specific to this plugin (takes precedence over fallback)
+			userInfo, exist, err := ns.userExternalLoginRepo.GetByUserID(ctx, fn.Info().SlugName, subscriberUserID)
+			if err != nil {
+				log.Errorf("get user external login info failed: %v", err)
+				return nil
+			}
+			if exist {
+				newMsg.ReceiverExternalID = userInfo.ExternalID
+			}
 			fn.Notify(newMsg)
 		}
 		return nil
diff --git a/internal/service/notification_common/notification.go b/internal/service/notification_common/notification.go
index 5dbadcb9..94ce86b1 100644
--- a/internal/service/notification_common/notification.go
+++ b/internal/service/notification_common/notification.go
@@ -431,6 +431,14 @@ func (ns *NotificationCommon) syncNotificationToPlugin(ctx context.Context, objI
 	}
 
 	_ = plugin.CallNotification(func(fn plugin.Notification) error {
+		userInfo, exist, err := ns.userExternalLoginRepo.GetByUserID(ctx, fn.Info().SlugName, msg.ReceiverUserID)
+		if err != nil {
+			log.Errorf("get user external login info failed: %v", err)
+			return nil
+		}
+		if exist {
+			pluginNotificationMsg.ReceiverExternalID = userInfo.ExternalID
+		}
 		fn.Notify(pluginNotificationMsg)
 		return nil
 	})