Base solution for your next web application
Open Closed

Notifications with Signal IR not working in single tenant #1715


User avatar
0
diegorqc created

Hi,

I think i found a bug while i was trying to get notifications with signal IR work with my project. Because i couldn't get it work i downloaded a fresh project from aspnetboilerplate and i disabled this line inside CoreModule

Configuration.MultiTenancy.IsEnabled = true;

and notifications stop working. If i enable multitenancy again, notifications with signal IR work again. I think the problem is the implementation of this method: _realTimeNotifier.SendNotificationsAsync(Notifications). I does nothing when used in single tenant mode.

My test work was this one:

public async Task UpdateTask()
        {
            var data2 = new MessageNotificationData("The update task has started");
            var userId = new UserIdentifier(null, AbpSession.UserId ?? 1);
            _notificationPublisher.Publish("UpdateMainData", data2, userIds: new[] { userId });

            var not = _userNotificationManager.GetUserNotifications(userId);

            _realTimeNotifier.SendNotificationsAsync(not.ToArray());
        }

Thanks.


1 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    By defining a UserIdentifier like this

    var userId = new UserIdentifier(null, AbpSession.UserId ?? 1);
    

    you are pointing a user in host account by giving first parameter null to UserIdentifier.

    If you disable MultiTenancy, then you should give tenantId to UserIdentifier.

    var userId = new UserIdentifier(1, AbpSession.UserId ?? 1);
    

    Even netter, you can use this.

    var userId = AbpSession.ToUserIdentifier();