dbf256 / teamcity-password-reset-plugin

TeamCity password reset plugin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Consider using MessageSender service

pavelsher opened this issue · comments

TeamCity does not have good API to send email to a user, but there is a jetbrains.buildServer.notification.MessageSender service which can be used for this task. At the moment this extension is implemented by email notifier only.

You can use jetbrains.buildServer.ExtensionProvider to obtain all registered implementations of MessageSender interface. You can distinguish email sender by looking for "Email Notifier" in return value of describe() method. Not very robust, but still better than implementing own email sending.

And by the way, congratulations for winning the plugin contest!

Pavel, thaks for detailed explanations, I'll have a look on it!

@pavelsher, and what is a correct way to work with ExtensionProvider? I inject it using constructor into my controller and for
logger.info("Extensions provider: " + extensionsProvider); logger.info("Total extensions: " + extensionsProvider.getExtensions(MessageSender.class).size());
I got
[2015-07-22 23:14:15,728] INFO - jetbrains.buildServer.SERVER - Extensions provider: jetbrains.buildServer.serverSide.impl.BuildServerServiceLocator@750132 [2015-07-22 23:14:15,730] INFO - jetbrains.buildServer.SERVER - Total extensions: 0
in the log.

It is not possible to fix this issue while there is a bug in Teamcity https://youtrack.jetbrains.com/issue/TW-43798