Exemplo n.º 1
0
        public async Task <ActionResult <MessageLoadDto> > GetMessagesForConversationAsync(int id, int?currentMessageId)
        {
            var messageLoadDto = await _messageQueryService.GetMessagesForConversationAsync(id, User.GetUserId(), User.GetWorkspaceId(), currentMessageId);

            if (!await _conversationQueryService.IsSelfConversationAsync(id, User.GetUserId()))
            {
                await _cacheService.ClearAllUnreadConversationMessageIdsForUserAsync(id, User.GetUserId(), User.GetWorkspaceId());
            }
            await _cacheService.SetActiveSidebarItemAsync(false, id, User.GetUserId(), User.GetWorkspaceId());

            await _notificationService.SendUnreadConversationMessageClearedNotificationAsync(new[] { User.GetUserId() }, id);

            return(messageLoadDto);
        }
Exemplo n.º 2
0
        private async Task NotifyForNewConversationMessageAsync(int conversationId, int messageId, int userId, int workspaceId)
        {
            if (!await _conversationQueryService.IsSelfConversationAsync(conversationId, userId))
            {
                var userIds = (await _conversationQueryService.GetAllConversationUserIdsAsync(conversationId)).ToList();
                await _cacheService.AddUnreadConversationMessageForUsersAsync(conversationId, messageId, userIds, workspaceId);
            }

            await SendConversationMessageItemChangedNotificationAsync(conversationId, messageId, MessageChangeType.Added);
        }