Skip to content

Commit 5c4816b

Browse files
committed
Set as unread for private message
1 parent 7483a5e commit 5c4816b

File tree

1 file changed

+26
-12
lines changed

1 file changed

+26
-12
lines changed

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)