Alright, so the class you mentioned has a function FindUsersInRoleAsync, and it returns a Tuple<IEnumerable<string>, int>, where IEnumerable<string> is a list of usernames.
_notifier.PostNotificationAsync(new NotificationMessage()
{
ChannelName = "SlettingAvBlokk",
Content = content,
Subject = "Ansattblokk slettet",
Recipients = receivers,
Sender = sender,
TypeName = "PageChanged"
}).GetAwaiter().GetResult();
The method expects Recipients to be an IEnumerable<INotificationUser>. How can we get INotificationUser-objects from a list of usernames? Can we call the method FindAsync in the class QueryableNotificationUserService to retrieve INotificationUsers, or would that not work since users are logging in with Azure AD?
Hi Tam
You can create the NotificationUser objects as follows, and pass to the PostNotificationAsync method
var users = await _synchronizingRolesSecurityEntityProvider.FindUsersInRoleAsync("WebAdmins", null);
var notificationRecipients = users.Select(u => new NotificationUser(u));
I believe the Notification Dispatcher Job will resolve the users when sending the emails. Give it a go
Hi, I'm creating a scheduled job that notifies admins when a block has been deleted by the system, and where it has been used. For that to work we need to fetch users in the group WebAdmins that have logged in with Azure AD. How do we fetch users that have logged in with Azure AD, and is in the group WebAdmins? For sending user notifications, we are using the interface INotifier. An example:
_notifier.PostNotificationAsync(new NotificationMessage()
{
ChannelName = "SlettingAvBlokk",
Content = content,
Subject = "Ansattblokk slettet",
Recipients = receivers,
Sender = sender,
TypeName = "PageChanged"
}).GetAwaiter().GetResult();
Where receivers should be user in the group WebAdmins that have logged in with Azure AD. We have created a group in Azure AD for WebAdmins, so the users should be synced to the CMS group WebAdmins. In the database table SynchronizedUsers, we see the users logged in with Azure AD.