6
6
using HtmlAgilityPack ;
7
7
using Newtonsoft . Json ;
8
8
using Newtonsoft . Json . Linq ;
9
+ using RedditSharp . Utils ;
9
10
10
11
namespace RedditSharp . Things
11
12
{
@@ -37,6 +38,7 @@ public class Subreddit : Thing
37
38
private const string FlairListUrl = "/r/{0}/api/flairlist.json" ;
38
39
private const string CommentsUrl = "/r/{0}/comments.json" ;
39
40
private const string SearchUrl = "/r/{0}/search.json?q={1}&restrict_sr=on&sort={2}&t={3}" ;
41
+ private const string SearchUrlDate = "/r/{0}/search.json?q=timestamp:{1}..{2}&restrict_sr=on&sort={3}&syntax=cloudsearch" ;
40
42
41
43
[ JsonIgnore ]
42
44
private Reddit Reddit { get ; set ; }
@@ -66,8 +68,8 @@ public class Subreddit : Thing
66
68
[ JsonProperty ( "header_title" ) ]
67
69
public string HeaderTitle { get ; set ; }
68
70
69
- [ JsonProperty ( "over18 " ) ]
70
- public bool ? NSFW { get ; set ; }
71
+ [ JsonProperty ( "over_18 " ) ]
72
+ public bool NSFW { get ; set ; }
71
73
72
74
[ JsonProperty ( "public_description" ) ]
73
75
public string PublicDescription { get ; set ; }
@@ -89,20 +91,20 @@ public class Subreddit : Thing
89
91
/// Property determining whether the current logged in user is a moderator on this subreddit.
90
92
/// </summary>
91
93
[ JsonProperty ( "user_is_moderator" ) ]
92
- public bool UserIsModerator { get ; set ; }
94
+ public bool ? UserIsModerator { get ; set ; }
93
95
94
- /// <summary>
95
- /// Property giving the moderator permissions of the logged in user on this subreddit.
96
+ /// <summary>
97
+ /// Property giving the moderator permissions of the logged in user on this subreddit.
96
98
/// </summary>
97
- [ JsonProperty ( "mod_permissions" ) ]
98
- [ JsonConverter ( typeof ( ModeratorPermissionConverter ) ) ]
99
+ [ JsonProperty ( "mod_permissions" ) ]
100
+ [ JsonConverter ( typeof ( ModeratorPermissionConverter ) ) ]
99
101
public ModeratorPermission ModPermissions { get ; set ; }
100
102
101
103
/// <summary>
102
104
/// Property determining whether the current logged in user is banned from the subreddit.
103
105
/// </summary>
104
106
[ JsonProperty ( "user_is_banned" ) ]
105
- public bool UserIsBanned { get ; set ; }
107
+ public bool ? UserIsBanned { get ; set ; }
106
108
107
109
[ JsonIgnore ]
108
110
public string Name { get ; set ; }
@@ -177,6 +179,11 @@ public Listing<Post> Search(string terms)
177
179
return new Listing < Post > ( Reddit , string . Format ( SearchUrl , Name , Uri . EscapeUriString ( terms ) , "relevance" , "all" ) , WebAgent ) ;
178
180
}
179
181
182
+ public Listing < Post > Search ( DateTime from , DateTime to )
183
+ {
184
+ return new Listing < Post > ( Reddit , string . Format ( SearchUrlDate , Name , from . DateTimeToUnixTimestamp ( ) , to . DateTimeToUnixTimestamp ( ) , "new" ) , WebAgent ) ;
185
+ }
186
+
180
187
public SubredditSettings Settings
181
188
{
182
189
get
@@ -271,12 +278,12 @@ public IEnumerable<ModeratorUser> Moderators
271
278
}
272
279
}
273
280
274
- public IEnumerable < TBUserNote > UserNotes
275
- {
276
- get
277
- {
278
- return ToolBoxUserNotes . GetUserNotes ( WebAgent , Name ) ;
279
- }
281
+ public IEnumerable < TBUserNote > UserNotes
282
+ {
283
+ get
284
+ {
285
+ return ToolBoxUserNotes . GetUserNotes ( WebAgent , Name ) ;
286
+ }
280
287
}
281
288
282
289
public Subreddit Init ( Reddit reddit , JToken json , IWebAgent webAgent )
0 commit comments