Skip to content

Commit

Permalink
allow manual reports even if a question has already been closed --aut…
Browse files Browse the repository at this point in the history
…oupdate
  • Loading branch information
Jonathan Keller committed May 9, 2017
1 parent e60300f commit 0ada88a
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions Sources/Reporter.swift
Expand Up @@ -188,19 +188,19 @@ class Reporter {
//Debug print
print ("'report' called on post \(id)")

let isManualReport = reasons.contains {
if case .manuallyReported = $0.type {
return true
} else {
return false
}
}

if let minDate: Date = Calendar(identifier: .gregorian).date(byAdding: DateComponents(hour: -6), to: Date()) {
let recentlyReportedPosts = reportedPosts.filter {
$0.when > minDate
}

let isManualReport = reasons.contains {
if case .manuallyReported = $0.type {
return true
} else {
return false
}
}

if !isManualReport && recentlyReportedPosts.contains(where: { $0.id == id }) {
print("Not reporting \(id) because it was recently reported.")
result = .alreadyReported
Expand All @@ -211,7 +211,7 @@ class Reporter {
rooms.forEach {$0.postMessage("Failed to calculate minimum report date!")}
}

if (post.closed_reason != nil) {
if !isManualReport && post.closed_reason != nil {
print ("Not reporting \(post.id ?? 0) as it is closed.")
result = .alreadyClosed
return
Expand Down

0 comments on commit 0ada88a

Please sign in to comment.