public async Task DeleteChannelAsync()
        {
            await _slackChannelRepository.AddSlackChannelAsync(slackChannelDetails);

            await _slackChannelRepository.DeleteChannelAsync(slackChannelDetails.ChannelId);

            SlackChannelDetails slackChannel = await _slackChannelRepository.GetByIdAsync(slackChannelDetails.ChannelId);

            Assert.Null(slackChannel);
        }
Ejemplo n.º 2
0
        public async Task <IHttpActionResult> SlackEventAsync(SlackEventApiAC slackEvent)
        {
            //slack verification
            if (slackEvent.Type == _stringConstantRepository.VerificationUrl)
            {
                return(Ok(slackEvent.Challenge));
            }
            eventQueue.Enqueue(slackEvent);
            foreach (var events in eventQueue)
            {
                string eventType = slackEvent.Event.Type;
                //when a user is added to the slack team
                if (eventType == _stringConstantRepository.TeamJoin)
                {
                    await _oAuthLoginRepository.SlackEventUpdateAsync(events);

                    eventQueue.Dequeue();
                    return(Ok());
                }
                //when a user's details are changed
                else if (eventType == _stringConstantRepository.UserChange)
                {
                    await _slackUserRepository.UpdateSlackUserAsync(events.Event.User);

                    eventQueue.Dequeue();
                    return(Ok());
                }
                //when a public channel is created or renamed or a private channel is renamed
                else if (eventType == _stringConstantRepository.ChannelCreated || eventType == _stringConstantRepository.ChannelRename || eventType == _stringConstantRepository.GroupRename)
                {
                    await _oAuthLoginRepository.SlackChannelAddAsync(events);

                    eventQueue.Dequeue();
                    return(Ok());
                }
                //when a channel or a group is archived
                else if (eventType == _stringConstantRepository.ChannelArchive || eventType == _stringConstantRepository.GroupArchive)
                {
                    await _slackChannelRepository.DeleteChannelAsync(events.Event.Channel.ChannelId);

                    eventQueue.Dequeue();
                    return(Ok());
                }
                else
                {
                    eventQueue.Dequeue();
                    return(Ok());
                }
            }
            return(Ok());
        }