Ejemplo n.º 1
0
        public async Task <IEnumerable <SlackChatHub> > GetChannels()
        {
            IChannelClient client   = _connectionFactory.CreateChannelClient();
            var            channels = await client.GetChannels(SlackKey);

            var groups = await client.GetGroups(SlackKey);

            var fromChannels = channels.Select(c => c.ToChatHub());
            var fromGroups   = groups.Select(g => g.ToChatHub());

            return(fromChannels.Concat(fromGroups));
        }
Ejemplo n.º 2
0
        //TODO: Cache newly created channel, and return if already exists
        public async Task <SlackChatHub> JoinDirectMessageChannel(string user)
        {
            if (string.IsNullOrEmpty(user))
            {
                throw new ArgumentNullException(nameof(user));
            }

            IChannelClient client  = _connectionFactory.CreateChannelClient();
            Channel        channel = await client.JoinDirectMessageChannel(SlackKey, user);

            return(new SlackChatHub
            {
                Id = channel.Id,
                Name = channel.Name,
                Type = SlackChatHubType.DM
            });
        }