public async Task <IActionResult> NotifyUser([FromRoute] string userId, [FromRoute] string method, CancellationToken token) { if (!IsAuthorized()) { return(Unauthorized()); } if (!Guid.TryParse(userId, out Guid id)) { return(BadRequest("Invalid userId (Guid format expected)")); } var body = string.Empty; using (var reader = new StreamReader(Request.Body)) { body = await reader.ReadToEndAsync(); await _context.Clients.User(id.ToString("N")).SendAsync("event", new { Method = method, UserId = userId, Content = body }, token); } _sheaftMediatr.Post( new CreateUserNotificationCommand(new RequestUser("signalr-user", HttpContext.TraceIdentifier)) { UserId = id, Method = method, Content = body }); return(Ok()); }
public IActionResult Notify(PspEventKind EventType, long date, string resourceId = null, string ressourceId = null) { var requestUser = new RequestUser("hook", _httpContextAccessor.HttpContext.TraceIdentifier); var identifier = ressourceId ?? resourceId; switch (EventType) { case PspEventKind.KYC_SUCCEEDED: case PspEventKind.KYC_FAILED: case PspEventKind.KYC_OUTDATED: case PspEventKind.KYC_VALIDATION_ASKED: _sheaftMediatr.Post(new RefreshDocumentStatusCommand(requestUser, identifier)); break; case PspEventKind.UBO_DECLARATION_REFUSED: case PspEventKind.UBO_DECLARATION_VALIDATED: case PspEventKind.UBO_DECLARATION_INCOMPLETE: case PspEventKind.UBO_DECLARATION_VALIDATION_ASKED: _sheaftMediatr.Post(new RefreshDeclarationStatusCommand(requestUser, identifier)); break; case PspEventKind.PAYIN_NORMAL_SUCCEEDED: case PspEventKind.PAYIN_NORMAL_FAILED: _sheaftMediatr.Post(new RefreshPayinStatusCommand(requestUser, identifier)); break; case PspEventKind.TRANSFER_NORMAL_SUCCEEDED: case PspEventKind.TRANSFER_NORMAL_FAILED: _sheaftMediatr.Post(new RefreshTransferStatusCommand(requestUser, identifier)); break; case PspEventKind.PAYOUT_NORMAL_SUCCEEDED: case PspEventKind.PAYOUT_NORMAL_FAILED: _sheaftMediatr.Post(new RefreshPayoutStatusCommand(requestUser, identifier)); break; case PspEventKind.PAYIN_REFUND_SUCCEEDED: case PspEventKind.PAYIN_REFUND_FAILED: _sheaftMediatr.Post(new RefreshPayinRefundStatusCommand(requestUser, identifier)); break; case PspEventKind.USER_KYC_LIGHT: case PspEventKind.USER_KYC_REGULAR: _sheaftMediatr.Post(new RefreshLegalValidationCommand(requestUser, identifier)); break; case PspEventKind.PREAUTHORIZATION_PAYMENT_CANCELED: case PspEventKind.PREAUTHORIZATION_PAYMENT_EXPIRED: case PspEventKind.PREAUTHORIZATION_PAYMENT_VALIDATED: case PspEventKind.PREAUTHORIZATION_PAYMENT_WAITING: _sheaftMediatr.Post(new RefreshPreAuthorizationStatusCommand(requestUser, identifier)); break; default: _logger.LogInformation($"{EventType:G)} is not a supported Psp EventType for resource: {identifier} executed on: {GetExecutedOn(date)}."); return(BadRequest()); } return(Ok()); }
private void DispatchEvents() { while (true) { var domainEventEntity = ChangeTracker.Entries <IHasDomainEvent>() .Select(x => x.Entity.DomainEvents) .SelectMany(x => x) .FirstOrDefault(domainEvent => !domainEvent.IsPublished); if (domainEventEntity == null) { break; } domainEventEntity.IsPublished = true; _mediatr.Post(domainEventEntity); } }