Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement callback for update PublicAsset when remove IdentityId #1059

Open
vttranlina opened this issue May 22, 2024 · 0 comments
Open

Implement callback for update PublicAsset when remove IdentityId #1059

vttranlina opened this issue May 22, 2024 · 0 comments

Comments

@vttranlina
Copy link
Member

Why?

When I remove an identity, other identity ids shall be removed in the background
original: #1050 (comment)

How

class PublicAssetIdentityCallback @Inject()(publicAssetRepository: PublicAssetRepository) extends IdentityCallback {

  override def identityRemoved(username: Username, identityId: IdentityId): Publisher[Void] = {
    // get all public assets for the user
    // then filter the public assets that have the identityId
    // then remove the identityId from the public asset
    SFlux(publicAssetRepository.list(username))
      .flatMap(publicAsset => {
        val updatedIdentityIds: Seq[IdentityId] = publicAsset.identityIds.filterNot(_ == identityId)
        publicAssetRepository.update(username, publicAsset.id, updatedIdentityIds.toSet)
      })
      .`then`()
  }
}

Dod

  • Unit test
  • jmap integration test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant