Mass notifications and "regular" notifications are stored in the same DB table. The table has a CreatorUserId field. If I create a mass notification the CreatorUserId is populated; however, the field is null if I create a "regular" in app notification. Am I doing something wrong, or is this the expected behavior? If it is the expected behavior, how can I get the CreatorUserId saved when creating all notification types?
public async Task InvoiceNotificationAsync(Vendor vendor, string hostName, long userId, string userName)
{
Logger.Warn($"InvoiceRequestNotificationAsync called");
var vendorTenantId = 1073;
var notificationData = new LocalizableMessageNotificationData(
new LocalizableString(
"message",
ERAConsts.LocalizationSourceName
)
);
notificationData["hostName"] = hostName;
notificationData["recordId"] = vendor.Id;
notificationData["recordType"] = "vendor";
notificationData["htmlCheck"] = "Yes";
notificationData["TenantName"] = vendor.TenantName;
notificationData["userId"] = userId;
notificationData["userName"] = userName;
notificationData["OrderNumber"] = vendor.OrderNumber;
notificationData["InvoiceRequestDate"] = vendor.InvoiceRequestDate;
await CurrentUnitOfWork.SaveChangesAsync();
await _notificationPublisher.PublishAsync(AppNotificationNames.InvoiceRequested, notificationData,
severity: NotificationSeverity.Warn,
tenantIds: new int?[] { vendorTenantId });
}
END GOAL
Scenario: User1 creates an order, which triggers a notification to inform User2 a task needs to be completed. User1 then realizes the order needs to be modified so he/she cancels the order. The task is removed from User2's view; however, the notification remains. I've been trying to figure out how to delete the notification when User1 cancels the order. I found this method:
public async Task<GetPublishedNotificationsOutput> GetNotificationsPublishedByUser(
GetPublishedNotificationsInput input)
{
return new GetPublishedNotificationsOutput(
await _notificationStore.GetNotificationsPublishedByUserAsync(AbpSession.ToUserIdentifier(),
AppNotificationNames.MassNotification, input.StartDate, input.EndDate)
);
}
I created a copy and changed AppNotificationNames.MassNotification to AppNotificationNames.InvoiceRequested, but then I realized the CreatorUserId is not saved.
4 Answer(s)
-
0
Hi,
Could you share where do you call
InvoiceNotificationAsync
method ? -
0
InvoiceNotificationAsync method is located in the AppNotifer file.
The method is being called from the HostAccountAppService file at the end of the update method.
-
0
@oguzhanagir could you check this case and offer a solution to @maberry ?
-
0
Hi @maberry
Do you login as a host user and then execute HostAccountAppService's method ? If so, could you share related method in HostAccountAppService and also your notification definition in AppNotificationProvider ?