File tree Expand file tree Collapse file tree 5 files changed +31
-93
lines changed Expand file tree Collapse file tree 5 files changed +31
-93
lines changed Original file line number Diff line number Diff line change 1
1
using Newtonsoft . Json ;
2
2
using Newtonsoft . Json . Linq ;
3
+ using RedditSharp . Things . User ;
3
4
4
5
namespace RedditSharp
5
6
{
6
7
/// <summary>
7
8
/// Represents a moderator.
8
9
/// </summary>
9
- public class ModeratorUser
10
+ public class ModeratorUser : RelUser
10
11
{
11
- /// <summary>
12
- /// Create ModeratorUser from given JSON
13
- /// </summary>
14
- /// <param name="json"></param>
15
- public ModeratorUser ( JToken json )
16
- {
17
- Helpers . PopulateObject ( json , this ) ;
18
- }
12
+ public ModeratorUser ( IWebAgent agent , JToken json ) : base ( agent , json )
13
+ {
14
+ }
19
15
20
- /// <summary>
21
- /// Moderator username.
22
- /// </summary>
23
- [ JsonProperty ( "name" ) ]
24
- public string Name { get ; private set ; }
25
-
26
- /// <summary>
27
- /// base36 Id of the moderator.
28
- /// </summary>
29
- [ JsonProperty ( "id" ) ]
30
- public string Id { get ; private set ; }
31
-
32
- /// <summary>
33
- /// Permissions the moderator has in the subreddit.
34
- /// </summary>
35
- [ JsonProperty ( "mod_permissions" ) ]
16
+ /// <summary>
17
+ /// Permissions the moderator has in the subreddit.
18
+ /// </summary>
19
+ [ JsonProperty ( "mod_permissions" ) ]
36
20
[ JsonConverter ( typeof ( ModeratorPermissionConverter ) ) ]
37
21
public ModeratorPermission Permissions { get ; private set ; }
38
-
39
- /// <inheritdoc/>
40
- public override string ToString ( )
41
- {
42
- return Name ;
43
- }
44
22
}
45
23
}
Original file line number Diff line number Diff line change 1
1
using Newtonsoft . Json ;
2
2
using Newtonsoft . Json . Linq ;
3
- using RedditSharp . Extensions ;
3
+ using RedditSharp . Things . User ;
4
4
using System ;
5
5
6
6
namespace RedditSharp . Things
7
7
{
8
8
/// <summary>
9
9
/// A user that is banned in a subreddit.
10
10
/// </summary>
11
- public class BannedUser : RedditUser
11
+ public class BannedUser : RelUser
12
12
{
13
13
/// <inheritdoc />
14
14
public BannedUser ( IWebAgent agent , JToken json ) : base ( agent , json ) {
15
- var data = json [ "name" ] == null ? json [ "data" ] : json ;
16
- base . Name = data [ "name" ] . ValueOrDefault < string > ( ) ;
17
- var id = data [ "id" ] . ValueOrDefault < string > ( ) ;
18
- if ( id . Contains ( "_" ) )
19
- {
20
- base . Kind = "t2" ;
21
- base . Id = id . Split ( '_' ) [ 1 ] ;
22
- base . FullName = id ;
23
- }
24
15
}
25
16
26
17
/// <summary>
27
18
/// Date the user was banned.
28
19
/// </summary>
29
- [ JsonProperty ( "date" ) ]
30
- [ JsonConverter ( typeof ( UnixTimestampConverter ) ) ]
31
- public DateTime ? BanDate { get ; private set ; }
20
+ [ Obsolete ( "User RelUser.Date" ) ]
21
+ public DateTime ? BanDate { get => DateUTC ; private set => DateUTC = value ; }
32
22
33
23
/// <summary>
34
24
/// Ban note.
35
25
/// </summary>
36
26
[ JsonProperty ( "note" ) ]
37
27
public string Note { get ; private set ; }
38
-
39
- /// <summary>
40
- /// This will always return 0 for BannedUsers
41
- /// </summary>
42
- [ JsonIgnore ]
43
- public new int CommentKarma => 0 ;
44
-
45
- /// <summary>
46
- /// This will always return 0 for BannedUsers
47
- /// </summary>
48
- [ JsonIgnore ]
49
- public new int LinkKarma => 0 ;
50
28
}
51
29
}
Original file line number Diff line number Diff line change 1
1
using Newtonsoft . Json ;
2
2
using Newtonsoft . Json . Linq ;
3
- using RedditSharp . Extensions ;
3
+ using RedditSharp . Things . User ;
4
4
using System ;
5
5
6
6
namespace RedditSharp . Things
7
7
{
8
8
/// <summary>
9
9
/// A contributor to a subreddit.
10
10
/// </summary>
11
- public class Contributor : RedditUser
11
+ public class Contributor : RelUser
12
12
{
13
13
/// <inheritdoc />
14
14
public Contributor ( IWebAgent agent , JToken json ) : base ( agent , json ) {
15
- var data = json [ "name" ] == null ? json [ "data" ] : json ;
16
- base . Name = data [ "name" ] . ValueOrDefault < string > ( ) ;
17
- var id = data [ "id" ] . ValueOrDefault < string > ( ) ;
18
- if ( id . Contains ( "_" ) )
19
- {
20
- base . Id = id . Split ( '_' ) [ 1 ] ;
21
- base . FullName = id ;
22
- }
23
15
}
24
16
25
- /// <summary>
26
- /// Contributor name.
27
- /// </summary>
28
- [ JsonProperty ( "name" ) ]
29
- public new string Name { get ; private set ; }
30
-
31
- /// <summary>
32
- /// Date contributor was added.
33
- /// </summary>
34
- [ JsonProperty ( "date" ) ]
35
- [ JsonConverter ( typeof ( UnixTimestampConverter ) ) ]
36
- public DateTime DateAdded { get ; private set ; }
37
-
38
- /// <summary>
39
- /// This will always return 0 for Contributors
40
- /// </summary>
41
- [ JsonIgnore ]
42
- public new int CommentKarma => 0 ;
43
-
44
- /// <summary>
45
- /// This will always return 0 for Contributors
46
- /// </summary>
47
- [ JsonIgnore ]
48
- public new int LinkKarma => 0 ;
49
- }
17
+ /// <summary>
18
+ /// Date contributor was added.
19
+ /// </summary>
20
+ [ Obsolete ( "User RelUser.Date" ) ]
21
+ public DateTime ? DateAdded { get => DateUTC ; private set => DateUTC = value ; }
22
+ }
50
23
}
Original file line number Diff line number Diff line change @@ -950,7 +950,7 @@ public static async Task<IEnumerable<ModeratorUser>> GetModeratorsAsync(IWebAgen
950
950
var mods = data [ "children" ] . ToArray ( ) ;
951
951
var result = new ModeratorUser [ mods . Length ] ;
952
952
for ( var i = 0 ; i < mods . Length ; i ++ ) {
953
- var mod = new ModeratorUser ( mods [ i ] ) ;
953
+ var mod = new ModeratorUser ( agent , mods [ i ] ) ;
954
954
result [ i ] = mod ;
955
955
}
956
956
return result ;
Original file line number Diff line number Diff line change 1
1
using Newtonsoft . Json ;
2
2
using Newtonsoft . Json . Linq ;
3
+ using RedditSharp . Extensions ;
3
4
using System ;
4
5
using System . Threading . Tasks ;
5
6
@@ -13,6 +14,14 @@ public class PartialUser : CreatedThing
13
14
/// <inheritdoc />
14
15
public PartialUser ( IWebAgent agent , JToken json ) : base ( agent , json )
15
16
{
17
+ var data = json [ "name" ] == null ? json [ "data" ] : json ;
18
+ Name = data [ "name" ] . ValueOrDefault < string > ( ) ;
19
+ var id = data [ "id" ] . ValueOrDefault < string > ( ) ;
20
+ if ( id . Contains ( "_" ) )
21
+ {
22
+ base . Id = id . Split ( '_' ) [ 1 ] ;
23
+ base . FullName = id ;
24
+ }
16
25
}
17
26
#region Properties
18
27
private string OverviewUrl => $ "/user/{ Name } .json";
You can’t perform that action at this time.
0 commit comments