ABP实时通知系统UserId为空

ABP real-time notification system UserId is null

我正在尝试使用实时通知。我尝试了所有示例,但是当我 SendNotificationsAsync 时,我的客户没有收到它。

此外,AbpNotifications table 始终为空。

启动:

public class Startup
{
    public void Configuration(IAppBuilder app)
    {
        GlobalHost.DependencyResolver.UseRedis("redis", 6379, "", "ChecklistCache");
        app.MapSignalR();
    }
}

子:

public async Task Subscribe_NewAlert(int? tenantId, long userId)
{
    await _notificationSubscriptionManager.SubscribeAsync(new UserIdentifier(tenantId, userId), "NewAlert");
}

酒吧:

public async Task Publish_NewAlert(string alert)
{
    var msg = new MessageNotificationData($"New alert created! {alert}");
    await _notiticationPublisher.PublishAsync("NewAlert", msg, severity: NotificationSeverity.Info);
}

我的工作:

[Abp.Domain.Uow.UnitOfWork]
public override void Execute(UserIdentifier args)
{
    var notifications = _userNotificationManager.GetUserNotifications(args);
    Abp.Threading.AsyncHelper.RunSync(() => _realTimeNotifier.SendNotificationsAsync(notifications.ToArray()));
}
  1. 我检查了 _realTimeNotifier 并且我的 UserId 为空,但是 IOnlineClientManager 自动设置了一个用户。我在哪里可以设置我的用户 ID?

  2. 要使用 ABP 通知系统,我必须拥有 ABP 创建的所有通用 table 吗? (AbpUserAbpTenantAbpRoles、权限等)我可以更改那些 table 的名称和列名称吗?如果我使用外部登录并且我没有所有这些信息,我还需要那些 tables 吗?

  3. 当我在执行时设置我的 ID 时,它起作用了。此外,在显示通知后,它不会从数据库中删除,因此每次都会显示。必须手动删除吗?

让我试着澄清一下我需要什么:

在我对我的站点实施身份验证后,它现在可以正常工作了。但我现在的问题是我的通知不会过期。每次我发布通知时,我都会向我的客户显示 AbpUserNotifications table.

上的所有通知

通知什么时候过期?我的理解是,当我发布通知时,会在 table AbpUserNotifications 上创建一条记录,然后显示给客户端。但是当我发布另一个通知时,它会向我的客户显示两个通知。我需要手动控制通知吗?

实时通知

I checked _realTimeNotifier and my UserId is null, but the IOnlineClientManager sets an user automatically, where can I set my user id?

它是由身份验证(授权)系统从 cookie 或 JWT 令牌自动设置的。

持续通知

to use the abp notification system I must have all the common tables that abp framework creates? (abpUser, AbpTenant, AbpRoles, permissions, etc) I can change those tables names and columns names too? And if I use external login, I don't have all that info, still need those tables?

不,您不需要所有 个表格。您可以实施自己的 INotificationStore 和服务。

使用存储库实现存储的零模块创建并使用公用表。

External login 确实在您的应用程序的租户中创建了一个用户。这就是大多数应用程序的工作方式。

When I set my ID at execution time works, also after the notification is shown, its not deleted from database, so is showing every time, I must delete manually?

Now is working, after I implemented authentication to my site, but my problem now is that my notifications dont expire, everytime I publish a notifications is show to my Client I notifications that is on AbpUserNotifications table.

When Notifications expire? My understanding is that when I publish a notification a record is created on Table AbpUserNotifications and them I show to the client, but when I publish another notifications is showing TWO notify to my client. I need to control my notifications manually?

通知不会过期。您应该将其标记为已读(类似于 Stack Overflow)或将其删除。