[smuxi/stable] Engine-Twitter: fix OverflowException thrown in TwitterProtocolManager.CloseChat()



commit f1057b2880053c3f5e4c2af3bd6c87fd8466749b
Author: Mirco Bauer <meebey meebey net>
Date:   Sun Jul 24 22:03:32 2016 +0200

    Engine-Twitter: fix OverflowException thrown in TwitterProtocolManager.CloseChat()
    
    ChatModel.ID is a long integer for newer Twitter accounts and thus the
    Enum.Parse() into a Int32 fails with an OverflowException. The parse needs a
    guard check to only parse for "group chats".

 .../Protocols/Twitter/TwitterProtocolManager.cs    |   17 +++++++++--------
 1 files changed, 9 insertions(+), 8 deletions(-)
---
diff --git a/src/Engine-Twitter/Protocols/Twitter/TwitterProtocolManager.cs 
b/src/Engine-Twitter/Protocols/Twitter/TwitterProtocolManager.cs
index 66b31f0..5357418 100644
--- a/src/Engine-Twitter/Protocols/Twitter/TwitterProtocolManager.cs
+++ b/src/Engine-Twitter/Protocols/Twitter/TwitterProtocolManager.cs
@@ -581,15 +581,16 @@ namespace Smuxi.Engine
             Trace.Call(fm, chat);
 
             TwitterChatType? chatType = null;
-            try {
-                chatType = (TwitterChatType) Enum.Parse(
-                    typeof(TwitterChatType),
-                    chat.ID
-                );
-            } catch (ArgumentException) {
+            if (chat.ChatType == ChatType.Group) {
+                try {
+                    chatType = (TwitterChatType) Enum.Parse(
+                        typeof(TwitterChatType),
+                        chat.ID
+                    );
+                } catch (ArgumentException) {
+                }
             }
-            if (chat.ChatType == ChatType.Group &&
-                chatType.HasValue) {
+            if (chatType.HasValue) {
                switch (chatType.Value) {
                     case TwitterChatType.FriendsTimeline:
                         if (f_UpdateFriendsTimelineThread != null &&


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]