krz/hutch
an ios client for sourcehut
clone: git clone https://gitbay.org/krz/hutch.git
main: Hutch/Models/Meta.swift · raw
1import Foundation
2
3// MARK: - User Profile (full)
4
5/// Extended user profile from meta.sr.ht with all fields from the `me` query.
6nonisolated struct UserProfile: Codable, Sendable {
7 let username: String
8 let canonicalName: String
9 let email: String
10 let url: String?
11 let location: String?
12 let bio: String?
13 let avatar: String?
14 let userType: String?
15 let sshKeys: SSHKeyPage
16 let pgpKeys: PGPKeyPage
17 let paymentStatus: String?
18 let subscription: Subscription?
19}
20
21// MARK: - SSH Key
22
23nonisolated struct SSHKey: Codable, Sendable, Identifiable {
24 let id: Int
25 let comment: String?
26 let created: Date
27 let lastUsed: Date?
28
29 var displayLabel: String {
30 if let comment, !comment.isEmpty {
31 return comment
32 }
33 return "SSH key #\(id)"
34 }
35}
36
37nonisolated struct SSHKeyPage: Codable, Sendable {
38 let results: [SSHKey]
39 let cursor: String?
40}
41
42// MARK: - PGP Key
43
44nonisolated struct PGPKey: Codable, Sendable, Identifiable {
45 let id: Int
46 let fingerprint: String
47 let created: Date
48}
49
50nonisolated struct PGPKeyPage: Codable, Sendable {
51 let results: [PGPKey]
52 let cursor: String?
53}
54
55// MARK: - Subscription
56
57nonisolated struct Subscription: Codable, Sendable {
58 let status: String?
59 let autorenew: Bool?
60 let interval: String?
61}
62
63// MARK: - Personal Access Token
64
65nonisolated struct PersonalAccessToken: Codable, Sendable, Identifiable {
66 let id: Int
67 let issued: Date
68 let expires: Date?
69 let comment: String?
70 let grants: String?
71}
72
73/// One entry in meta.sr.ht's audit log: a security-relevant action on the
74/// account, with the address it came from.
75nonisolated struct AuditLogEntry: Codable, Sendable, Identifiable {
76 let id: Int
77 let created: Date
78 let ipAddress: String
79 let eventType: String
80 let details: String?
81}