Commits

Matt Hamilton committed ad1c76a

HTML decoding text when retweeting

  • Participants
  • Parent commits 4403e50

Comments (0)

Files changed (1)

Source/Halfwit2/ViewModels/Updates/RetweetViewModel.cs

 using Budgie;
 using Halfwit2.Helpers;
 using System.Threading.Tasks;
+using System.Net;
 
 namespace Halfwit2.ViewModels
 {
 
             _context = context;
             _prefix = "♺ @" + _context.User.ScreenName + ": ";
-            Text = _prefix + _context.Text;
+            Text = _prefix + WebUtility.HtmlDecode(_context.Text);
             Message = "Retweeting " + _context.User.Name;
         }
 
 
         protected override Task<ITwitterResponse<TwitterStatus>> PostUpdate()
         {
-            if (Text == _prefix + _context.Text)
+            if (Text == _prefix + WebUtility.HtmlDecode(_context.Text))
             {
                 return Service.RetweetAsync(_context.Id);
             }
 
         protected override int GetTextLength()
         {
-            if (Text == _prefix + _context.Text)
+            var userName = _context.User.Name ?? _context.User.ScreenName;
+            if (Text == _prefix + WebUtility.HtmlDecode(_context.Text))
             {
-                Message = "Natively Retweeting " + _context.User.Name;
-                return _context.Text.Length;
+                Message = "Natively Retweeting " + userName;
+                return WebUtility.HtmlDecode(_context.Text).Length;
             }
             else
             {
-                Message = "Retweeting " + _context.User.Name;
+                Message = "Retweeting " + userName;
                 return base.GetTextLength();
             }
         }