private string UpdateFromLabel(Chat chat, NotificationTypeNewPushMessage message)
        {
            //if (message.IsService())
            //{
            //return MessageService.GetText(new ViewModels.MessageViewModel(_protoService, null, null, message));
            //}

            var result = string.Empty;

            User from = null;

            if (message.Sender is MessageSenderUser senderUser)
            {
                from = _protoService.GetUser(senderUser.UserId);

                if (from != null && ShowFrom(chat))
                {
                    if (!string.IsNullOrEmpty(from.FirstName))
                    {
                        result = $"{from.FirstName.Trim()}: ";
                    }
                    else if (!string.IsNullOrEmpty(from.LastName))
                    {
                        result = $"{from.LastName.Trim()}: ";
                    }
                    else if (!string.IsNullOrEmpty(from.Username))
                    {
                        result = $"{from.Username.Trim()}: ";
                    }
                    else if (from.Type is UserTypeDeleted)
                    {
                        result = $"{Strings.Resources.HiddenName}: ";
                    }
                    else
                    {
                        result = $"{from.Id}: ";
                    }
                }
            }

            string FormatPinned(string key)
            {
                if (chat.Type is ChatTypeSupergroup supergroup && supergroup.IsChannel)
                {
                    return(string.Format(key, string.Empty).Trim(' '));
                }
Exemple #2
0
 private void ProcessNewPushMessage(int group, int id, long chatId, NotificationTypeNewPushMessage newPushMessage)
 {
     UpdateFromLabel(_protoService.GetChat(chatId), newPushMessage);
 }