Skip to content

Commit 439d42e

Browse files
committed
Merge pull request #158 from corylulu/patch-4
Allows for voteable things to be reported.
2 parents 00e6eda + d4fd13f commit 439d42e

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

RedditSharp/Things/VotableThing.cs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,20 @@ public enum VoteType
1313
Downvote = -1
1414
}
1515

16+
public enum ReportType
17+
{
18+
Spam = 0,
19+
VoteManipulation = 1,
20+
PersonalInformation = 2,
21+
SexualizingMinors = 3,
22+
BreakingReddit = 4,
23+
Other = 5
24+
}
25+
1626
private const string VoteUrl = "/api/vote";
1727
private const string SaveUrl = "/api/save";
1828
private const string UnsaveUrl = "/api/unsave";
29+
private const string ReportUrl = "/api/report";
1930

2031
[JsonIgnore]
2132
private IWebAgent WebAgent { get; set; }
@@ -158,5 +169,41 @@ public void ClearVote()
158169
var response = request.GetResponse();
159170
var data = WebAgent.GetResponseString(response.GetResponseStream());
160171
}
172+
173+
public void Report(ReportType reportType, string otherReason = null)
174+
{
175+
var request = WebAgent.CreatePost(ReportUrl);
176+
var stream = request.GetRequestStream();
177+
178+
string reportReason;
179+
switch (reportType)
180+
{
181+
case ReportType.Spam:
182+
reportReason = "spam"; break;
183+
case ReportType.VoteManipulation:
184+
reportReason = "vote manipulation"; break;
185+
case ReportType.PersonalInformation:
186+
reportReason = "personal information"; break;
187+
case ReportType.BreakingReddit:
188+
reportReason = "breaking reddit"; break;
189+
case ReportType.SexualizingMinors:
190+
reportReason = "sexualizing minors"; break;
191+
default:
192+
reportReason = "other"; break;
193+
}
194+
195+
WebAgent.WritePostBody(stream, new
196+
{
197+
api_type = "json",
198+
reason = reportReason,
199+
other_reason = otherReason ?? "",
200+
thing_id = FullName,
201+
uh = Reddit.User.Modhash
202+
});
203+
stream.Close();
204+
var response = request.GetResponse();
205+
var data = WebAgent.GetResponseString(response.GetResponseStream());
206+
}
207+
161208
}
162209
}

0 commit comments

Comments
 (0)