Thanks! The article was somewhat helpful. However, I do think this is an Abp issue or at least I need further help understanding what it is doing.
The article talks about converting to and from local time. Basically, I don't want to convert. When I send a date to the server, that's date what I want to store. But it seems like Abp adjusts if for me when it maps my Dtos.
Cinco de Mayo is always May 5th. Christmas is always on December 25th. New Years is always January 1st.
That's not quite right.
Let's say I save a UTC date time as July 1, 2017 0:00 Z. This is the DAY the event is happening. July 1st.
Now when someone 1 hour west of me opens the event, it says that it is happening June 30th.
Nevermind..... forgot to inherit IApplicationService.
Ok great. I'm running into an angular injection error.
I named my service IContentNotificationAppService. I tried to inject 'abp.services.app.contentNotification'. It complains that it cannot find 'abp.services.app.contentNotificationProvider'.
Is this due to some convention?
BTW, my managers might be in parent organizations. So I need to go up the tree first. Is this a good way to do it?
var org = await _organizations.GetAsync(header.OrganizationUnitId); // go up the organization tree while(org.Parent != null) { org = org.Parent; } // now that we're on the top, get the users var users = await _userManager.GetUsersInOrganizationUnit(org, true);
***************************** [EDIT] *********************************** This is not the correct way to get managers of an organization. Obviously, it will get ALL the users within the tenant!!
This works though. I will probably make this an extension method since I frequently need to find managers within parent organizations.
List<User> users = new List<User>();
// go up the organization tree
do {
var ous = await _userManager.GetUsersInOrganizationUnit(org, false);
users.AddRange(ous);
org = org.Parent;
}
while (org != null);
This is what I'm thinking.... I haven't tried it yet. I'm about to. I created another AppService called ContentNotificationAppService. I'll call this on the client after a successful content creation. Is this the right direction? Rather than injecting some notification service in my ContentAppService?? Below is the method from ContentNoficationAppService.
public async Task ContentSubmitted(EntityDto<Guid> input) { var content = await _contents.GetAsync(input.Id); var org = await _organizations.GetAsync(content.OrganizationUnitId);
var users = await _userManager.GetUsersInOrganizationUnit(org, false);
var currentUser = await _userManager.GetUserByIdAsync(AbpSession.GetUserId());
List<UserIdentifier> userIds = new List<UserIdentifier>();
foreach(var user in users) {
if(user.Id == currentUser.Id) {
// we don't need to send a notification to ourselves
continue;
}
// we need to see if this is a manager within our organization
bool isManager = await _userManager.IsGrantedAsync(user.Id, AppPermissions.Pages_Content_ManageContent);
bool isSubscribed = await _notificationSubcriptionManager.IsSubscribedAsync(user.ToUserIdentifier(), ContentAppNotificationNames.ContentSubmitted);
if(isManager && isSubscribed) {
userIds.Add(user.ToUserIdentifier());
}
}
if (userIds.Count > 0) {
// send the notification to the users
await _notificationPublisher.PublishAsync(
ContentAppNotificationNames.ContentSubmitted,
data: new MessageNotificationData($"{currentUser.FullName} has submitted some content."),
userIds: userIds.ToArray());
}
}
Yes to each user in an organization.
My question is, if I simply loop over all the users in an organization and send the notification explicitly, will the notification service respect the Subscribe/Unsubscribe options. In other words, if I send a notification to a user who has not subscribed AND who does not have permissions for that notification, will he get the notification?