public virtual async Task SetReadAsync(PrivateMessage privateMessage)
        {
            await _privateMessageNotificationManager.DeleteByPrivateMessageIdAsync(new[] { privateMessage.Id });

            privateMessage.TrySetReadTime(_clock.Now);

            await _repository.UpdateAsync(privateMessage, true);
        }
Exemple #2
0
        public virtual async Task SetReadAsync(PrivateMessage privateMessage)
        {
            var fromUser = privateMessage.FromUserId.HasValue
                ? await _externalUserLookupServiceProvider.FindByIdAsync(privateMessage.FromUserId.Value)
                : null;

            var toUser = await _externalUserLookupServiceProvider.FindByIdAsync(privateMessage.ToUserId);

            await _privateMessageNotificationManager.DeleteByPrivateMessageIdAsync(new[] { privateMessage.Id });

            privateMessage.TrySetReadTime(_clock.Now);

            await _repository.UpdateAsync(privateMessage, true);

            _unitOfWorkManager.Current.OnCompleted(async() => await _distributedEventBus.PublishAsync(
                                                       new PrivateMessageReadEto(privateMessage.TenantId, privateMessage.Id, privateMessage.FromUserId,
                                                                                 fromUser?.UserName, privateMessage.ToUserId, toUser.UserName, privateMessage.CreationTime,
                                                                                 privateMessage.ReadTime !.Value, privateMessage.Title)));
        }