Merge pull request '[v7.0/forgejo] migrations: Map non-existant external users to Ghost' (#3936) from bp-v7.0/forgejo-ade7304 into v7.0/forgejo
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/3936 Reviewed-by: Gergely Nagy <algernon@noreply.codeberg.org>
This commit is contained in:
commit
6d9fe1db67
3 changed files with 8 additions and 7 deletions
1
release-notes/8.0.0/fix/3935.md
Normal file
1
release-notes/8.0.0/fix/3935.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
- Fixed an issue where migrated activities (such as reviews) were mapped to the user who initiated the migration rather than the Ghost user, if the external user could not be mapped to a local one. This mapping mismatch led to internal server errors in some cases (forgejo/forgejo#3860).
|
|
@ -997,7 +997,7 @@ func (g *GiteaLocalUploader) remapUser(source user_model.ExternalUserMigrated, t
|
||||||
if userid > 0 {
|
if userid > 0 {
|
||||||
return target.RemapExternalUser("", 0, userid)
|
return target.RemapExternalUser("", 0, userid)
|
||||||
}
|
}
|
||||||
return target.RemapExternalUser(source.GetExternalName(), source.GetExternalID(), g.doer.ID)
|
return target.RemapExternalUser(source.GetExternalName(), source.GetExternalID(), user_model.GhostUserID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GiteaLocalUploader) remapLocalUser(source user_model.ExternalUserMigrated, target user_model.ExternalUserRemappable) (int64, error) {
|
func (g *GiteaLocalUploader) remapLocalUser(source user_model.ExternalUserMigrated, target user_model.ExternalUserRemappable) (int64, error) {
|
||||||
|
|
|
@ -145,24 +145,24 @@ func TestGiteaUploadRemapLocalUser(t *testing.T) {
|
||||||
|
|
||||||
//
|
//
|
||||||
// The externalID does not match any existing user, everything
|
// The externalID does not match any existing user, everything
|
||||||
// belongs to the doer
|
// belongs to the Ghost user
|
||||||
//
|
//
|
||||||
target := repo_model.Release{}
|
target := repo_model.Release{}
|
||||||
uploader.userMap = make(map[int64]int64)
|
uploader.userMap = make(map[int64]int64)
|
||||||
err := uploader.remapUser(&source, &target)
|
err := uploader.remapUser(&source, &target)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.EqualValues(t, doer.ID, target.GetUserID())
|
assert.EqualValues(t, user_model.GhostUserID, target.GetUserID())
|
||||||
|
|
||||||
//
|
//
|
||||||
// The externalID matches a known user but the name does not match,
|
// The externalID matches a known user but the name does not match,
|
||||||
// everything belongs to the doer
|
// everything belongs to the Ghost user
|
||||||
//
|
//
|
||||||
source.PublisherID = user.ID
|
source.PublisherID = user.ID
|
||||||
target = repo_model.Release{}
|
target = repo_model.Release{}
|
||||||
uploader.userMap = make(map[int64]int64)
|
uploader.userMap = make(map[int64]int64)
|
||||||
err = uploader.remapUser(&source, &target)
|
err = uploader.remapUser(&source, &target)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.EqualValues(t, doer.ID, target.GetUserID())
|
assert.EqualValues(t, user_model.GhostUserID, target.GetUserID())
|
||||||
|
|
||||||
//
|
//
|
||||||
// The externalID and externalName match an existing user, everything
|
// The externalID and externalName match an existing user, everything
|
||||||
|
@ -195,13 +195,13 @@ func TestGiteaUploadRemapExternalUser(t *testing.T) {
|
||||||
|
|
||||||
//
|
//
|
||||||
// When there is no user linked to the external ID, the migrated data is authored
|
// When there is no user linked to the external ID, the migrated data is authored
|
||||||
// by the doer
|
// by the Ghost user
|
||||||
//
|
//
|
||||||
uploader.userMap = make(map[int64]int64)
|
uploader.userMap = make(map[int64]int64)
|
||||||
target := repo_model.Release{}
|
target := repo_model.Release{}
|
||||||
err := uploader.remapUser(&source, &target)
|
err := uploader.remapUser(&source, &target)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.EqualValues(t, doer.ID, target.GetUserID())
|
assert.EqualValues(t, user_model.GhostUserID, target.GetUserID())
|
||||||
|
|
||||||
//
|
//
|
||||||
// Link the external ID to an existing user
|
// Link the external ID to an existing user
|
||||||
|
|
Loading…
Add table
Reference in a new issue