-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add in-memory settings to enable/disable imouto pics upload
- Loading branch information
1 parent
689a3fb
commit 202b4cf
Showing
20 changed files
with
683 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
...Navigator/ImoutoRebirth.Navigator/Services/Collections/IImoutoPicsUploaderStateService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace ImoutoRebirth.Navigator.Services.Collections; | ||
|
||
public interface IImoutoPicsUploaderStateService | ||
{ | ||
Task EnableAsync(); | ||
|
||
Task DisableAsync(); | ||
|
||
Task<bool> IsEnabledAsync(); | ||
} |
20 changes: 20 additions & 0 deletions
20
....Navigator/ImoutoRebirth.Navigator/Services/Collections/ImoutoPicsUploaderStateService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using ImoutoRebirth.Room.WebApi.Client; | ||
|
||
namespace ImoutoRebirth.Navigator.Services.Collections; | ||
|
||
internal class ImoutoPicsUploaderStateService : IImoutoPicsUploaderStateService | ||
{ | ||
private readonly ImoutoPicsUploaderEnabledClient _imoutoPicsUploaderEnabledClient; | ||
|
||
public ImoutoPicsUploaderStateService(ImoutoPicsUploaderEnabledClient imoutoPicsUploaderEnabledClient) | ||
=> _imoutoPicsUploaderEnabledClient = imoutoPicsUploaderEnabledClient; | ||
|
||
public async Task EnableAsync() | ||
=> await _imoutoPicsUploaderEnabledClient.EnableImoutoPicsUploaderAsync(); | ||
|
||
public async Task DisableAsync() | ||
=> await _imoutoPicsUploaderEnabledClient.DisableImoutoPicsUploaderAsync(); | ||
|
||
public async Task<bool> IsEnabledAsync() | ||
=> await _imoutoPicsUploaderEnabledClient.IsImoutoPicsUploaderEnabledAsync(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
...birth.Room.Application/Cqrs/ImoutoPicsUploadStateSlice/EnableImoutoPicsUploaderCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using ImoutoRebirth.Common.Cqrs.Abstract; | ||
using ImoutoRebirth.Room.Application.Services; | ||
|
||
namespace ImoutoRebirth.Room.Application.Cqrs.ImoutoPicsUploadStateSlice; | ||
|
||
public record EnableImoutoPicsUploaderCommand : ICommand; | ||
|
||
public record DisableImoutoPicsUploaderCommand : ICommand; | ||
|
||
internal class EnableImoutoPicsUploaderCommandHandler | ||
: ICommandHandler<EnableImoutoPicsUploaderCommand> | ||
, ICommandHandler<DisableImoutoPicsUploaderCommand> | ||
{ | ||
private readonly IImoutoPicsUploaderRepository _imoutoPicsUploaderRepository; | ||
|
||
public EnableImoutoPicsUploaderCommandHandler(IImoutoPicsUploaderRepository imoutoPicsUploaderRepository) | ||
=> _imoutoPicsUploaderRepository = imoutoPicsUploaderRepository; | ||
|
||
public Task Handle(EnableImoutoPicsUploaderCommand _, CancellationToken ct) | ||
{ | ||
var state = _imoutoPicsUploaderRepository.Get(); | ||
state.Enable(); | ||
|
||
return Task.CompletedTask; | ||
} | ||
|
||
public Task Handle(DisableImoutoPicsUploaderCommand _, CancellationToken ct) | ||
{ | ||
var state = _imoutoPicsUploaderRepository.Get(); | ||
state.Disable(); | ||
|
||
return Task.CompletedTask; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...irth.Room.Application/Cqrs/ImoutoPicsUploadStateSlice/IsImoutoPicsUploaderEnabledQuery.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using ImoutoRebirth.Common.Cqrs.Abstract; | ||
using ImoutoRebirth.Room.Application.Services; | ||
|
||
namespace ImoutoRebirth.Room.Application.Cqrs.ImoutoPicsUploadStateSlice; | ||
|
||
public record IsImoutoPicsUploaderEnabledQuery : IQuery<bool>; | ||
|
||
internal class IsImoutoPicsUploaderEnabledQueryHandler | ||
: IQueryHandler<IsImoutoPicsUploaderEnabledQuery, bool> | ||
{ | ||
private readonly IImoutoPicsUploaderRepository _imoutoPicsUploaderRepository; | ||
|
||
public IsImoutoPicsUploaderEnabledQueryHandler(IImoutoPicsUploaderRepository imoutoPicsUploaderRepository) | ||
=> _imoutoPicsUploaderRepository = imoutoPicsUploaderRepository; | ||
|
||
public Task<bool> Handle(IsImoutoPicsUploaderEnabledQuery _, CancellationToken ct) | ||
{ | ||
var state = _imoutoPicsUploaderRepository.Get(); | ||
return Task.FromResult(state.IsEnabled); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
...outoRebirth.Room/ImoutoRebirth.Room.Application/Services/IImoutoPicsUploaderRepository.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using ImoutoRebirth.Room.Domain; | ||
|
||
namespace ImoutoRebirth.Room.Application.Services; | ||
|
||
public interface IImoutoPicsUploaderRepository | ||
{ | ||
ImoutoPicsUploaderState Get(); | ||
} | ||
|
||
/// <summary> | ||
/// Should be registered as a singleton. | ||
/// </summary> | ||
public class ImoutoPicsUploaderRepository : IImoutoPicsUploaderRepository | ||
{ | ||
private readonly ImoutoPicsUploaderState _state = new(); | ||
|
||
public ImoutoPicsUploaderState Get() => _state; | ||
} |
10 changes: 10 additions & 0 deletions
10
Source/ImoutoRebirth.Room/ImoutoRebirth.Room.Domain/ImoutoPicsUploaderState.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace ImoutoRebirth.Room.Domain; | ||
|
||
public class ImoutoPicsUploaderState | ||
{ | ||
public bool IsEnabled { get; private set; } = true; | ||
|
||
public void Enable() => IsEnabled = true; | ||
|
||
public void Disable() => IsEnabled = false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.