Native macOS app for posting to Mastodon, WordPress (self-hosted), and Micro.blog. Features: global hotkey (Ctrl+Option+Cmd+T), multiple accounts with selection, image attachments (up to 4, drag-and-drop), floating panel UI, Keychain storage.
56 lines
1.2 KiB
Swift
56 lines
1.2 KiB
Swift
import Foundation
|
|
|
|
enum ServiceType: String, Codable, CaseIterable, Identifiable {
|
|
case mastodon
|
|
case wordpress
|
|
case microblog
|
|
|
|
var id: String { rawValue }
|
|
|
|
var displayName: String {
|
|
switch self {
|
|
case .mastodon: "Mastodon"
|
|
case .wordpress: "WordPress"
|
|
case .microblog: "Micro.blog"
|
|
}
|
|
}
|
|
|
|
var iconName: String {
|
|
switch self {
|
|
case .mastodon: "bubble.left.and.text.bubble.right"
|
|
case .wordpress: "w.square"
|
|
case .microblog: "pencil.and.outline"
|
|
}
|
|
}
|
|
|
|
var maxImages: Int { 4 }
|
|
}
|
|
|
|
struct Account: Identifiable, Codable, Hashable {
|
|
let id: UUID
|
|
var serviceType: ServiceType
|
|
var displayName: String
|
|
var instanceURL: String
|
|
var username: String
|
|
|
|
// Mastodon-specific
|
|
var mastodonClientID: String?
|
|
var mastodonClientSecret: String?
|
|
|
|
init(
|
|
serviceType: ServiceType,
|
|
displayName: String,
|
|
instanceURL: String,
|
|
username: String
|
|
) {
|
|
self.id = UUID()
|
|
self.serviceType = serviceType
|
|
self.displayName = displayName
|
|
self.instanceURL = instanceURL
|
|
self.username = username
|
|
}
|
|
|
|
var keychainKey: String {
|
|
"account-\(id.uuidString)"
|
|
}
|
|
}
|