Fix attachment migration error about avatarUrl startsWith undefined.

Thanks to xet7 !

Related #4780
This commit is contained in:
Lauri Ojansivu 2023-02-27 16:31:43 +02:00
parent bf42958059
commit 7b2cff4c5e

View file

@ -1361,6 +1361,7 @@ Migrations.add('migrate-avatars-collectionFS-to-ostrioFiles', () => {
'original',
'/',
);
if (user.profile.avatarUrl !== undefined) {
if (user.profile.avatarUrl.startsWith(old_url)) {
// Set avatar url to new url
Users.direct.update(
@ -1370,6 +1371,7 @@ Migrations.add('migrate-avatars-collectionFS-to-ostrioFiles', () => {
);
console.log('User avatar updated: ', user._id, new_url);
}
}
});
fileObj.remove();
}