Skip to content

Commit c8908b7

Browse files
IfDougelseSaLinkinStars
authored andcommitted
fix(review): notifications from the specific external system will take precedence
1 parent 42f8947 commit c8908b7

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

internal/service/notification/new_question_notification.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ func (ns *ExternalNotificationService) syncNewQuestionNotificationToPlugin(ctx c
238238
}
239239
}
240240

241+
// Get all external logins as fallback
241242
externalLogins, err := ns.userExternalLoginRepo.GetUserExternalLoginList(ctx, subscriberUserID)
242243
if err != nil {
243244
log.Errorf("get user external login list failed for user %s: %v", subscriberUserID, err)
@@ -249,6 +250,15 @@ func (ns *ExternalNotificationService) syncNewQuestionNotificationToPlugin(ctx c
249250
}
250251
}
251252

253+
// Try to get external login specific to this plugin (takes precedence over fallback)
254+
userInfo, exist, err := ns.userExternalLoginRepo.GetByUserID(ctx, fn.Info().SlugName, subscriberUserID)
255+
if err != nil {
256+
log.Errorf("get user external login info failed: %v", err)
257+
return nil
258+
}
259+
if exist {
260+
newMsg.ReceiverExternalID = userInfo.ExternalID
261+
}
252262
fn.Notify(newMsg)
253263
}
254264
return nil

internal/service/notification_common/notification.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,14 @@ func (ns *NotificationCommon) syncNotificationToPlugin(ctx context.Context, objI
431431
}
432432

433433
_ = plugin.CallNotification(func(fn plugin.Notification) error {
434+
userInfo, exist, err := ns.userExternalLoginRepo.GetByUserID(ctx, fn.Info().SlugName, msg.ReceiverUserID)
435+
if err != nil {
436+
log.Errorf("get user external login info failed: %v", err)
437+
return nil
438+
}
439+
if exist {
440+
pluginNotificationMsg.ReceiverExternalID = userInfo.ExternalID
441+
}
434442
fn.Notify(pluginNotificationMsg)
435443
return nil
436444
})

0 commit comments

Comments
 (0)