mirror of
https://github.com/bitwarden/server.git
synced 2025-07-04 09:32:48 -05:00
organize event models. stub out event services
This commit is contained in:
11
src/Core/Services/IEventService.cs
Normal file
11
src/Core/Services/IEventService.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Bit.Core.Enums;
|
||||
|
||||
namespace Bit.Core.Services
|
||||
{
|
||||
public interface IEventService
|
||||
{
|
||||
Task LogUserEventAsync(Guid userId, EventType type);
|
||||
}
|
||||
}
|
28
src/Core/Services/Implementations/EventService.cs
Normal file
28
src/Core/Services/Implementations/EventService.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using System.Threading.Tasks;
|
||||
using System;
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Repositories;
|
||||
using Bit.Core.Models.Data;
|
||||
|
||||
namespace Bit.Core.Services
|
||||
{
|
||||
public class EventService : IEventService
|
||||
{
|
||||
private readonly IEventRepository _eventRepository;
|
||||
private readonly GlobalSettings _globalSettings;
|
||||
|
||||
public EventService(
|
||||
IEventRepository eventRepository,
|
||||
GlobalSettings globalSettings)
|
||||
{
|
||||
_eventRepository = eventRepository;
|
||||
_globalSettings = globalSettings;
|
||||
}
|
||||
|
||||
public async Task LogUserEventAsync(Guid userId, EventType type)
|
||||
{
|
||||
var userEvent = new UserEvent(userId, type);
|
||||
await _eventRepository.CreateAsync(userEvent);
|
||||
}
|
||||
}
|
||||
}
|
14
src/Core/Services/NoopImplementations/NoopEventService.cs
Normal file
14
src/Core/Services/NoopImplementations/NoopEventService.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Bit.Core.Enums;
|
||||
|
||||
namespace Bit.Core.Services
|
||||
{
|
||||
public class NoopEventService : IEventService
|
||||
{
|
||||
public Task LogUserEventAsync(Guid userId, EventType type)
|
||||
{
|
||||
return Task.FromResult(0);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user