Exemplo n.º 1
0
        public override async Task OnConnectedAsync()
        {
            var user            = _claimsService.GetUserClaims();
            var userConnections = await _cacheService.Get <List <string> >(CachingHelpers.BuildKey("Notification", user.Id)) ?? new List <string>();

            userConnections.Add(Context.ConnectionId);
            await _cacheService.Set(CachingHelpers.BuildKey("Notification", user.Id), userConnections);

            var numOfNotifications = await _notificationService.GetUserNumberOfNotifications(user.Id);

            var unreadMessages = await _messageService.GetUnreadMessages(user.Id);

            await _pubSub.Publish(Channels.NotififcationMessageChannel, new NewNotificationMessageContract
            {
                ActionType          = NotificationActionType.UnreadMessage,
                ConnectionIds       = userConnections,
                TotalUnreadMessages = unreadMessages
            });

            await _pubSub.Publish(Channels.NotififcationMessageChannel, new NewNotificationMessageContract
            {
                ActionType          = NotificationActionType.NewNoti,
                ConnectionIds       = userConnections,
                TotalUnreadMessages = numOfNotifications
            });

            await base.OnConnectedAsync();
        }
        public IActionResult GetSuggestedContacts()
        {
            var claims   = _claimsService.GetUserClaims();
            var response = new ResponseMessage
            {
                Data = _contactService.GetContactSuggestions(claims.Id),
            };

            return(Ok(response));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Get()
        {
            var userContext = _claimService.GetUserClaims();
            var response    = new ResponseMessage
            {
                Data      = await _userService.GetUserDetails(userContext.Id),
                IsSuccess = true
            };

            return(Ok(response));
        }
Exemplo n.º 4
0
        public override async Task OnConnectedAsync()
        {
            var user = _claimsService.GetUserClaims();
            var key  = CachingHelpers.BuildKey("Chat", user.Id);

            var userConnections = await _cacheService.Get <List <string> >(key) ?? new List <string>();

            userConnections.Add(Context.ConnectionId);
            await _cacheService.Set(key, userConnections);

            await base.OnConnectedAsync();
        }
Exemplo n.º 5
0
        public async Task <IActionResult> GetConversationInfo([FromBody] PrivateMessagePaginationContract contract)
        {
            var input = new PrivateMessagePaginationContract
            {
                Cursor         = contract.Cursor,
                UserId         = _claimsService.GetUserClaims().Id,
                ContactUserId  = contract.ContactUserId,
                ConversationId = contract.ConversationId,
                PageSize       = contract.PageSize
            };
            var conversation = await _messageService.GetPrivateConversationInfo(input);

            var response = new ResponseMessage
            {
                Data      = conversation,
                IsSuccess = true
            };

            return(Ok(response));
        }