import Foundation

// Header conventions that match the phone client's behaviour
// (src/lib/api-context.ts). `X-PIXELFED-APP: 1` is Pixelfed's app gate;
// Mastodon servers ignore it. The User-Agent is informational — instances
// that key on it (rate limits, abuse patterns) get a stable identifier.

enum HTTPHeaders {
    static func common(accountType: String) -> [String: String] {
        var h: [String: String] = [
            "Accept": "application/json",
            "User-Agent": Branding.userAgent,
        ]
        if accountType == "pixelfed" {
            h["X-PIXELFED-APP"] = "1"
        }
        return h
    }

    static func authed(token: String, accountType: String) -> [String: String] {
        var h = common(accountType: accountType)
        h["Authorization"] = "Bearer \(token)"
        return h
    }
}
