Skip to content

Commit 2d1807f

Browse files
authored
Merge pull request #164 from czf/2.0-Patch
Minor updates
2 parents dde0cdb + 58c4e6d commit 2d1807f

File tree

2 files changed

+38
-12
lines changed

2 files changed

+38
-12
lines changed

RedditSharp/Things/Post.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,18 @@ public Post(IWebAgent agent, JToken json) : base(agent, json)
3434
}
3535
#pragma warning restore 1591
3636

37+
/// <summary>
38+
/// Returns true if post is marked as spoiler
39+
/// </summary>
40+
[JsonProperty("spoiler")]
41+
public bool IsSpoiler { get; set; }
42+
43+
/// <summary>
44+
/// Returns true if this post is hidden
45+
/// </summary>
46+
[JsonProperty("hidden")]
47+
public bool IsHidden { get; set; }
48+
3749
/// <summary>
3850
/// Domain of this post.
3951
/// </summary>

RedditSharp/Things/PrivateMessage.cs

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public class PrivateMessage : ModeratableThing
1515
{
1616

1717
#region Properties
18+
private const string SetAsUnReadUrl = "/api/unread_message";
1819
private const string SetAsReadUrl = "/api/read_message";
1920
private const string CommentUrl = "/api/comment";
2021

@@ -158,28 +159,41 @@ public Listing<PrivateMessage> GetThread()
158159
/// <inheritdoc />
159160
internal override JToken GetJsonData(JToken json) => json["data"];
160161

161-
/// <summary>
162-
/// Mark the message read
162+
/// <summary>
163+
/// Reply to the message
163164
/// </summary>
164-
public async Task SetAsReadAsync()
165+
/// <param name="message">Markdown text.</param>
166+
public async Task ReplyAsync(string message)
165167
{
166-
await WebAgent.Post(SetAsReadUrl, new
168+
await WebAgent.Post(CommentUrl, new
167169
{
168-
id = FullName,
169-
api_type = "json"
170+
text = message,
171+
thing_id = FullName
170172
}).ConfigureAwait(false);
171173
}
172174

173175
/// <summary>
174-
/// Reply to the message
176+
/// Mark this comment as read.
175177
/// </summary>
176-
/// <param name="message">Markdown text.</param>
177-
public async Task ReplyAsync(string message)
178+
public async Task SetAsReadAsync()
178179
{
179-
await WebAgent.Post(CommentUrl, new
180+
await SetReadStatusAsync(SetAsReadUrl);
181+
}
182+
183+
/// <summary>
184+
/// Mark this comment as unread.
185+
/// </summary>
186+
public async Task SetAsUnReadAsync()
187+
{
188+
await SetReadStatusAsync(SetAsUnReadUrl);
189+
}
190+
191+
private async Task SetReadStatusAsync(string statusUrl)
192+
{
193+
await WebAgent.Post(statusUrl, new
180194
{
181-
text = message,
182-
thing_id = FullName
195+
id = FullName,
196+
api_type = "json"
183197
}).ConfigureAwait(false);
184198
}
185199
}

0 commit comments

Comments
 (0)