OSDN Git Service

blocking/idsを取得して該当するユーザーの発言はAddPost時に弾くようにした
authorf_swallow <f_swallow@users.sourceforge.jp>
Thu, 31 Mar 2011 09:59:23 +0000 (18:59 +0900)
committerKimura Youichi <kim.upsilon@bucyou.net>
Sat, 18 Feb 2012 14:19:23 +0000 (23:19 +0900)
Tween/Connection/HttpTwitter.vb
Tween/My Project/Resources.Designer.vb
Tween/My Project/Resources.resx
Tween/MyCommon.vb
Tween/StatusDictionary.vb
Tween/Tween.vb
Tween/Tween.vbproj
Tween/Twitter.vb

index bcded2c..bc238fb 100644 (file)
@@ -794,6 +794,14 @@ Public Class HttpTwitter
                             AddressOf GetApiCallback)
     End Function
 
+    Public Function GetBlockUserIds(ByRef content As String) As HttpStatusCode
+        Return httpCon.GetContent(GetMethod, _
+                            CreateTwitterUri("/1/blocks/blocking/ids.json"), _
+                            Nothing, _
+                            content, _
+                            TwitterApiInfo.HttpHeaders, _
+                            AddressOf GetApiCallback)
+    End Function
 
 #Region "Proxy API"
     Private Shared _twitterUrl As String = "api.twitter.com"
index 70266ef..68f3ece 100644 (file)
@@ -1,7 +1,7 @@
 '------------------------------------------------------------------------------
 ' <auto-generated>
 '     このコードはツールによって生成されました。
-'     ランタイム バージョン:4.0.30319.1
+'     ランタイム バージョン:4.0.30319.225
 '
 '     このファイルへの変更は、以下の状況下で不正な動作の原因になったり、
 '     コードが再生成されるときに損失したりします。
@@ -2787,6 +2787,33 @@ Namespace My.Resources
         End Property
         
         '''<summary>
+        '''  BlockIds取得中... に類似しているローカライズされた文字列を検索します。
+        '''</summary>
+        Friend ReadOnly Property UpdateBlockUserText1() As String
+            Get
+                Return ResourceManager.GetString("UpdateBlockUserText1", resourceCulture)
+            End Get
+        End Property
+        
+        '''<summary>
+        '''  BlockIds取得エラー : に類似しているローカライズされた文字列を検索します。
+        '''</summary>
+        Friend ReadOnly Property UpdateBlockUserText2() As String
+            Get
+                Return ResourceManager.GetString("UpdateBlockUserText2", resourceCulture)
+            End Get
+        End Property
+        
+        '''<summary>
+        '''  BlockIds取得完了 に類似しているローカライズされた文字列を検索します。
+        '''</summary>
+        Friend ReadOnly Property UpdateBlockUserText3() As String
+            Get
+                Return ResourceManager.GetString("UpdateBlockUserText3", resourceCulture)
+            End Get
+        End Property
+        
+        '''<summary>
         '''  Followers取得中... に類似しているローカライズされた文字列を検索します。
         '''</summary>
         Friend ReadOnly Property UpdateFollowersMenuItem1_ClickText1() As String
index 6bf742d..8c3d92a 100644 (file)
   <data name="SaveLogMenuItem_ClickText5" xml:space="preserve">
     <value>現在のタブに表示されているイベントログを保存しますか?{0} 「はい」  :現在タブに表示されているイベントログを保存する{0} 「いいえ」 :全てのイベントログを保存する{0}「キャンセル」:保存処理をキャンセル{0}(タブ区切りのテキストファイル形式で保存します)</value>
   </data>
+  <data name="UpdateBlockUserText1" xml:space="preserve">
+    <value>BlockIds取得中...</value>
+  </data>
+  <data name="UpdateBlockUserText2" xml:space="preserve">
+    <value>BlockIds取得エラー :</value>
+  </data>
+  <data name="UpdateBlockUserText3" xml:space="preserve">
+    <value>BlockIds取得完了</value>
+  </data>
 </root>
\ No newline at end of file
index 97134b0..036ffa7 100644 (file)
@@ -123,6 +123,7 @@ Public Module MyCommon
         Related                 '関連発言
         UserStream              'UserStream
         UserTimeline            'UserTimeline
+        BlockIds                'Blocking/ids
         '''
         ErrorState              'エラー表示のみで後処理終了(認証エラー時など)
     End Enum
index e141a35..f880f52 100644 (file)
@@ -453,6 +453,8 @@ Public NotInheritable Class TabInformations
     Private _retweets As New Dictionary(Of Long, PostClass)
     Private _removedTab As New Stack(Of TabClass)
 
+    Public BlockIds As New List(Of Long)
+
     '発言の追加
     'AddPost(複数回) -> DistributePosts          -> SubmitUpdate
 
@@ -1037,6 +1039,7 @@ Public NotInheritable Class TabInformations
                             Not Item.IsMe AndAlso
                             Me._retweets.ContainsKey(Item.RetweetedId) AndAlso
                             Me._retweets(Item.RetweetedId).RetweetedCount > 0 Then Exit Sub
+                        If BlockIds.Contains(Item.UserId) Then Exit Sub
                         _statuses.Add(Item.StatusId, Item)
                     End If
                     If Item.RetweetedId > 0 Then
index e327a8c..19071b3 100644 (file)
@@ -2144,6 +2144,12 @@ Public Class TweenMain
                 Dim tb As TabClass = _statuses.GetTabByName(args.tName)
                 ret = tw.GetRelatedResult(read, tb)
                 rslt.addCount = _statuses.DistributePosts()
+            Case WORKERTYPE.BlockIds
+                bw.ReportProgress(50, My.Resources.UpdateBlockUserText1)
+                ret = tw.GetBlockUserIds()
+                If TabInformations.GetInstance.BlockIds.Count = 0 Then
+                    tw.GetBlockUserIds()
+                End If
         End Select
         'キャンセル要求
         If bw.CancellationPending Then
@@ -2257,6 +2263,8 @@ Public Class TweenMain
                     smsg = "Related refreshed"
                 Case WORKERTYPE.UserTimeline
                     smsg = "UserTimeline refreshed"
+                Case WORKERTYPE.BlockIds
+                    smsg = My.Resources.UpdateBlockUserText3
             End Select
         End If
         Return smsg
@@ -2331,7 +2339,8 @@ Public Class TweenMain
            rslt.type = WORKERTYPE.FavAdd OrElse _
            rslt.type = WORKERTYPE.FavRemove OrElse _
            rslt.type = WORKERTYPE.Related OrElse _
-           rslt.type = WORKERTYPE.UserTimeline Then
+           rslt.type = WORKERTYPE.UserTimeline OrElse _
+           rslt.type = WORKERTYPE.BlockIds Then
             RefreshTimeline(False) 'リスト反映
         End If
 
@@ -8391,6 +8400,7 @@ RETRY:
         NotifyIcon1.Visible = True
 
         If IsNetworkAvailable() Then
+            GetTimeline(WORKERTYPE.BlockIds, 0, 0, "")
             If SettingDialog.StartupFollowers Then
                 GetTimeline(WORKERTYPE.Follower, 0, 0, "")
             End If
index c716d98..9ae585e 100644 (file)
@@ -48,6 +48,7 @@
     <NoWarn>42353,42354,42355</NoWarn>
     <WarningsAsErrors>41999,42016,42017,42018,42019,42020,42021,42022,42032,42036</WarningsAsErrors>
     <RemoveIntegerChecks>true</RemoveIntegerChecks>
+    <PlatformTarget>x86</PlatformTarget>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
     <DebugType>pdbonly</DebugType>
index d90d48b..d7ab6c2 100644 (file)
@@ -2851,6 +2851,43 @@ Public Class Twitter
             Return False
         End Try
     End Function
+    Public Function GetBlockUserIds() As String
+        If Twitter.AccountState <> ACCOUNT_STATE.Valid Then Return ""
+
+        Dim res As HttpStatusCode
+        Dim content As String = ""
+
+        Try
+            res = twCon.GetBlockUserIds(content)
+        Catch ex As Exception
+            Return "Err:" + ex.Message + "(" + GetCurrentMethod.Name + ")"
+        End Try
+
+        Select Case res
+            Case HttpStatusCode.OK
+                Twitter.AccountState = ACCOUNT_STATE.Valid
+            Case HttpStatusCode.Unauthorized
+                Twitter.AccountState = ACCOUNT_STATE.Invalid
+                Return "Check your Username/Password."
+            Case HttpStatusCode.BadRequest
+                Return "Err:API Limits?"
+            Case Else
+                Return "Err:" + res.ToString() + "(" + GetCurrentMethod.Name + ")"
+        End Select
+
+        Try
+            Dim Ids = CreateDataFromJson(Of Long())(content)
+            TabInformations.GetInstance.BlockIds.AddRange(Ids)
+            Return ("")
+        Catch ex As SerializationException
+            TraceOut(ex.Message + Environment.NewLine + content)
+            Return "Err:Json Parse Error(DataContractJsonSerializer)"
+        Catch ex As Exception
+            TraceOut(ex, GetCurrentMethod.Name & " " & content)
+            Return "Err:Invalid Json!"
+        End Try
+
+    End Function
 
     Public Function GetHashList() As String()
         Dim hashArray As String()