 	}
 	
 	func checkPost(_ post: Question) -> [FilterResult] {
-        //Debug print
-        print ("Checking post id \(post.id ?? -1).")
+		//Debug print
+		print ("Checking post id \(post.id ?? -1).")
 		return filters.flatMap { $0.check(post) }
 	}
 	

	let rooms: [ChatRoom]
	
	var filters = [Filter]()
	
	func filter<T: Filter>(ofType type: T.Type) -> T? {
		for filter in filters {

	
	///Reports a post if it has not been recently reported.  Returns either .reported or .alreadyReported.
	func report(post: Question, reasons: [FilterResult]) -> ReportResult {
		var result: ReportResult = .notBad
		
		queue.sync {
			guard let id = post.id else {
				print("No post ID!")
				result = .notBad
				return
			}
			
			//Debug print
			print ("'report' called on post \(id)")
			
			if let minDate: Date = Calendar(identifier: .gregorian).date(byAdding: DateComponents(hour: -6), to: Date()) {
				let recentlyReportedPosts = reportedPosts.filter {
					$0.when > minDate
				}
				if recentlyReportedPosts.contains(where: { $0.id == id }) {
					print("Not reporting \(id) because it was recently reported.")
					result = .alreadyReported
					return
				}
			}
			else {
				rooms.forEach {$0.postMessage("Failed to calculate minimum report date!")}
			}
			
			if (post.closed_reason != nil) {
				print ("Not reporting \(post.id ?? 0) as it is closed.")
				result = .alreadyClosed
				return
			}
			
			var reported = false
			
			var bayesianDifference: Int?
			
			var postDetails = "Details unknown."
			
			
			
			let title = "\(post.title ?? "<no title>")"
				.replacingOccurrences(of: "[", with: "\\[")
				.replacingOccurrences(of: "]", with: "\\]")
			
			let tags = post.tags ?? []
			
			let header = reasons.map { $0.header }.joined(separator: ", ")
			
			postDetails = reasons.map {$0.details ?? "Details unknown."}.joined (separator: ", ")
			
			
			
			var messages: [(host: ChatRoom.Host, roomID: Int, messageID: Int)] = []
			
			
			
			let sema = DispatchSemaphore(value: 0)
			
			for room in rooms {
				//Filter out Bayesian scores which are less than this room's threshold.
				let reasons = reasons.filter {
					if case .bayesianFilter(let difference) = $0.type {
						bayesianDifference = difference
						return difference < room.threshold
					}
					return true
				}
				if reasons.isEmpty {
					sema.signal()
					continue
				}
				
				reported = true
				
				
				let message = "[ [\(botName)](\(stackAppsLink)) ] " +
					"[tag:\(tags.first ?? "tagless")] \(header) [\(title)](//stackoverflow.com/q/\(id)) " +
					room.notificationString(tags: tags, reasons: reasons)
				
				room.postMessage(message, completion: {message in
					if let message = message {
						messages.append((host: room.host, roomID: room.roomID, messageID: message))
					}
					sema.signal()
				})
			}
			rooms.forEach { _ in sema.wait() }
			
			
			if reported {
				reportedPosts.append(Report(
					id: id,
					when: Date(),
					difference: bayesianDifference,
					messages: messages,
					details: postDetails
					)
				)
				
				result = .reported(reasons: reasons)
				return
			} else {
				result = .notBad
				return
			}
		}
		
		return result
	}
}
