Remove Contact Type

I would like to be able to remove a registered ContactType.
I’ve added one using
gatewayContext.getUserSourceManager().registerContactType(newContactType);
and tried to remove one using
gatewayContext.getUserSourceManager().getRegisteredContactTypes().remove(oldContactType);
It doesn’t seem to get removed from the system (I’m guessing getRegisteredContactTypes() is creating a new Set).
Is there a way to do this?

It doesn’t look like there’s a way to do this in the current API, no. What’s the use case? Each gateway startup the contact type would have to be explicitly registered to appear to end-users, so if you remove the module your new contact types will be (visibly) cleared up on the next restart.

That said, if you really need this functionality, it should be possible with some reflection, though that is absolutely going to break in 8.0+. The (private) field on the UserSourceManagerImpl class is just contactTypes. I’ll leave the rest an exercise for the reader.

1 Like

My module adds a new notification profile type, and for each instance created of that type on the gateway I wanted to add a new ContactType. So, when sending a notification with a given profile, only contacts relating to that profile would be notified.

I don’t think I need the functionality enough to take the reflection route, so might have to rethink my approach.