@@ -127,7 +127,7 @@ export default class OrganizationService extends LoggerBase {
127127 currentSegments : secondMemberSegments ,
128128 } )
129129
130- // Delete toMerge member
130+ // Delete toMerge organization
131131 await OrganizationRepository . destroy ( toMergeId , repoOptions , true )
132132
133133 await SequelizeRepository . commitTransaction ( tx )
@@ -422,25 +422,28 @@ export default class OrganizationService extends LoggerBase {
422422 data . website = websiteNormalizer ( data . website )
423423 }
424424
425- const originalIdentities = data . identities
425+ if ( data . identities ) {
426+ const originalIdentities = data . identities
426427
427- // check identities
428- await OrganizationRepository . checkIdentities ( data , { ...this . options , transaction } , id )
428+ // check identities
429+ await OrganizationRepository . checkIdentities ( data , { ...this . options , transaction } , id )
429430
430- // if we found any strong identities sent already existing in another organization
431- // instead of making it a weak identity we throw an error here, because this function
432- // is mainly used for doing manual updates through UI and possibly
433- // we don't wanna do an auto-merge here or make strong identities sent by user as weak
434- if ( originalIdentities . length !== data . identities . length ) {
435- const alreadyExistingStrongIdentities = originalIdentities . filter (
436- ( oi ) => ! data . identities . some ( ( di ) => di . platform === oi . platform && di . name === oi . name ) ,
437- )
431+ // if we found any strong identities sent already existing in another organization
432+ // instead of making it a weak identity we throw an error here, because this function
433+ // is mainly used for doing manual updates through UI and possibly
434+ // we don't wanna do an auto-merge here or make strong identities sent by user as weak
435+ if ( originalIdentities . length !== data . identities . length ) {
436+ const alreadyExistingStrongIdentities = originalIdentities . filter (
437+ ( oi ) =>
438+ ! data . identities . some ( ( di ) => di . platform === oi . platform && di . name === oi . name ) ,
439+ )
438440
439- throw new Error (
440- `Organization identities ${ JSON . stringify (
441- alreadyExistingStrongIdentities ,
442- ) } already exist in another organization!`,
443- )
441+ throw new Error (
442+ `Organization identities ${ JSON . stringify (
443+ alreadyExistingStrongIdentities ,
444+ ) } already exist in another organization!`,
445+ )
446+ }
444447 }
445448
446449 const record = await OrganizationRepository . update ( id , data , {
0 commit comments