public ConversationsTests()
        {
            TestsData testsData = TestsData.Create(nameof(ConversationsTests));

            fillTestDbHelper     = testsData.FillTestDbHelper;
            conversationsService = testsData.AppServiceProvider.ConversationsService;
        }
Esempio n. 2
0
 public GetMessagesRequestHandler(NodeRequest request, NodeConnection current, ILoadMessagesService loadMessagesService, IConversationsService conversationsService)
 {
     this.request              = (GetMessagesNodeRequest)request;
     this.current              = current;
     this.loadMessagesService  = loadMessagesService;
     this.conversationsService = conversationsService;
 }
Esempio n. 3
0
 public PollsService(IAppServiceProvider appServiceProvider, IDbContextFactory <MessengerDbContext> contextFactory)
 {
     conversationsService = appServiceProvider.ConversationsService;
     this.contextFactory  = contextFactory;
     nodeRequestSender    = appServiceProvider.NodeRequestSender;
     connectionsService   = appServiceProvider.ConnectionsService;
 }
Esempio n. 4
0
        /// <summary>
        /// Устанавливает пользователей для коллекции сообщений.
        /// </summary>
        /// <param name="messages">Коллекция сообщений.</param>
        /// <exception cref="ArgumentException"/>
        /// <exception cref="CacheConversationException"/>
        /// <exception cref="AuthorizationRequiredException"/>
        public async Task SetUsers(IEnumerable <VKMessage> messages)
        {
            if (conversationsService == null)
            {
                conversationsService = ServiceLocator.Current.GetInstance <IConversationsService>();
            }
            if (cacheService == null)
            {
                cacheService = ServiceLocator.Current.GetInstance <IMessagesCacheService>();
            }

            var firstMsg = messages.First();

            if (!messages.All(m => m.ChatID == firstMsg.ChatID || m.UserID == firstMsg.UserID))
            {
                throw new ArgumentException("Все сообщения должны принадлежать одному чату или одному отправителю.");
            }

            if (firstMsg.IsChatMessage)
            {
                await WorkOnChat(firstMsg.ChatID, messages);
            }
            else
            {
                await WorkOnDialog(firstMsg.UserID, messages);
            }
        }
Esempio n. 5
0
 public ConversationsController(IAuthService authService, IConversationsService conversationsService, IMessagesService messagesService, IConversationValidator conversationValidator)
 {
     _authService           = authService;
     _conversationsService  = conversationsService;
     _messagesService       = messagesService;
     _conversationValidator = conversationValidator;
 }
Esempio n. 6
0
 public ConversationsController(IConversationsService conversationsService, UserManager <PoolItUser> userManager,
                                IRidesService ridesService)
 {
     this.conversationsService = conversationsService;
     this.userManager          = userManager;
     this.ridesService         = ridesService;
 }
Esempio n. 7
0
 public LoadMessagesService(IAppServiceProvider appServiceProvider, IDbContextFactory <MessengerDbContext> contextFactory)
 {
     this.loadChatsService     = appServiceProvider.LoadChatsService;
     this.conversationsService = appServiceProvider.ConversationsService;
     this.loadChannelsService  = appServiceProvider.LoadChannelsService;
     this.loadDialogsService   = appServiceProvider.LoadDialogsService;
     this.contextFactory       = contextFactory;
 }
Esempio n. 8
0
 private UsersConversationsCacheService()
 {
     loadDialogsService   = AppServiceProvider.Instance.LoadDialogsService;
     loadUsersService     = AppServiceProvider.Instance.LoadUsersService;
     loadChatsService     = AppServiceProvider.Instance.LoadChatsService;
     loadChannelsService  = AppServiceProvider.Instance.LoadChannelsService;
     conversationsService = AppServiceProvider.Instance.ConversationsService;
     repository           = new RedisUserConversationsRepository(NodeSettings.Configs.CacheServerConnection);
 }
Esempio n. 9
0
 public MessagesController(IAuthService authService,
                           IMessagesService messagesService,
                           IConversationsService conversationsService,
                           IHubContext <MessageHub> messageHub)
 {
     _authService          = authService;
     _messagesService      = messagesService;
     _conversationsService = conversationsService;
     _messageHub           = messageHub;
 }
 public ConversationsController(
     IConversationsService conversationsService,
     IMessagesService messagesService,
     IApplicationUsersService applicationUsersService,
     IFollowsService followsService,
     IHubContext <ChatHub> chatHubContext)
 {
     this.conversationsService    = conversationsService;
     this.messagesService         = messagesService;
     this.applicationUsersService = applicationUsersService;
     this.followsService          = followsService;
     this.chatHubContext          = chatHubContext;
 }
Esempio n. 11
0
 public ConversationActionNodeNoticeHandler(
     NodeNotice notice,
     NodeConnection nodeConnection,
     IConversationsService conversationsService,
     IConversationsNoticeService conversationsNoticeService,
     ILoadDialogsService loadDialogsService,
     ISystemMessagesService systemMessagesService)
 {
     this.notice                     = (ConversationActionNodeNotice)notice;
     this.nodeConnection             = nodeConnection;
     this.conversationsService       = conversationsService;
     this.conversationsNoticeService = conversationsNoticeService;
     this.loadDialogsService         = loadDialogsService;
     this.systemMessagesService      = systemMessagesService;
 }
Esempio n. 12
0
 public ConversationActionRequestHandler(
     Request request,
     ClientConnection clientConnection,
     IConversationsService conversationsService,
     IConversationsNoticeService conversationsNoticeService,
     INodeNoticeService nodeNoticeService,
     ILoadDialogsService loadDialogsService,
     ISystemMessagesService systemMessagesService)
 {
     this.request                    = (ConversationActionRequest)request;
     this.clientConnection           = clientConnection;
     this.conversationsService       = conversationsService;
     this.conversationsNoticeService = conversationsNoticeService;
     this.nodeNoticeService          = nodeNoticeService;
     this.loadDialogsService         = loadDialogsService;
     this.systemMessagesService      = systemMessagesService;
 }
 public GetMessagesRequestHandler(Request request,
                                  ClientConnection clientConnection,
                                  IConnectionsService connectionsService,
                                  ILoadMessagesService loadMessagesService,
                                  ICreateMessagesService createMessagesService,
                                  IAttachmentsService attachmentsService,
                                  ILoadChatsService loadChatsService,
                                  IConversationsService conversationsService,
                                  INodeRequestSender nodeRequestSender)
 {
     this.request               = (GetMessagesRequest)request;
     this.clientConnection      = clientConnection;
     this.connectionsService    = connectionsService;
     this.loadMessagesService   = loadMessagesService;
     this.createMessagesService = createMessagesService;
     this.attachmentsService    = attachmentsService;
     this.loadChatsService      = loadChatsService;
     this.conversationsService  = conversationsService;
     this.nodeRequestSender     = nodeRequestSender;
 }
Esempio n. 14
0
        /// <summary>
        /// Возвращает пользователей указанной беседы.
        /// </summary>
        /// <param name="convID">Идентификатор беседы.</param>
        /// <exception cref="CacheConversationException"/>
        /// <exception cref="AuthorizationRequiredException"/>
        public async Task <IEnumerable <VKProfileShort> > GetConversationUsers(long convID)
        {
            if (conversationsService == null)
            {
                conversationsService = ServiceLocator.Current.GetInstance <IConversationsService>();
            }
            if (cacheService == null)
            {
                cacheService = ServiceLocator.Current.GetInstance <IMessagesCacheService>();
            }

            IConversation conversation = null;

            try { conversation = await cacheService.GetConversation(convID); }
            catch (Exception) { }

            if (conversation == null)
            {
                if (convID < 0)
                {
                    conversation = await conversationsService.GetChat((uint)-convID);
                }
                else
                {
                    conversation = await conversationsService.GetDialog((ulong)convID);
                }
            }

            if (convID < 0)
            {
                return(((IChat)conversation).Users);
            }
            else
            {
                return new List <VKProfileShort> {
                           ((IDialog)conversation).User
                }
            };
        }
Esempio n. 15
0
 public GetAllUserConversationsNodeRequestHandler(Request request, ClientConnection clientConnection, IConversationsService conversationsService)
 {
     this.clientConnection     = clientConnection;
     this.request              = (GetAllUserConversationsRequest)request;
     this.conversationsService = conversationsService;
 }
 public ConversationsController(IConversationsService conversationsService)
 {
     _conversationsService = conversationsService;
 }
Esempio n. 17
0
        protected void Setup()
        {
            ConversationsRepository = new Mock <IConversationsRepository>();

            ConversationsService = new ConversationsService(ConversationsRepository.Object);
        }
Esempio n. 18
0
 public SystemMessagesService(IDbContextFactory <MessengerDbContext> contextFactory, IConversationsService conversationsService, ILoadDialogsService loadDialogsService)
 {
     this.contextFactory       = contextFactory;
     this.conversationsService = conversationsService;
     this.loadDialogsService   = loadDialogsService;
 }
Esempio n. 19
0
 public ConversationsHub(IConversationsService conversationsService, IRidesService ridesService)
 {
     this.conversationsService = conversationsService;
     this.ridesService         = ridesService;
 }
 public MuteConversationRequestHandler(Request request, ClientConnection clientConnection, IConversationsService conversationsService)
 {
     this.request              = (MuteConversationRequest)request;
     this.clientConnection     = clientConnection;
     this.conversationsService = conversationsService;
 }
 public ConversationsController(IConversationsService conversationsService, ILogger <ConversationsController> logger, TelemetryClient telemetryClient)
 {
     _conversationsService = conversationsService;
     _logger = logger;
 }