mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-11-03 08:02:36 +09:00 
			
		
		
		
	Fix migration information update bug when linked github account (#10310)
* Fix bug on upgrade migrated reactions * Fix migration information update bug when linked github account Co-authored-by: zeripath <art27@cantab.net>
This commit is contained in:
		@@ -1873,9 +1873,8 @@ func UpdateIssuesMigrationsByType(gitServiceType structs.GitServiceType, origina
 | 
				
			|||||||
// UpdateReactionsMigrationsByType updates all migrated repositories' reactions from gitServiceType to replace originalAuthorID to posterID
 | 
					// UpdateReactionsMigrationsByType updates all migrated repositories' reactions from gitServiceType to replace originalAuthorID to posterID
 | 
				
			||||||
func UpdateReactionsMigrationsByType(gitServiceType structs.GitServiceType, originalAuthorID string, userID int64) error {
 | 
					func UpdateReactionsMigrationsByType(gitServiceType structs.GitServiceType, originalAuthorID string, userID int64) error {
 | 
				
			||||||
	_, err := x.Table("reaction").
 | 
						_, err := x.Table("reaction").
 | 
				
			||||||
		Join("INNER", "issue", "issue.id = reaction.issue_id").
 | 
							Where("original_author_id = ?", originalAuthorID).
 | 
				
			||||||
		Where("issue.repo_id IN (SELECT id FROM repository WHERE original_service_type = ?)", gitServiceType).
 | 
							And(migratedIssueCond(gitServiceType)).
 | 
				
			||||||
		And("reaction.original_author_id = ?", originalAuthorID).
 | 
					 | 
				
			||||||
		Update(map[string]interface{}{
 | 
							Update(map[string]interface{}{
 | 
				
			||||||
			"user_id":            userID,
 | 
								"user_id":            userID,
 | 
				
			||||||
			"original_author":    "",
 | 
								"original_author":    "",
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -208,20 +208,24 @@ func InsertReleases(rels ...*Release) error {
 | 
				
			|||||||
	return sess.Commit()
 | 
						return sess.Commit()
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// UpdateReviewsMigrationsByType updates reviews' migrations information via given git service type and original id and poster id
 | 
					func migratedIssueCond(tp structs.GitServiceType) builder.Cond {
 | 
				
			||||||
func UpdateReviewsMigrationsByType(tp structs.GitServiceType, originalAuthorID string, posterID int64) error {
 | 
						return builder.In("issue_id",
 | 
				
			||||||
	_, err := x.Table("review").
 | 
					 | 
				
			||||||
		Where(builder.In("issue_id",
 | 
					 | 
				
			||||||
		builder.Select("issue.id").
 | 
							builder.Select("issue.id").
 | 
				
			||||||
			From("issue").
 | 
								From("issue").
 | 
				
			||||||
			InnerJoin("repository", "issue.repo_id = repository.id").
 | 
								InnerJoin("repository", "issue.repo_id = repository.id").
 | 
				
			||||||
			Where(builder.Eq{
 | 
								Where(builder.Eq{
 | 
				
			||||||
				"repository.original_service_type": tp,
 | 
									"repository.original_service_type": tp,
 | 
				
			||||||
			}),
 | 
								}),
 | 
				
			||||||
		)).
 | 
						)
 | 
				
			||||||
		And("review.original_author_id = ?", originalAuthorID).
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// UpdateReviewsMigrationsByType updates reviews' migrations information via given git service type and original id and poster id
 | 
				
			||||||
 | 
					func UpdateReviewsMigrationsByType(tp structs.GitServiceType, originalAuthorID string, posterID int64) error {
 | 
				
			||||||
 | 
						_, err := x.Table("review").
 | 
				
			||||||
 | 
							Where("original_author_id = ?", originalAuthorID).
 | 
				
			||||||
 | 
							And(migratedIssueCond(tp)).
 | 
				
			||||||
		Update(map[string]interface{}{
 | 
							Update(map[string]interface{}{
 | 
				
			||||||
			"poster_id":          posterID,
 | 
								"reviewer_id":        posterID,
 | 
				
			||||||
			"original_author":    "",
 | 
								"original_author":    "",
 | 
				
			||||||
			"original_author_id": 0,
 | 
								"original_author_id": 0,
 | 
				
			||||||
		})
 | 
							})
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user