I am trying to add support for notification (live, email) using INotificationType, IEmailNotificationType interfaces.
Live notifications are working, the GetMessage method is called to create a message and I see live toast.
IEmailNotificationType.Get method is not called for me.
Using a simple source code example, where after creating a media gallery item, the user should receive a notifications (email, live).
Code example:
using System; using Telligent.Common; using Telligent.Evolution.Extensibility; using Telligent.Evolution.Extensibility.Api.Version1; using Telligent.Evolution.Extensibility.Content.Version1; using Telligent.Evolution.Extensibility.Email.Version1; namespace SE.Notifications { public class MyNotificationPlugin : INotificationType, IEmailNotificationType { public string NotificationTypeName => "MyNotificationTypeName"; public string NotificationTypeDescription => "MyNotificationTypeDescription"; public string NotificationTypeCategory => "MyNotificationTypeCategory"; private readonly Guid m_NotificationGuid = new Guid("a0e161f7-7609-46df-be04-0a7deb237e89"); public Guid NotificationTypeId => m_NotificationGuid; public bool IsCacheable => true; public bool VaryCacheByUser => true; public string Name => "My Notification Plugin"; public string Description => string.Empty; private INotificationController m_Controller; public bool CanDeleteNotification(Guid notificationId, int userId) { var notification = Apis.Get<INotifications>().Get(notificationId); return notification != null && notification.UserId == userId; } public string GetTargetUrl(Guid notificationId) { var notification = Apis.Get<INotifications>().Get(notificationId); return notification != null && notification.Content != null ? notification.Content.Url : null; } public void Initialize() { var media = Apis.Get<IMedia>(); media.Events.AfterCreate += Events_AfterCreate; } public void SetController(INotificationController controller) { m_Controller = controller; } private void Events_AfterCreate(MediaAfterCreateEventArgs e) { var media = Apis.Get<IMedia>(); m_Controller.CreateUpdate(new NotificationCreateUpdateOptions { ContentId = e.ContentId, ContentTypeId = media.ContentTypeId, LastUpdate = DateTime.UtcNow, UserId = e.Author.Id.Value, ActorIdToAdd = e.Author.Id }); } public string GetMessage(Guid notificationId, string target) { var eventLogger = Services.Get<IEventLog>(); eventLogger.Write("Live message sent", new EventLogEntryWriteOptions() { EventType = "Information", Category = "Notification Test" }); return "Live Message"; } public string Get(EmailTarget target, Telligent.Evolution.Extensibility.Api.Entities.Version1.Notification notification) { // NOTE: This method is never called var eventLogger = Services.Get<IEventLog>(); eventLogger.Write("Mail template creating", new EventLogEntryWriteOptions() { EventType = "Information", Category = "Notification Test" }); // TODO: create working template return "My Mail Template"; } } }
Email options (SMTP) - enabled and configured.
User has "private & public emails", "Enable email contact" - enabled.
"Live Alert" and "Email" enabled on Profile => Settings => Notifications page.
Any "Send preview email" notifications in the Administration panel are working for me and I receiving emails.
Version: 11.1.0.9731 (Developer mode)