Exemplo n.º 1
0
 public NewMessagesNoticeHandler(CommunicationObject @object,
                                 NodeConnection current,
                                 IConversationsNoticeService conversationsNoticeService,
                                 IAttachmentsService attachmentsService,
                                 ICreateMessagesService createMessagesService,
                                 ICreateChannelsService createChannelsService,
                                 INodeRequestSender nodeRequestSender,
                                 ICrossNodeService crossNodeService,
                                 ILoadDialogsService loadDialogsService)
 {
     notice       = (NewMessagesNodeNotice)@object;
     this.current = current;
     this.conversationsNoticeService = conversationsNoticeService;
     this.attachmentsService         = attachmentsService;
     this.createMessagesService      = createMessagesService;
     this.createChannelsService      = createChannelsService;
     this.nodeRequestSender          = nodeRequestSender;
     this.crossNodeService           = crossNodeService;
     this.loadDialogsService         = loadDialogsService;
 }
Exemplo n.º 2
0
        public async void SendNewChannelMessageNodeNoticeAsync(MessageVm message)
        {
            try
            {
                NewMessagesNodeNotice notice   = new NewMessagesNodeNotice(message);
                IEnumerable <long>    nodesIds = await _loadChannelsService.GetChannelNodesIdAsync(message.ConversationId.GetValueOrDefault()).ConfigureAwait(false);

                if (message.Attachments != null && message.Attachments.Any())
                {
                    var forwardedMessagesAttachment = message.Attachments.FirstOrDefault(opt => opt.Type == AttachmentType.ForwardedMessages);
                    if (forwardedMessagesAttachment != null)
                    {
                        await _updateMessagesService.UpdateMessagesNodesIdsAsync((List <MessageVm>) forwardedMessagesAttachment.Payload, nodesIds).ConfigureAwait(false);
                    }
                }
                await SendNoticeToNodesAsync(notice, nodesIds).ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                Logger.WriteLog(ex);
            }
        }
Exemplo n.º 3
0
        public async void SendNewDialogMessageNodeNoticeAsync(MessageVm newMessage)
        {
            try
            {
                IEnumerable <long> nodesId = await _loadDialogsService.GetDlalogNodesAsync(newMessage.ConversationId.GetValueOrDefault()).ConfigureAwait(false);

                if (newMessage.Attachments != null && newMessage.Attachments.Any())
                {
                    var forwardedMessagesAttachment = newMessage.Attachments.FirstOrDefault(message => message.Type == AttachmentType.ForwardedMessages);
                    if (forwardedMessagesAttachment != null)
                    {
                        await _updateMessagesService.UpdateMessagesNodesIdsAsync((List <MessageVm>) forwardedMessagesAttachment.Payload, nodesId).ConfigureAwait(false);
                    }
                }
                NewMessagesNodeNotice notice = new NewMessagesNodeNotice(newMessage);
                await SendNoticeToNodesAsync(notice, nodesId).ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                Logger.WriteLog(ex);
            }
        }