A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.
fix(review): notifications from the specific external system will take precedence
Douglas Cortezc8908b7b3405
diff --git a/internal/service/notification/new_question_notification.go b/internal/service/notification/new_question_notification.goindex 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 fallbackexternalLogins, 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 nildiff --git a/internal/service/notification_common/notification.go b/internal/service/notification_common/notification.goindex 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})