Orchard Messaging Channel Question

Topics: Core, Customizing Orchard, General
Jun 21, 2013 at 4:16 PM
Edited Jun 21, 2013 at 7:12 PM
Hello —

I am building my own implementation of IMessagingChannel and in my Orchard I now have two messaging channels available ("Email") and ("SendGrid"). I see in Administrator -> Settings there is an option to select the default messaging channel. The default messaging channel is saved as MessageSettingsPart.DefaultChannelService. However, the code in Orchard.Core modules references the "Email" channel explicitly. I looked at Orchard 1.6 and 1.X to confirm that this code has not changed.

I have two questions:

1) Is MessageSettingsPart.DefaultChannelService currently used anywhere in Orchard?

2) Is there a way to tell IMessageManager to use the default selected channel from settings when sending a message within a module?

Thank you!
Shaun
Developer
Jun 21, 2013 at 9:24 PM
Edited Jun 21, 2013 at 9:24 PM
Yes, channel reference is hardcoded in some places, eg. Orchard.Users, to always use "email" channel.
  1. Nope.
  2. Yes, the service parameter of IMessageManager.Send method is the name of the channel to use. Get the default channel from site settings and use that value as an argument. If you'd want to always use the default channel, provide your own implementation of IMessageManager (I'd recommend deriving from the default one). Then add an explicit implementation of IMessageManager.Send method that will ignore the argument passed and replace it with the one from settings before calling base.Send.
Jun 21, 2013 at 10:53 PM
Thanks pszmyd. Would you like me to submit a patch to 1.X that replaces all references of "email" service to the service parameter in IMessageManager.Send?

Thanks,
Shaun
Developer
Jun 21, 2013 at 11:10 PM
Edited Jun 21, 2013 at 11:11 PM
Np. I'm not sure if we actually want this in the core - Sebastien need to respond.

The whole thing is that messaging channels are not only meant for sending e-mails, but some features explicitly need an e-mail to be sent (like the account confirmation or challenge). That's why "email" channel is hardcoded there. After a bit of thinking I guess you should rather replace the existing e-mail channel with SendGrid-based implementation. Why would you need two channels that do exactly the same thing (send an e-mail)?

But on the other hand I agree with you that not using the default channel setting anywhere seems a bit weird. Maybe we need to rethink the design of those message channels. We'll see.
Jun 23, 2013 at 7:59 PM
These are great questions, pszmyd. I am wondering if core features which require messaging should refer to the default messaging channel. It looks like Orchard does have support for multiple messaging channels, and I think this is a nice feature to have. In our case, the existing email channel 'email' is a default option and when a SendGrid module is enabled it adds a choice for the end-user. If core Orchard modules request 'email' instead of the system default we really don't have a way to change how email is delivered in Orchard without copying the same service name, and I am not sure this is desirable behavior.
Jun 26, 2013 at 3:35 PM
Is there someone from the Orchard community that can weigh in on this functionality? I am wondering if core modules should be referring to the default messaging channel instead of "email". What is the intended behavior here?

Thanks,
Shaun
Jul 2, 2013 at 7:41 PM
Can Sebastien or anyone else weigh in on this? I am wondering if it is a bug to have core modules refer to the "email" channel explicitly as opposed to the default channel.