Requests WIP: getWeeklyRants, getNotificationFeed

This commit is contained in:
Wilhelm Oks
2024-12-18 15:08:14 +01:00
parent edd526d2aa
commit b6fd0219fb
3 changed files with 52 additions and 3 deletions
@@ -2,7 +2,7 @@ import Foundation
/// Contains a list of all notifications for the logged in user and the numbers of unread notifications.
public struct NotificationFeed: Hashable {
public enum Categories: String, CaseIterable {
public enum Category: String, CaseIterable {
case all = ""
case upvotes = "upvotes"
case mentions = "mentions"
@@ -32,6 +32,10 @@ public struct NotificationFeed: Hashable {
extension NotificationFeed {
struct CodingData: Decodable {
struct Container: Decodable {
let data: NotificationFeed.CodingData
}
let check_time: Int
let items: [Notification.CodingData]
let unread: UnreadNumbers.CodingData
+3 -1
View File
@@ -71,7 +71,7 @@ extension Rant {
let text: String
let score: Int
let created_time: Int
let attached_image: AttachedImage.CodingData?
let attached_image: AttachedImage.CodingData? // this value can also be of type String. See the custom decoding code.
let num_comments: Int
let tags: [String]
let vote_state: Int
@@ -104,8 +104,10 @@ extension Rant {
created_time = try values.decode(Int.self, forKey: .created_time)
do {
// If the value is an object, decode it into an attached image.
attached_image = try values.decode(AttachedImage.CodingData.self, forKey: .attached_image)
} catch {
// Otherwise it was an empty string. Treat is as no attached image.
attached_image = nil
}