Skip to content

Commit 26bf039

Browse files
authored
Merge pull request #211 from jkrejcha/feature-thing-locking
Adds support for locking links and comments.
2 parents f4a5a44 + 170702f commit 26bf039

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

RedditSharp/Things/VotableThing.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ public enum VoteType
3737
private const string UnsaveUrl = "/api/unsave";
3838

3939
private const string DelUrl = "/api/del";
40+
private const string LockUrl = "/api/lock";
41+
private const string UnlockUrl = "/api/unlock";
4042

4143
/// <summary>
4244
/// Css flair class of the item author.
@@ -80,6 +82,14 @@ public enum VoteType
8082
[JsonProperty("saved")]
8183
public bool Saved { get; private set; }
8284

85+
/// <summary>
86+
/// Whether this <see cref="VotableThing"/> is locked. If <see langword="true""/>,
87+
/// only moderators with posts permissions or admins will be able to
88+
/// comment.
89+
/// </summary>
90+
[JsonProperty("locked")]
91+
public bool Locked { get; private set; }
92+
8393
/// <summary>
8494
/// Shortlink to the item
8595
/// </summary>
@@ -112,6 +122,27 @@ public enum VoteType
112122
[JsonProperty("gilded")]
113123
public int Gilded { get; private set; }
114124

125+
/// <summary>
126+
/// Locks this <see cref="VotableThing"/>. If <see langword="true""/>,
127+
/// Only moderators with posts permissions or admins will be able to
128+
/// comment.
129+
/// </summary>
130+
public async Task LockAsync()
131+
{
132+
await SimpleActionAsync(LockUrl);
133+
Locked = true;
134+
}
135+
136+
/// <summary>
137+
/// Unlocks this <see cref="VotableThing"/>. Users who were previously
138+
/// unable to comment because of it being locked are now able to.
139+
/// </summary>
140+
public async Task UnlockAsync()
141+
{
142+
await SimpleActionAsync(UnlockUrl);
143+
Locked = false;
144+
}
145+
115146
/// <summary>
116147
/// Gets or sets the vote for the current VotableThing.
117148
/// </summary>

0 commit comments

Comments
 (0)