@@ -11,7 +11,7 @@ namespace RedditSharp
11
11
public static class ToolBoxUserNotes
12
12
{
13
13
private const string ToolBoxUserNotesWiki = "/r/{0}/wiki/usernotes" ;
14
- public static IEnumerable < tbUserNote > GetUserNotes ( IWebAgent webAgent , string subName )
14
+ public static IEnumerable < TBUserNote > GetUserNotes ( IWebAgent webAgent , string subName )
15
15
{
16
16
var request = webAgent . CreateGet ( String . Format ( ToolBoxUserNotesWiki , subName ) ) ;
17
17
var reqResponse = webAgent . ExecuteRequest ( request ) ;
@@ -22,11 +22,10 @@ public static IEnumerable<tbUserNote> GetUserNotes( IWebAgent webAgent, string s
22
22
23
23
string [ ] warnings = response [ "constants" ] [ "warnings" ] . Values < string > ( ) . ToArray ( ) ;
24
24
25
- if ( version < 6 )
25
+ if ( version < 6 ) throw new ToolBoxUserNotesException ( "Unsupported ToolBox version" ) ;
26
+
27
+ try
26
28
{
27
- throw new ToolBoxUserNotesException ( "Unsupported ToolBox version" ) ;
28
- }
29
- try {
30
29
var data = Convert . FromBase64String ( response [ "blob" ] . Value < string > ( ) ) ;
31
30
32
31
string uncompressed ;
@@ -46,14 +45,14 @@ public static IEnumerable<tbUserNote> GetUserNotes( IWebAgent webAgent, string s
46
45
47
46
JObject users = JObject . Parse ( uncompressed ) ;
48
47
49
- List < tbUserNote > toReturn = new List < tbUserNote > ( ) ;
48
+ List < TBUserNote > toReturn = new List < TBUserNote > ( ) ;
50
49
foreach ( KeyValuePair < string , JToken > user in users )
51
50
{
52
51
var x = user . Value ;
53
52
foreach ( JToken note in x [ "ns" ] . Children ( ) )
54
53
{
55
54
56
- tbUserNote uNote = new tbUserNote ( ) ;
55
+ TBUserNote uNote = new TBUserNote ( ) ;
57
56
uNote . AppliesToUsername = user . Key ;
58
57
uNote . SubName = subName ;
59
58
uNote . SubmitterIndex = note [ "m" ] . Value < int > ( ) ;
@@ -69,17 +68,16 @@ public static IEnumerable<tbUserNote> GetUserNotes( IWebAgent webAgent, string s
69
68
}
70
69
return toReturn ;
71
70
}
72
- catch ( Exception e )
71
+ catch ( Exception e )
73
72
{
74
73
throw new ToolBoxUserNotesException ( "An error occured while processing Usernotes wiki. See inner exception for details" , e ) ;
75
74
}
76
-
77
75
}
78
- public static string UnsquashLink ( string subreddit , string permalink )
76
+ public static string UnsquashLink ( string subreddit , string permalink )
79
77
{
80
-
81
78
var link = "https://reddit.com/r/" + subreddit + "/" ;
82
- if ( string . IsNullOrEmpty ( permalink ) ) {
79
+ if ( string . IsNullOrEmpty ( permalink ) )
80
+ {
83
81
return link ;
84
82
}
85
83
var linkParams = permalink . Split ( ',' ) ;
@@ -94,7 +92,6 @@ public static string UnsquashLink(string subreddit,string permalink)
94
92
{
95
93
link += "message/messages/" + linkParams [ 1 ] ;
96
94
}
97
-
98
95
return link ;
99
96
}
100
97
}
0 commit comments