예제 #1
0
        private async Task SendNotification(string clientId, NotificationType notificationType, string message,
                                            OrderHistoryBackendContract order)
        {
            if (await _clientAccountService.IsPushEnabled(clientId))
            {
                var notificationId = await _clientAccountService.GetNotificationId(clientId);

                await _appNotifications.SendNotification(notificationId, notificationType, message, order);
            }
        }
예제 #2
0
        public async Task <ResponseModel <string> > GetNotificationId()
        {
            var clientId = this.GetClientId();

            if (clientId == null)
            {
                return(this.UserNotFoundError <string>());
            }

            var notificationId = await _clientNotificationService.GetNotificationId(clientId);

            return(ResponseModel <string> .CreateOk(notificationId));
        }
예제 #3
0
        public async Task ProcessAccountChanged(AccountChangedMessage accountChangedMessage)
        {
            if (accountChangedMessage.EventType != AccountEventTypeEnum.Updated)
            {
                return;
            }

            var account   = accountChangedMessage.Account;
            var queueName = QueueHelper.BuildQueueName(_settings.MarginTradingFront.RabbitMqQueues.AccountChanged.ExchangeName, _settings.MarginTradingFront.Env);

            _consoleWriter.WriteLine($"Get account change from {queueName} queue for clientId = {account.ClientId}");
            var notificationId = await _clientNotificationService.GetNotificationId(account.ClientId);

            var userTopic = _realm.Services.GetSubject <NotifyResponse <MarginTradingAccountClientContract> >($"user.{notificationId}");

            var notifyResponse = new NotifyResponse <MarginTradingAccountClientContract>
            {
                Entity = account.ToClientContract(),
                Type   = NotifyEntityType.Account
            };

            userTopic.OnNext(notifyResponse);

            _operationsLog.AddLog($"topic user.{notificationId} (account changed)", account.ClientId, account.Id, null, notifyResponse.ToJson());
            _consoleWriter.WriteLine($"topic user.{notificationId} (account changed) for clientId = {account.ClientId}");

            var userUpdateTopic         = _realm.Services.GetSubject <NotifyResponse>($"user.updates.{notificationId}");
            var userUpdateTopicResponse = new NotifyResponse {
                Account = notifyResponse.Entity, Order = null
            };

            userUpdateTopic.OnNext(userUpdateTopicResponse);

            _operationsLog.AddLog($"topic user.updates.{notificationId} (account changed)", account.ClientId,
                                  account.Id, null, userUpdateTopicResponse.ToJson());
            _consoleWriter.WriteLine($"topic user.updates.{notificationId} (account changed) for clientId = {account.ClientId}");
        }