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 2024/05/06 08:56:19 UTC

(incubator-answer-plugins) branch main updated: feat(github): use the primary email first

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

linkinstar pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-answer-plugins.git


The following commit(s) were added to refs/heads/main by this push:
     new 57973fa  feat(github): use the primary email first
57973fa is described below

commit 57973fade7e3dfdbf544257ab9c3a7bbf636c43a
Author: LinkinStars <li...@foxmail.com>
AuthorDate: Wed Apr 24 17:26:53 2024 +0800

    feat(github): use the primary email first
---
 connector-github/github.go | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/connector-github/github.go b/connector-github/github.go
index 141ce9e..096d08a 100644
--- a/connector-github/github.go
+++ b/connector-github/github.go
@@ -122,9 +122,6 @@ func (g *Connector) ConnectorReceiver(ctx *plugin.GinContext, receiverURL string
 }
 
 func (g *Connector) guaranteeEmail(email string, accessToken string) string {
-	if len(email) == 0 {
-		return ""
-	}
 	client := oauth2.NewClient(context.Background(), oauth2.StaticTokenSource(
 		&oauth2.Token{AccessToken: accessToken},
 	))
@@ -137,12 +134,11 @@ func (g *Connector) guaranteeEmail(email string, accessToken string) string {
 		return ""
 	}
 	for _, e := range emails {
-		if e.GetEmail() == email && e.GetVerified() {
-			log.Infof("email %s was verified", email)
-			return email
+		if e.GetPrimary() {
+			return e.GetEmail()
 		}
 	}
-	return ""
+	return email
 }
 
 func (g *Connector) ConfigFields() []plugin.ConfigField {