Use failIfThrows for spam reporting tokens

This commit is contained in:
Max Radermacher 2026-04-13 17:03:11 -05:00 committed by GitHub
parent 0949136fb2
commit 2795e070b2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 11 deletions

View File

@ -38,8 +38,10 @@ public struct SpamReportingTokenRecord: Codable, FetchableRecord, PersistableRec
public static func reportingToken(
for sourceAci: Aci,
database: Database,
) throws -> SpamReportingToken? {
try Self.fetchOne(database, key: sourceAci.rawUUID)?.spamReportingToken
) -> SpamReportingToken? {
return failIfThrows {
return try Self.fetchOne(database, key: sourceAci.rawUUID)
}?.spamReportingToken
}
}

View File

@ -189,15 +189,7 @@ public enum ReportSpamUIUtils {
owsFailDebug("Failed to lookup guids to report \(error)")
}
var reportingToken: SpamReportingToken?
do {
reportingToken = try SpamReportingTokenRecord.reportingToken(
for: aci,
database: tx.database,
)
} catch {
owsFailBeta("Failed to look up spam reporting token. Continuing on, as the parameter is optional. Error: \(error)")
}
let reportingToken = SpamReportingTokenRecord.reportingToken(for: aci, database: tx.database)
guard !guidsToReport.isEmpty else {
Logger.warn("No messages with serverGuids to report.")