Initial commit carried over from private repo. This is V2.
This commit is contained in:
35
code/MessengerApi/Handlers/Endpoint/PeekEndpointHandler.cs
Normal file
35
code/MessengerApi/Handlers/Endpoint/PeekEndpointHandler.cs
Normal file
@ -0,0 +1,35 @@
|
||||
using MessengerApi.Contracts.Models.Scoped;
|
||||
using MessengerApi.Models.Scoped;
|
||||
|
||||
namespace MessengerApi.Handlers.Endpoint
|
||||
{
|
||||
public class PeekEndpointHandler
|
||||
{
|
||||
private readonly ILogger logger;
|
||||
|
||||
private readonly Timing timing;
|
||||
private readonly Identity identity;
|
||||
private readonly IUnitOfWork unitOfWork;
|
||||
|
||||
public PeekEndpointHandler(
|
||||
ILogger logger,
|
||||
Timing timing,
|
||||
Identity identity,
|
||||
IUnitOfWork unitOfWork)
|
||||
{
|
||||
this.logger = logger;
|
||||
this.timing = timing;
|
||||
this.identity = identity;
|
||||
this.unitOfWork = unitOfWork;
|
||||
}
|
||||
|
||||
public Task<int> Peek()
|
||||
{
|
||||
var pendingMessages = this.unitOfWork.Messages.GetPendingMessages(this.identity.User);
|
||||
|
||||
this.logger.Debug($"[{this.timing.Timestamp:s}] User {this.identity.User.Name} is receiving {pendingMessages.Count()}.");
|
||||
|
||||
return Task.FromResult(pendingMessages.Count());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user