public async Task <IActionResult> RemoveChannelForUser(string channelId)
        {
            var uid = User.Claims.Single(c => c.Type == Constants.Strings.JwtClaimIdentifiers.Id).Value;

            var channel = _chatRepo.GetSubscriptionsForUser(uid)?.FirstOrDefault(c => c == channelId);

            if (channel == null)
            {
                return(NotFound());
            }

            _chatRepo.RemoveSubscriptonForUser(uid, channel);

            return(Ok(getChannelsForUser(uid)));
        }
Example #2
0
        private void SubscribeUsersWhichAreNot(List <string> ids)
        {
            var chanalName = GetChannelName(ids);

            foreach (var id in ids)
            {
                if (!_chatRepo.GetSubscriptionsForUser(id).Contains(chanalName)) // todo: optimaze
                {
                    _chatRepo.AddUserForChannel(chanalName, id);
                    _chatRepo.AddSubscriptionForUser(id, chanalName);
                    if (_chatRepo.GetConnectionForUid(id) != null)
                    {
                        ConnectSubscriptionForUser(chanalName, id);
                    }
                }
            }
        }