Add reactions, reliable push & session checks

Implements message reactions and reaction packs (domain models, services, admin HTTP API, media processing via ImageSharp and limits) and adds reliable push delivery (ChatPushNotification, ChatPushDispatcher, ChatPushWorker, improved ChatNotificationService). Enhances message reading (ReadChat API, unread counts, concurrency-safe receipts) and tightens session security (access-token session validation in JWT, hub filter, SessionAuthorization). Improves SignalR behavior (session groups, reaction/channel events, hub/error mappings). Adds EF migrations, many controller fixes (Forbid handling, password API), tests (Govor.Server.Tests), docs, CI and tooling updates (Dockerfile → .NET 10, GH Actions matrix for sqlite/postgres, Govor.Server.slnx, global.json), and small infra changes (AutoMapper bump, NullPushProvider, storage/token handling).
This commit is contained in:
Artemy
2026-10-03 17:42:24 +07:00
parent 4603be9f71
commit 29cc51ee0c
127 changed files with 7290 additions and 2488 deletions
+25 -51
View File
@@ -1,53 +1,27 @@
# PresenceHub — online и offline
Подключение: /hubs/presence. Требуется роль User/Admin.
Публичных команд у хаба нет. На подключении сервер добавляет connectionId в OnlineUserStore и группу userId. Первая связь пользователя вызывает событие UserOnline; отключение последней — UserOffline.
| Событие | Payload |
| --- | --- |
| UserOnline | Guid пользователя |
| UserOffline | Guid пользователя |
Получатели определяются IUserNotificationScopeService. Несколько соединений одного пользователя учитываются отдельно.
## Ограничения
OnlineUserStore хранится в памяти одного процесса. Перезапуск теряет состояние; несколько серверов не согласованы. Online означает наличие соединения этого хаба, не доступность устройства для push.
PresenceHub не сохраняет lastSeen в БД при отключении. Для него есть отдельный HTTP ping; нужна единая политика обновления lastSeen.
Для первоначального экрана получайте доступные данные профиля/друзей; события только изменяют локальный cache. После reconnect перечитайте состояние. HTTP /api/online/status сейчас сломан из-за отсутствующих зависимостей.
Обработчики должны быть зарегистрированы до StartAsync. Не используйте события присутствия как гарантированный журнал активности.
---
description: SignalR hub for managing user online presence and notifications.
icon: wifi
---
Проверено по исходникам на 03.10.2026, commit `4603be9`. Описано текущее поведение; сервер с БД и Firebase в рамках диагностики не запускался.
# PresenceHub
### Controller Description
* **Route**: `hubs/presence`
* **Authorize**: Requires authenticated user with roles "Admin" or "User" (`[Authorize(Roles = "Admin, User")]`).
### Hub Methods
#### <mark style="color:$info;">OnConnectedAsync</mark>
* **Description**: Invoked when a client connects, updates online status and notifies friends.
* **Behavior**:
* Retrieves user ID from context.
* Aborts connection if user ID is `Guid.Empty` or user does not exist.
* Adds user to online store and their personal group.
* Notifies friends of user going online via `UserOnline` event.
* **Client-Side Events**:
* **UserOnline**: Triggered for friends with payload `userId` (Guid).
* **Responses**: None (connection aborted on invalid user ID).
#### <mark style="color:$info;">OnDisconnectedAsync</mark>
* **Description**: Invoked when a client disconnects, updates offline status and notifies friends.
* **Behavior**:
* Retrieves user ID from context, suppressing exceptions.
* Removes user from personal group if ID is valid.
* Updates user's `WasOnline` timestamp.
* Sets user as offline in store.
* Notifies friends of user going offline via `UserOffline` event.
* **Client-Side Events**:
* **UserOffline**: Triggered for friends with payload `userId` (Guid).
* **Responses**: None.
### Data Models
* **N/A**: No specific data models defined for hub methods.
### Error Handling
* **Invalid User ID**: Aborts connection with logged warning if `Guid.Empty` or user not found.
* **Unexpected Errors**: Logged, but no specific response (handled by base method).
### Logging
* Logs warnings for invalid user ID on connection.
* Logs information for disconnections with user ID and connection ID.
* Logs errors for unexpected exceptions during disconnection.
Источник: [Govor.API/Hubs/PresenceHub.cs](https://github.com/Govor-team/Govor/blob/4603be9f714135e0af72d505d17f3d1709834bea/Govor.API/Hubs/PresenceHub.cs).