public IActionResult SendMessage(SendMessageVM model)
        {
            bool success;
            var  message = string.Empty;

            try
            {
                if (!model.IsNotRobot)
                {
                    message = "Confirm that you are not a robot!";
                    success = false;
                }
                else if (ModelState.IsValid)
                {
                    var supportMessage = new SupportMessage
                    {
                        Email   = model.Email,
                        Message = model.Message,
                        Name    = model.Name
                    };
                    success = UnitOfWork.SupportMessages.Merge(supportMessage);
                }
                else
                {
                    message = ModelState.GetHtmlErrors();
                    success = false;
                }
            }
            catch (Exception ex)
            {
                success = false;
                message = "An error occurred while sending! Contact Support.";
            }
            return(Json(new { success, message }));
        }
示例#2
0
        private void BuscarMensagens(Support support)
        {
            List <SupportMessage> supportMessage = new SupportMessage {
                SupportId = support.SupportId
            }.ObterPorId();

            if (supportMessage.Count != supportMessages.Count)
            {
                RemoverMensagens();
                supportMessages = supportMessage;
                foreach (SupportMessage message in supportMessage)
                {
                    switch (message.Method)
                    {
                    case Method.RECEIVED:
                        InserirMensagemRecebida(message);
                        break;

                    case Method.SENTED:
                        InserirMensagemEnviada(message);
                        break;
                    }
                }
            }

            //myTimer.Enabled = true;
        }
示例#3
0
        public IActionResult SendMessage(SendMessageVM model)
        {
            bool success;
            var  message = string.Empty;

            try
            {
                if (!model.IsNotRobot)
                {
                    message = "Подтвердите, что Вы не робот!";
                    success = false;
                }
                else if (ModelState.IsValid)
                {
                    var supportMessage = new SupportMessage
                    {
                        Email   = model.Email,
                        Message = model.Message,
                        Name    = model.Name
                    };
                    success = UnitOfWork.SupportMessages.Merge(supportMessage);
                }
                else
                {
                    message = ModelState.GetHtmlErrors();
                    success = false;
                }
            }
            catch (Exception ex)
            {
                success = false;
                message = "При отправке произошла ошибка! Обратитесь в службу поддержки.";
            }
            return(Json(new { success, message }));
        }
示例#4
0
        public static void QueueSupportEmail(this IEmailService emailSender, SupportMessage message, string recipient)
        {
            var subject = "Support message from listener on Chavah Messianic Radio";
            var body    = $@"
                <p>You received the following message via Chavah's support page:</p>
                <p>From: {message.Name}, {message.Email}
                    <br>User: {message.UserId}
                    <br>Dated: {message.Date.ToString()}
                    <br>User agent: {message.UserAgent}
                    <br>Message:
                </p>
                <p>{message.Message}</p>";

            emailSender.QueueSendEmail(recipient, subject, body, message.Email);
        }
示例#5
0
        private void btnSend_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(txtMessage.Text))
            {
                SupportMessage supportMessage = new SupportMessage
                {
                    SupportId  = Support.SupportId,
                    EmployeeId = AppDesktop.ActualEmployee.EmployeeId,
                    CustomerId = Support.CustomerId,
                    Message    = txtMessage.Text,
                    SentedAt   = DateTime.Now,
                    Method     = Method.SENTED
                };


                enviaMessagem(supportMessage);
                txtMessage.Text = null;
            }
        }
        private void SendEmail()
        {
            try
            {
                SupportMessage message = new SupportMessage("Help! Bugs in \"NFSU2 ExOpts-UI\" application!", userEmail, userComment);
                message.OnMailSendingStarted += StartSending;
                message.OnMailSendingEnded   += SendingEnded;
                message.OnExceptionCatched   += SendingError;

                string[] files = Directory.GetFiles(App.ApplicationDataFolder, "*.*", SearchOption.AllDirectories);
                message.AddFiles(files);

                message.SendAsync();
            }
            catch (Exception ex)
            {
                Errors.WriteError(ex);
            }
        }
示例#7
0
        private void InserirMensagemRecebida(SupportMessage message)
        {
            Label lblReceived = new Label();

            lblReceived.AllowDrop   = true;
            lblReceived.AutoSize    = true;
            lblReceived.BackColor   = System.Drawing.Color.FromArgb(((int)(((byte)(46)))), ((int)(((byte)(86)))), ((int)(((byte)(120)))));
            lblReceived.ForeColor   = System.Drawing.Color.White;
            lblReceived.Location    = new System.Drawing.Point(5, 142);
            lblReceived.Margin      = new System.Windows.Forms.Padding(5, 5, 5, 1);
            lblReceived.MaximumSize = new System.Drawing.Size(455, 0);
            lblReceived.MinimumSize = new System.Drawing.Size(455, 0);
            lblReceived.Name        = "lblReceived";
            lblReceived.Padding     = new System.Windows.Forms.Padding(5);
            lblReceived.Size        = new System.Drawing.Size(455, 36);
            lblReceived.TabIndex    = 5;
            lblReceived.Text        = message.Message;

            uiFlowPanelChat.Controls.Add(lblReceived);
        }
示例#8
0
        private void AtualizaStatus(string messageJson)
        {
            try
            {
                // Instancia uma nova classe do tipo SupportMessage.
                SupportMessage supportMessage = new SupportMessage();

                // Converte o JSON para Objeto (SupportMessage).
                supportMessage = JsonConvert.DeserializeObject <SupportMessage>(messageJson);

                // Grava a mensagem no banco de dados.
                supportMessage.Gravar();

                // Appenda o JSON na lista de transmissão realizadas.
                txtDados.AppendText(messageJson + "\r\n");
            }
            catch
            {
                txtDados.AppendText(messageJson + "\r\n");
            }
        }
示例#9
0
        public async Task <IActionResult> SendMessageAsync(string customerId, [FromBody] SendSupportMessage command)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest());
                }

                var customer = await _dbContext.Customers.FirstOrDefaultAsync(c => c.CustomerId == customerId);

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

                if (customer.SupportMessages == null)
                {
                    customer.SupportMessages = new List <SupportMessage>();
                }

                SupportMessage message = Mapper.Map <SupportMessage>(command);
                customer.SupportMessages.Add(message);
                await _dbContext.SaveChangesAsync();

                // send event
                SupportMessageSent e = Mapper.Map <SupportMessageSent>(command);
                await _messagePublisher.PublishMessageAsync(e.MessageType, e, "");

                // return result
                return(CreatedAtRoute("GetByCustomerId", new { customerId = customer.CustomerId }, customer));
            }
            catch (DbUpdateException)
            {
                ModelState.AddModelError("", "Unable to save changes. " +
                                         "Try again, and if the problem persists " +
                                         "see your system administrator.");
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
        }
示例#10
0
        public async Task <SupportMessage> SendSupportMessage([FromBody] SupportMessage message)
        {
            if (!string.IsNullOrEmpty(User.Identity.Name))
            {
                message.UserId = $"AppUsers/{User.Identity.Name}";
            }

            using (logger.BeginKeyValueScope("message", message))
            {
                logger.LogInformation("Support message submitted");
            }

            // If we have a userID, see if we can load that user and update his/her name.
            if (!string.IsNullOrEmpty(message.Name) && !string.IsNullOrEmpty(message.UserId))
            {
                var user = await GetUser();

                if (user != null && string.IsNullOrEmpty(user.FirstName) && string.IsNullOrEmpty(user.LastName))
                {
                    // Update their name.
                    var nameParts = message.Name.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                    user.FirstName = nameParts.FirstOrDefault();
                    user.LastName  = string.Join(' ', nameParts.Skip(1));
                }
            }

            var isMutedUser = await DbSession.Advanced.ExistsAsync("MutedEmails/" + message.Email);

            if (!isMutedUser)
            {
                emailSender.QueueSupportEmail(message, emailOptions.SenderEmail);
            }
            else
            {
                logger.LogInformation("Support email received from muted user {email}. No email will be sent.", message.Email);
            }

            return(message);
        }
示例#11
0
        private void enviaMessagem(SupportMessage message)
        {
            Label lblSented = new Label();

            lblSented.AllowDrop   = true;
            lblSented.AutoSize    = true;
            lblSented.BackColor   = System.Drawing.Color.SteelBlue;
            lblSented.FlatStyle   = System.Windows.Forms.FlatStyle.Flat;
            lblSented.ForeColor   = System.Drawing.Color.White;
            lblSented.Location    = new System.Drawing.Point(99, 100);
            lblSented.Margin      = new System.Windows.Forms.Padding(99, 5, 10, 1);
            lblSented.MinimumSize = new System.Drawing.Size(455, 0);
            lblSented.Name        = "lblSented";
            lblSented.Padding     = new System.Windows.Forms.Padding(5);
            lblSented.Size        = new System.Drawing.Size(455, 36);
            lblSented.TabIndex    = 1;
            lblSented.Text        = message.Message;

            uiFlowPanelChat.Controls.Add(lblSented);
            stwEnviador.WriteLine(JsonConvert.SerializeObject(message));
            stwEnviador.Flush();
        }
示例#12
0
        private void InserirMensagemEnviada(SupportMessage message)
        {
            Label lblSented = new Label();

            lblSented.AllowDrop   = true;
            lblSented.AutoSize    = true;
            lblSented.BackColor   = System.Drawing.Color.SteelBlue;
            lblSented.FlatStyle   = System.Windows.Forms.FlatStyle.Flat;
            lblSented.ForeColor   = System.Drawing.Color.White;
            lblSented.Location    = new System.Drawing.Point(99, 100);
            lblSented.Margin      = new System.Windows.Forms.Padding(99, 5, 10, 1);
            lblSented.MinimumSize = new System.Drawing.Size(455, 0);
            lblSented.Name        = "lblSented";
            lblSented.Padding     = new System.Windows.Forms.Padding(5);
            lblSented.Size        = new System.Drawing.Size(455, 36);
            lblSented.TabIndex    = 1;
            lblSented.Text        = message.Message;

            uiFlowPanelChat.Controls.Add(lblSented);


            lblSented.Invalidate();
        }
示例#13
0
        private void AtualizaLog(string mensagemJson)
        {
            try
            {
                if (!mensagemJson.StartsWith(Support.CustomerId + " disse") || !mensagemJson.StartsWith("#"))
                {
                    SupportMessage supportMessage = new SupportMessage();

                    supportMessage = JsonConvert.DeserializeObject <SupportMessage>(mensagemJson);


                    if (supportMessage.Method == Method.RECEIVED)
                    {
                        if (supportMessage.SupportId == Support.SupportId)
                        {
                            if (supportMessage.EmployeeId == AppDesktop.ActualEmployee.EmployeeId)
                            {
                                InserirMensagemRecebida(supportMessage);
                            }
                        }
                    }
                }
            }
            catch (NullReferenceException)
            {
                if (!mensagemJson.StartsWith("#"))
                {
                    new Alert("Houve um problema ao requerer uma informação do servidor.", uiCSB.Toastr.Type.Warning);
                }
            }
            catch (Exception ex)
            {
                new Alert(ex.Message, uiCSB.Toastr.Type.Warning);
            }
            //txtLog.AppendText(strMensagem + "\r\n");
        }
示例#14
0
        /// <summary>
        /// Finds a message type to handle the message.
        /// </summary>
        public ReceivableMessage Process()
        {
            // Named messages.
            if (NickMessage.CanProcess(this))
            {
                return(new NickMessage(this));
            }
            if (QuitMessage.CanProcess(this))
            {
                return(new QuitMessage(this));
            }
            if (JoinMessage.CanProcess(this))
            {
                return(new JoinMessage(this));
            }
            if (PartMessage.CanProcess(this))
            {
                return(new PartMessage(this));
            }
            if (PrivateMessage.CanProcess(this))
            {
                return(new PrivateMessage(this));
            }
            if (PingMessage.CanProcess(this))
            {
                return(new PingMessage(this));
            }
            if (NoticeMessage.CanProcess(this))
            {
                return(new NoticeMessage(this));
            }
            if (UserModeMessage.CanProcess(this))
            {
                return(new UserModeMessage(this));
            }
            if (ChannelModeMessage.CanProcess(this))
            {
                return(new ChannelModeMessage(this));
            }
            if (KickMessage.CanProcess(this))
            {
                return(new KickMessage(this));
            }
            if (InviteMessage.CanProcess(this))
            {
                return(new InviteMessage(this));
            }
            if (OperwallMessage.CanProcess(this))
            {
                return(new OperwallMessage(this));
            }
            if (Receive.TopicMessage.CanProcess(this))
            {
                return(new Receive.TopicMessage(this));
            }

            // IRCv3 messages.
            if (Receive.v3.CapabilityMessage.CanProcess(this))
            {
                return(new Receive.v3.CapabilityMessage(this));
            }
            if (Receive.v3.AwayMessage.CanProcess(this))
            {
                return(new Receive.v3.AwayMessage(this));
            }

            // Numerics.
            if (NumericMessage.CanProcess(this))
            {
                // Pass all numeric messages to NumericMessage so an event can be fired, then pass it to more specific instances.
                // ReSharper disable once ObjectCreationAsStatement
                new NumericMessage(this);

                if (WelcomeMessage.CanProcess(this))
                {
                    return(new WelcomeMessage(this));
                }
                if (YourHostMessage.CanProcess(this))
                {
                    return(new YourHostMessage(this));
                }
                if (CreatedMessage.CanProcess(this))
                {
                    return(new CreatedMessage(this));
                }
                if (MyInfoMessage.CanProcess(this))
                {
                    return(new MyInfoMessage(this));
                }
                if (SupportMessage.CanProcess(this))
                {
                    return(new SupportMessage(this));
                }
                if (BounceMessage.CanProcess(this))
                {
                    return(new BounceMessage(this));
                }
                if (MOTDEndMessage.CanProcess(this))
                {
                    return(new MOTDEndMessage(this));
                }
                if (MOTDStartMessage.CanProcess(this))
                {
                    return(new MOTDStartMessage(this));
                }
                if (MOTDMessage.CanProcess(this))
                {
                    return(new MOTDMessage(this));
                }
                if (LUserMessage.CanProcess(this))
                {
                    return(new LUserMessage(this));
                }
                if (NamesMessage.CanProcess(this))
                {
                    return(new NamesMessage(this));
                }
                if (EndOfNamesMessage.CanProcess(this))
                {
                    return(new EndOfNamesMessage(this));
                }
                if (TopicMessage.CanProcess(this))
                {
                    return(new TopicMessage(this));
                }
                if (TopicWhoTimeMessage.CanProcess(this))
                {
                    return(new TopicWhoTimeMessage(this));
                }
                if (ListMessage.CanProcess(this))
                {
                    return(new ListMessage(this));
                }
                if (ListEndMessage.CanProcess(this))
                {
                    return(new ListEndMessage(this));
                }
                if (YoureOperMessage.CanProcess(this))
                {
                    return(new YoureOperMessage(this));
                }
                if (AwayMessage.CanProcess(this))
                {
                    return(new AwayMessage(this));
                }
                if (UnAwayMessage.CanProcess(this))
                {
                    return(new UnAwayMessage(this));
                }
                if (NowAwayMessage.CanProcess(this))
                {
                    return(new NowAwayMessage(this));
                }
                if (ChannelModeIsMessage.CanProcess(this))
                {
                    return(new ChannelModeIsMessage(this));
                }
                if (UModeIsMessage.CanProcess(this))
                {
                    return(new UModeIsMessage(this));
                }
                if (VersionMessage.CanProcess(this))
                {
                    return(new VersionMessage(this));
                }
                if (TimeMessage.CanProcess(this))
                {
                    return(new TimeMessage(this));
                }
                if (WhoMessage.CanProcess(this))
                {
                    return(new WhoMessage(this));
                }
                if (WhoisMessage.CanProcess(this))
                {
                    return(new WhoisMessage(this));
                }
                if (EndOfWhoMessage.CanProcess(this))
                {
                    return(new EndOfWhoMessage(this));
                }
                if (EndOfWhoisMessage.CanProcess(this))
                {
                    return(new EndOfWhoisMessage(this));
                }
                if (BanListMessage.CanProcess(this))
                {
                    return(new BanListMessage(this));
                }
                if (EndOfBanListMessage.CanProcess(this))
                {
                    return(new EndOfBanListMessage(this));
                }
                if (InviteListMessage.CanProcess(this))
                {
                    return(new InviteListMessage(this));
                }
                if (EndOfInviteListMessage.CanProcess(this))
                {
                    return(new EndOfInviteListMessage(this));
                }
                if (ExceptListMessage.CanProcess(this))
                {
                    return(new ExceptListMessage(this));
                }
                if (EndOfExceptListMessage.CanProcess(this))
                {
                    return(new EndOfExceptListMessage(this));
                }
                if (IsOnMessage.CanProcess(this))
                {
                    return(new IsOnMessage(this));
                }

                // Catch all for unhandled error messages.
                if (ErrorMessage.CanProcess(this))
                {
                    return(new ErrorMessage(this));
                }
            }

            Console.WriteLine("Message handler for \"" + Text + "\" not found.");
            return(null);
        }
示例#15
0
 private void EventInit(SupportMessage message)
 {
     message.OnMailSendingStarted += Message_OnMailSendingStarted;
     message.OnMailSendingEnded   += Message_OnMailSendingEnded;
 }
示例#16
0
 public EmailViewModel()
 {
     message = new SupportMessage();
     EventInit(message);
 }
示例#17
0
 internal void OnReplyISupport(SupportMessage message) => ReplyISupport?.Invoke(message);
示例#18
0
        public async Task <SupportMessageListModel> Send(SendSupportMessageModel model, int userId, Language language, string deviceId)
        {
            //User caller = null;
            Guest guest  = null;
            var   caller = await _repository.FilterAsNoTracking <User>(u => u.Id == userId).FirstOrDefaultAsync();

            if (caller == null)
            {
                guest = await _repository.FilterAsNoTracking <Guest>(g => g.DeviceId == deviceId).FirstOrDefaultAsync();

                if (guest == null)
                {
                    throw new Exception(_optionsBinder.Error().UserNotFound);
                }
            }

            var conversation = await _repository.Filter <SupportConversation>(x => x.Id == model.ConversationId)
                               .FirstOrDefaultAsync();

            if (conversation == null)
            {
                throw new Exception("connversation not found");
            }
            var  body            = model.MessageText;
            var  messageBodyType = model.SupportMessageBodyType;
            long length          = 0;

            if (model.File != null)
            {
                messageBodyType = SupportMessageBodyType.Image;
                body            = await _accessor.Upload(model.File, UploadType.SupportConversationFiles, conversation.Id);

                var extension = Path.GetExtension(body);
                if (extension != ".jpg" && extension != ".jpeg" && extension != ".png")
                {
                    messageBodyType = SupportMessageBodyType.Photo;
                }
                length = await _accessor.GetLength(body, UploadType.SupportConversationFiles, conversation.Id);
            }
            int?replayValue    = null;
            var supportMessage = new SupportMessage
            {
                SupportConversationId  = conversation.Id,
                SupportMessageBodyType = messageBodyType,
                MessageText            = body,
                FileLength             = length,
                ReplayMessageId        = model.ReplayMessageId.HasValue ? model.ReplayMessageId.Value : replayValue
            };

            if (caller != null)
            {
                supportMessage.UserSenderId  = caller.Id;
                supportMessage.GuestSenderId = null;
            }
            else
            {
                supportMessage.GuestSenderId = guest.Id;
                supportMessage.UserSenderId  = null;
            }
            _repository.Create(supportMessage);
            await _repository.SaveChangesAsync();

            int receiverId;

            if (caller != null)
            {
                receiverId = conversation.AdminId == caller.Id
                    ? conversation.GuestId ?? conversation.UserId ?? 0
                    : conversation.AdminId;
            }
            else
            {
                receiverId = conversation.AdminId;
            }
            var isGuest  = conversation.GuestId != null;
            var callerId = caller?.Id ?? guest.Id;
            AnnouncementListViewModel announcement = null;

            if (messageBodyType == SupportMessageBodyType.Announcement)
            {
                int.TryParse(model.MessageText, out var id);
                announcement = await _repository.Filter <Announcement>(x => !x.IsDraft && x.Id == id).Select(x =>
                                                                                                             new AnnouncementListViewModel
                {
                    Id            = x.Id,
                    BathroomCount = x.BathroomCount,
                    AnnouncementResidentialType = x.AnnouncementResidentialType,
                    AnnouncementRentType        = x.AnnouncementRentType,
                    IsFavourite            = false,
                    Address                = x.AddressEn.Trim(),
                    AnnouncementEstateType = x.AnnouncementEstateType,
                    AnnouncementType       = x.AnnouncementType,
                    Area         = Convert.ToInt64(x.Area),
                    BedroomCount = x.BedroomCount,
                    Price        = Convert.ToInt64(x.Price),
                    Title        = x.Title,
                    CreateDate   = x.CreatedDt,
                    Photo        = new ImageOptimizer
                    {
                        Photo = Utilities.ReturnFilePath(ConstValues.MediaBaseUrl, ConstValues.MediaResize,
                                                         UploadType.AnnouncementBasePhoto, x.BasePhoto, 300, 300, false, 0),
                        PhotoBlur = Utilities.ReturnFilePath(ConstValues.MediaBaseUrl, ConstValues.MediaResize,
                                                             UploadType.AnnouncementBasePhoto, x.BasePhoto, 100, 100, true, 0)
                    }
                }).FirstOrDefaultAsync();
            }
            var notify = (new SupportMessageListModel
            {
                ConversationId = conversation.Id,
                MessageId = supportMessage.Id,
                MessageText = supportMessage.SupportMessageBodyType == SupportMessageBodyType.Image ?
                              Utilities.ReturnFilePath(ConstValues.MediaBaseUrl, ConstValues.MediaResize,
                                                       UploadType.SupportConversationFiles, supportMessage.MessageText, 1000, 1000, false, conversation.Id) : supportMessage.MessageText,
                MessageBodyType = messageBodyType,
                SenderId = caller?.Id ?? guest.Id,
                FullName = caller != null ? supportMessage.UserSender.FullName : guest.Id.ToString(),
                Photo = caller != null ? new ImageOptimizer
                {
                    Photo = Utilities.ReturnFilePath(ConstValues.MediaBaseUrl, ConstValues.MediaResize,
                                                     UploadType.ProfilePhoto, supportMessage.UserSender.ProfilePhoto, ConstValues.Width, ConstValues.Height, false, 0),
                    PhotoBlur = Utilities.ReturnFilePath(ConstValues.MediaBaseUrl, ConstValues.MediaResize,
                                                         UploadType.ProfilePhoto, supportMessage.UserSender.ProfilePhoto, 100, 100, true, 0)
                } : new ImageOptimizer(),
                CreatedDate = supportMessage.CreatedDt,
                IsSentFromMe = false,
                Announcement = announcement,
                FileSize = length,
                FileUrl = messageBodyType == SupportMessageBodyType.Photo
                    ? Utilities.ReturnFilePath(ConstValues.MediaBaseUrl, ConstValues.MediaDownload,
                                               UploadType.SupportConversationFiles, supportMessage.MessageText, false, conversation.Id) : null,
                ReplayMessage = supportMessage.ReplayMessageId != null ? await _repository.Filter <SupportMessage>(s => s.Id == supportMessage.ReplayMessageId)
                                .Select(s => new SupportMessageListModel
                {
                    MessageBodyType = s.SupportMessageBodyType,
                    MessageId = s.Id,
                    MessageText = s.SupportMessageBodyType == SupportMessageBodyType.Image ?
                                  Utilities.ReturnFilePath(ConstValues.MediaBaseUrl, ConstValues.MediaResize,
                                                           UploadType.SupportConversationFiles, s.MessageText, 1000, 1000, false, conversation.Id) : s.MessageText,
                    CreatedDate = s.CreatedDt,
                    IsSentFromMe = (s.UserSenderId ?? s.GuestSenderId ?? 0) == callerId,
                    Photo = s.UserSender != null ? new ImageOptimizer
                    {
                        Photo = Utilities.ReturnFilePath(ConstValues.MediaBaseUrl, ConstValues.MediaResize,
                                                         UploadType.ProfilePhoto, s.UserSender.ProfilePhoto, ConstValues.Width, ConstValues.Height, false, 0),
                        PhotoBlur = Utilities.ReturnFilePath(ConstValues.MediaBaseUrl, ConstValues.MediaResize,
                                                             UploadType.ProfilePhoto, s.UserSender.ProfilePhoto, 100, 100, true, 0)
                    } : new ImageOptimizer(),
                    SenderId = s.UserSenderId ?? s.GuestSenderId.GetValueOrDefault(),
                    FullName = s.UserSenderId != null ? s.UserSender.FullName : "User",
                    FileUrl = s.SupportMessageBodyType == SupportMessageBodyType.Photo ?
                              Utilities.ReturnFilePath(ConstValues.MediaBaseUrl, ConstValues.MediaDownload,
                                                       UploadType.SupportConversationFiles, s.MessageText, false, conversation.Id) : null,
                    FileSize = s.FileLength
                }).FirstOrDefaultAsync() : null
            });

            if (notify.ReplayMessage != null && notify.ReplayMessage.MessageBodyType == SupportMessageBodyType.Announcement)
            {
                int.TryParse(notify.ReplayMessage.MessageText, out var replayMessage);
                notify.ReplayMessage.Announcement = _repository.Filter <Announcement>(x => !x.IsDraft && x.Id == replayMessage)
                                                    .Select(x => new AnnouncementListViewModel
                {
                    Id            = x.Id,
                    BathroomCount = x.BathroomCount,
                    AnnouncementResidentialType = x.AnnouncementResidentialType,
                    AnnouncementRentType        = x.AnnouncementRentType,
                    IsFavourite            = false,
                    Address                = x.AddressEn.Trim(),
                    AnnouncementEstateType = x.AnnouncementEstateType,
                    AnnouncementType       = x.AnnouncementType,
                    Area         = Convert.ToInt64(x.Area),
                    BedroomCount = x.BedroomCount,
                    Price        = Convert.ToInt64(x.Price),
                    Title        = x.Title,
                    Photo        = new ImageOptimizer
                    {
                        Photo = Utilities.ReturnFilePath(ConstValues.MediaBaseUrl, ConstValues.MediaResize,
                                                         UploadType.AnnouncementBasePhoto, x.BasePhoto, 300, 300, false, 0),
                        PhotoBlur = Utilities.ReturnFilePath(ConstValues.MediaBaseUrl, ConstValues.MediaResize,
                                                             UploadType.AnnouncementBasePhoto, x.BasePhoto, 100, 100, true, 0)
                    }
                }).FirstOrDefault();
            }
            var notifyToString = Utilities.SerializeObject(notify);
            var isSent         = await SupportChatMessageHandler.SendMessageAsync(conversation.Id, receiverId,
                                                                                  notifyToString, receiverId == conversation.GuestId);

            bool enableNotification = true;

            notify.IsSentFromMe = true;
            if (receiverId == conversation.AdminId && !isSent)
            {
                await SupportBaseMessageHandler.SendMessageAsync(conversation.Id, conversation.AdminId);

                return(notify);
            }
            if (!isSent && receiverId != conversation.AdminId)
            {
                if (isGuest && receiverId != conversation.AdminId)
                {
                    enableNotification = _repository.FilterAsNoTracking <PersonSetting>(s => s.GuestId == receiverId)
                                         .Select(s => s.SubscriptionsType).Contains(SubscriptionsType.EnableMessageNotification);
                }
                else if (!isGuest && caller != null && receiverId != conversation.AdminId)
                {
                    enableNotification = _repository.FilterAsNoTracking <PersonSetting>(s => s.UserId == receiverId)
                                         .Select(s => s.SubscriptionsType).Contains(SubscriptionsType.EnableMessageNotification);
                }

                if (enableNotification)
                {
                    await _firebaseRepository.SendIndividualNotification(new NewMessageNotificationModel
                    {
                        SenderId    = caller?.Id ?? guest.Id,
                        Description = messageBodyType == SupportMessageBodyType.Image ? "Image" :
                                      messageBodyType == SupportMessageBodyType.Photo ? "Photo" :
                                      messageBodyType == SupportMessageBodyType.Announcement ? "Announcement" : model.MessageText,
                        GenericId        = conversation.Id,
                        NotificationType = NotificationType.SupportMessage,
                        ReceiverId       = receiverId,
                        Title            = caller != null
                            ? $"{caller.FullName} sent you a message"
                            : $"Guest N {guest.Id} sent you a message"
                    }, isGuest);
                }
            }
            return(notify);
        }