LinkinStars commented on code in PR #1465:
URL: https://github.com/apache/answer/pull/1465#discussion_r2646520359


##########
internal/service/notification_common/notification.go:
##########
@@ -423,15 +423,14 @@ func (ns *NotificationCommon) 
syncNotificationToPlugin(ctx context.Context, objI
                }
        }
 
+       externalLogins, err := 
ns.userExternalLoginRepo.GetUserExternalLoginList(ctx, msg.ReceiverUserID)
+       if err != nil {
+               log.Errorf("get user external login list failed for user %s: 
%v", msg.ReceiverUserID, err)
+       } else if len(externalLogins) > 0 {
+               pluginNotificationMsg.ReceiverExternalID = 
externalLogins[0].ExternalID
+       }
+
        _ = 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
-               }

Review Comment:
   We can retain this section so that if a search is available, notifications 
from the same system can be prioritized. If no match is found, the default 
`externalLogins[0].ExternalID` configuration will be used.



##########
internal/service/notification_common/notification.go:
##########
@@ -423,15 +423,14 @@ func (ns *NotificationCommon) 
syncNotificationToPlugin(ctx context.Context, objI
                }
        }
 
+       externalLogins, err := 
ns.userExternalLoginRepo.GetUserExternalLoginList(ctx, msg.ReceiverUserID)
+       if err != nil {
+               log.Errorf("get user external login list failed for user %s: 
%v", msg.ReceiverUserID, err)
+       } else if len(externalLogins) > 0 {
+               pluginNotificationMsg.ReceiverExternalID = 
externalLogins[0].ExternalID
+       }
+
        _ = 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
-               }

Review Comment:
   We can retain this section so that if a search is available, notifications 
from the same system can be prioritized. If no match is found, the default 
`externalLogins[0].ExternalID` will be used.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to