-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Fix/external id notification #1465
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Fix/external id notification #1465
Conversation
|
@IfDougelseSa Originally, this notification plugin was designed to provide consistent notification functionality when users log in with the same account. For example, logging in with Slack would trigger corresponding Slack notifications. Of course, the scenario you mentioned is indeed an issue—users can configure different login methods and notification channels. Therefore, our recommendation is to retain both query methods. By default, it will use |
| 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 | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
| } | ||
| } | ||
|
|
||
| userInfo, exist, err := ns.userExternalLoginRepo.GetByUserID(ctx, fn.Info().SlugName, subscriberUserID) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can retain this section so that if a search is available, notifications from the same system can be prioritized.
Description
Fixes plugin notifications for SSO-authenticated users by querying the SSO provider's external_id instead of using the notification plugin's name.
Problem
Plugin notifications were failing for users authenticated via SSO (GitHub OAuth, Google, SAML, etc.) because the code was looking up
external_idusing the notification plugin's name instead of the SSO authentication provider.Example:
provider = "github"(SSO)provider = "discord"(notification plugin)ReceiverExternalIDis emptySolution
Query all external logins for the user and use the most recent one (ORDER BY updated_at DESC).
Changes
ORDER BY updated_at DESCtoGetUserExternalLoginListTesting
Before:
Receiver External ID: ← Empty
After:
Receiver External ID: 81540136 ← Populated
Tested with GitHub OAuth SSO and test notification plugin.