mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-11-03 08:02:36 +09:00 
			
		
		
		
	Signed-off-by: Wenxuan Zhao <viz@linux.com>
This commit is contained in:
		@@ -168,7 +168,7 @@ func FindExternalUsersByProvider(opts FindExternalUserOptions) ([]ExternalLoginU
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// UpdateMigrationsByType updates all migrated repositories' posterid from gitServiceType to replace originalAuthorID to posterID
 | 
					// UpdateMigrationsByType updates all migrated repositories' posterid from gitServiceType to replace originalAuthorID to posterID
 | 
				
			||||||
func UpdateMigrationsByType(tp structs.GitServiceType, externalUserID, userID int64) error {
 | 
					func UpdateMigrationsByType(tp structs.GitServiceType, externalUserID string, userID int64) error {
 | 
				
			||||||
	if err := UpdateIssuesMigrationsByType(tp, externalUserID, userID); err != nil {
 | 
						if err := UpdateIssuesMigrationsByType(tp, externalUserID, userID); err != nil {
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1950,7 +1950,7 @@ func (issue *Issue) ResolveMentionsByVisibility(ctx DBContext, doer *User, menti
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// UpdateIssuesMigrationsByType updates all migrated repositories' issues from gitServiceType to replace originalAuthorID to posterID
 | 
					// UpdateIssuesMigrationsByType updates all migrated repositories' issues from gitServiceType to replace originalAuthorID to posterID
 | 
				
			||||||
func UpdateIssuesMigrationsByType(gitServiceType structs.GitServiceType, originalAuthorID, posterID int64) error {
 | 
					func UpdateIssuesMigrationsByType(gitServiceType structs.GitServiceType, originalAuthorID string, posterID int64) error {
 | 
				
			||||||
	_, err := x.Table("issue").
 | 
						_, err := x.Table("issue").
 | 
				
			||||||
		Where("repo_id IN (SELECT id FROM repository WHERE original_service_type = ?)", gitServiceType).
 | 
							Where("repo_id IN (SELECT id FROM repository WHERE original_service_type = ?)", gitServiceType).
 | 
				
			||||||
		And("original_author_id = ?", originalAuthorID).
 | 
							And("original_author_id = ?", originalAuthorID).
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1025,7 +1025,7 @@ func FetchCodeComments(issue *Issue, currentUser *User) (CodeComments, error) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// UpdateCommentsMigrationsByType updates comments' migrations information via given git service type and original id and poster id
 | 
					// UpdateCommentsMigrationsByType updates comments' migrations information via given git service type and original id and poster id
 | 
				
			||||||
func UpdateCommentsMigrationsByType(tp structs.GitServiceType, originalAuthorID, posterID int64) error {
 | 
					func UpdateCommentsMigrationsByType(tp structs.GitServiceType, originalAuthorID string, posterID int64) error {
 | 
				
			||||||
	_, err := x.Table("comment").
 | 
						_, err := x.Table("comment").
 | 
				
			||||||
		Where(builder.In("issue_id",
 | 
							Where(builder.In("issue_id",
 | 
				
			||||||
			builder.Select("issue.id").
 | 
								builder.Select("issue.id").
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -369,7 +369,7 @@ func SyncReleasesWithTags(repo *Repository, gitRepo *git.Repository) error {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// UpdateReleasesMigrationsByType updates all migrated repositories' releases from gitServiceType to replace originalAuthorID to posterID
 | 
					// UpdateReleasesMigrationsByType updates all migrated repositories' releases from gitServiceType to replace originalAuthorID to posterID
 | 
				
			||||||
func UpdateReleasesMigrationsByType(gitServiceType structs.GitServiceType, originalAuthorID, posterID int64) error {
 | 
					func UpdateReleasesMigrationsByType(gitServiceType structs.GitServiceType, originalAuthorID string, posterID int64) error {
 | 
				
			||||||
	_, err := x.Table("release").
 | 
						_, err := x.Table("release").
 | 
				
			||||||
		Where("repo_id IN (SELECT id FROM repository WHERE original_service_type = ?)", gitServiceType).
 | 
							Where("repo_id IN (SELECT id FROM repository WHERE original_service_type = ?)", gitServiceType).
 | 
				
			||||||
		And("original_author_id = ?", originalAuthorID).
 | 
							And("original_author_id = ?", originalAuthorID).
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,8 +5,6 @@
 | 
				
			|||||||
package migrations
 | 
					package migrations
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"strconv"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	"code.gitea.io/gitea/models"
 | 
						"code.gitea.io/gitea/models"
 | 
				
			||||||
	"code.gitea.io/gitea/modules/log"
 | 
						"code.gitea.io/gitea/modules/log"
 | 
				
			||||||
	"code.gitea.io/gitea/modules/structs"
 | 
						"code.gitea.io/gitea/modules/structs"
 | 
				
			||||||
@@ -40,11 +38,7 @@ func updateMigrationPosterIDByGitService(tp structs.GitServiceType) error {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		for _, user := range users {
 | 
							for _, user := range users {
 | 
				
			||||||
			externalUserID, err := strconv.ParseInt(user.ExternalID, 10, 64)
 | 
								externalUserID := user.ExternalID
 | 
				
			||||||
			if err != nil {
 | 
					 | 
				
			||||||
				log.Warn("Parse externalUser %#v 's userID failed: %v", user, err)
 | 
					 | 
				
			||||||
				continue
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			if err := models.UpdateMigrationsByType(tp, externalUserID, user.UserID); err != nil {
 | 
								if err := models.UpdateMigrationsByType(tp, externalUserID, user.UserID); err != nil {
 | 
				
			||||||
				log.Error("UpdateMigrationsByType type %s external user id %v to local user id %v failed: %v", tp.Name(), user.ExternalID, user.UserID, err)
 | 
									log.Error("UpdateMigrationsByType type %s external user id %v to local user id %v failed: %v", tp.Name(), user.ExternalID, user.UserID, err)
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,7 +5,6 @@
 | 
				
			|||||||
package externalaccount
 | 
					package externalaccount
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"strconv"
 | 
					 | 
				
			||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"code.gitea.io/gitea/models"
 | 
						"code.gitea.io/gitea/models"
 | 
				
			||||||
@@ -45,10 +44,7 @@ func LinkAccountToUser(user *models.User, gothUser goth.User) error {
 | 
				
			|||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	externalID, err := strconv.ParseInt(externalLoginUser.ExternalID, 10, 64)
 | 
						externalID := externalLoginUser.ExternalID
 | 
				
			||||||
	if err != nil {
 | 
					 | 
				
			||||||
		return err
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	var tp structs.GitServiceType
 | 
						var tp structs.GitServiceType
 | 
				
			||||||
	for _, s := range structs.SupportedFullGitService {
 | 
						for _, s := range structs.SupportedFullGitService {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user