Files
Govor/Govor.Application/Users/UserOnlineStatus/UserNotificationScopeService.cs
T
Artemy 6d1c53beeb Refactor: migrate Core -> Domain and reorganize projects
Large refactor that renames/moves core types into a new Govor.Domain surface and reorganizes the Application layer. Models, configurations, migrations and many files moved from Govor.Core/Govor.Data to Govor.Domain; numerous Application services, interfaces and implementations were relocated or added (authentication, friends, messages, medias, push notifications, user sessions, storage, synching, private chats, etc.). Tests updated to use Govor.Domain namespaces and adjusted project references (removed Govor.Data reference from API tests). Also updated API, Hub and mapping code and project files to reflect the new structure and naming. This is primarily a codebase-wide namespace and module reorganization to establish a Domain project and restructure application services.
2026-07-16 19:27:45 +07:00

44 lines
1.6 KiB
C#

using Govor.Application.Friends;
using Microsoft.Extensions.Logging;
namespace Govor.Application.Users.UserOnlineStatus;
public class UserNotificationScopeService : IUserNotificationScopeService
{
private readonly ILogger<UserNotificationScopeService> _logger;
private readonly IFriendshipService _friendships;
public UserNotificationScopeService(ILogger<UserNotificationScopeService> logger, IFriendshipService friendships)
{
_logger = logger;
_friendships = friendships;
}
public async Task<List<Guid>> GetNotifiedUsers(Guid userId)
{
_logger.LogInformation($"Getting notified users of online/offline action user {userId}");
var users = await _friendships.GetFriendsAsync(userId);
return users.Select(u => u.Id).ToList();
}
/*public async Task SetWasOnlineAsync(Guid userId, DateTime when)
{
try
{
_logger.LogInformation("Set was-online for user {UserId}", userId);
var user = await _users.FindByIdAsync(userId);
user.WasOnline = when;
await _users.UpdateAsync(user);
}
catch (NotFoundByKeyException<Guid> ex)
{
_logger.LogError(ex, ex.Message);
throw new InvalidOperationException("User not found");
}
catch (UpdateException ex)
{
_logger.LogError(ex, "Failed to set WasOnline for user {UserId} at {Time}", userId, when);
throw new InvalidOperationException("Something went wrong when trying to set was-online for user");
}
}*/
}