|
11 | 11 | using JoinRpg.PrimitiveTypes.ProjectMetadata; |
12 | 12 | using JoinRpg.Services.Interfaces; |
13 | 13 | using JoinRpg.Services.Interfaces.Notification; |
| 14 | +using Microsoft.Extensions.Logging; |
14 | 15 |
|
15 | 16 | namespace JoinRpg.Services.Impl; |
16 | 17 |
|
17 | | -internal class ClaimServiceImpl : ClaimImplBase, IClaimService |
| 18 | +internal class ClaimServiceImpl( |
| 19 | + IUnitOfWork unitOfWork, |
| 20 | + IEmailService emailService, |
| 21 | + FieldSaveHelper fieldSaveHelper, |
| 22 | + IAccommodationInviteService accommodationInviteService, |
| 23 | + ICurrentUserAccessor currentUserAccessor, |
| 24 | + IProjectMetadataRepository projectMetadataRepository, |
| 25 | + IProblemValidator<Claim> claimValidator, |
| 26 | + ILogger<CharacterServiceImpl> logger) |
| 27 | + : ClaimImplBase(unitOfWork, emailService, currentUserAccessor, projectMetadataRepository), IClaimService |
18 | 28 | { |
19 | 29 |
|
20 | 30 | public async Task SubscribeClaimToUser(int projectId, int claimId) |
@@ -170,6 +180,14 @@ public async Task AddClaimFromUser(int projectId, |
170 | 180 | string claimText, |
171 | 181 | IReadOnlyDictionary<int, string?> fields) |
172 | 182 | { |
| 183 | + if (characterId is not null) |
| 184 | + { |
| 185 | + logger.LogDebug("About to add claim to character {characterId}", characterId); |
| 186 | + } |
| 187 | + if (characterGroupId is not null) |
| 188 | + { |
| 189 | + logger.LogDebug("About to add claim to character {characterGroupId}", characterGroupId); |
| 190 | + } |
173 | 191 | var source = await ProjectRepository.GetClaimSource(projectId, characterGroupId, characterId); |
174 | 192 | var projectInfo = await ProjectMetadataRepository.GetProjectMetadata(new(projectId)); |
175 | 193 |
|
@@ -223,14 +241,15 @@ public async Task AddClaimFromUser(int projectId, |
223 | 241 |
|
224 | 242 | if (claim.Project.Details.AutoAcceptClaims) |
225 | 243 | { |
226 | | - var userId = claim.ResponsibleMasterUserId; |
227 | | - StartImpersonate(userId); |
| 244 | + StartImpersonate(claim.ResponsibleMasterUserId); |
228 | 245 | //TODO[Localize] |
229 | 246 | await ApproveByMaster(projectId, |
230 | 247 | claim.ClaimId, |
231 | 248 | "Ваша заявка была принята автоматически"); |
232 | 249 | ResetImpersonation(); |
233 | 250 | } |
| 251 | + |
| 252 | + logger.LogInformation("Claim ({claimId}) was successfully send", claim.ClaimId); |
234 | 253 | } |
235 | 254 |
|
236 | 255 | public async Task AddComment(int projectId, int claimId, int? parentCommentId, bool isVisibleToPlayer, string commentText, FinanceOperationAction financeAction) |
@@ -485,7 +504,7 @@ public async Task DeclineByMaster(int projectId, int claimId, Claim.DenialStatus |
485 | 504 | DeleteCharacter(claim.Character, CurrentUserId); |
486 | 505 | } |
487 | 506 |
|
488 | | - await _accommodationInviteService.DeclineAllClaimInvites(claimId).ConfigureAwait(false); |
| 507 | + await accommodationInviteService.DeclineAllClaimInvites(claimId).ConfigureAwait(false); |
489 | 508 |
|
490 | 509 | var email = |
491 | 510 | await |
@@ -687,7 +706,7 @@ public async Task DeclineByPlayer(int projectId, int claimId, string commentText |
687 | 706 | claim.ClaimStatus = Claim.Status.DeclinedByUser; |
688 | 707 |
|
689 | 708 |
|
690 | | - await _accommodationInviteService.DeclineAllClaimInvites(claimId).ConfigureAwait(false); |
| 709 | + await accommodationInviteService.DeclineAllClaimInvites(claimId).ConfigureAwait(false); |
691 | 710 |
|
692 | 711 | var roomEmail = await CommonClaimDecline(claim); |
693 | 712 |
|
@@ -913,25 +932,6 @@ private void MarkCharacterChangedIfApproved(Claim claim) |
913 | 932 | } |
914 | 933 | } |
915 | 934 |
|
916 | | - private readonly FieldSaveHelper fieldSaveHelper; |
917 | | - private readonly IAccommodationInviteService _accommodationInviteService; |
918 | | - private readonly IPlotService plotService; |
919 | | - private readonly IProblemValidator<Claim> claimValidator; |
920 | | - |
921 | | - public ClaimServiceImpl(IUnitOfWork unitOfWork, IEmailService emailService, |
922 | | - FieldSaveHelper fieldSaveHelper, |
923 | | - IAccommodationInviteService accommodationInviteService, |
924 | | - ICurrentUserAccessor currentUserAccessor, |
925 | | - IPlotService plotService, |
926 | | - IProjectMetadataRepository projectMetadataRepository, |
927 | | - IProblemValidator<Claim> claimValidator) : base(unitOfWork, emailService, currentUserAccessor, projectMetadataRepository) |
928 | | - { |
929 | | - this.fieldSaveHelper = fieldSaveHelper; |
930 | | - _accommodationInviteService = accommodationInviteService; |
931 | | - this.plotService = plotService; |
932 | | - this.claimValidator = claimValidator; |
933 | | - } |
934 | | - |
935 | 935 | private void SetDiscussed(Claim claim, bool isVisibleToPlayer) |
936 | 936 | { |
937 | 937 | claim.LastUpdateDateTime = Now; |
|
0 commit comments