Files
Morgan Pretty 5e384eb7fb Moved and renamed remaining API definitions
• Cleaned up API structures to be more consistent
• Moved OpenGroupAPI into SessionNetworkingKit
• Moved PushNotificationAPI into SessionNetworkingKit
• Renamed to OpenGroupAPI to SOGSAPI
2025-09-15 14:22:39 +10:00

62 lines
1.7 KiB
Swift

// Copyright © 2023 Rangeproof Pty Ltd. All rights reserved.
import Foundation
import SessionNetworkingKit
import SessionUtilitiesKit
public extension Message {
enum Origin: Codable, Hashable {
case swarm(
publicKey: String,
namespace: Network.SnodeAPI.Namespace,
serverHash: String,
serverTimestampMs: Int64,
serverExpirationTimestamp: TimeInterval
)
case community(
openGroupId: String,
sender: String,
timestamp: TimeInterval?,
messageServerId: Int64,
whisper: Bool,
whisperMods: Bool,
whisperTo: String?
)
case openGroupInbox(
timestamp: TimeInterval,
messageServerId: Int64,
serverPublicKey: String,
senderId: String,
recipientId: String
)
public var isConfigNamespace: Bool {
switch self {
case .swarm(_, let namespace, _, _, _): return namespace.isConfigNamespace
default: return false
}
}
public var isCommunity: Bool {
switch self {
case .community: return true
default: return false
}
}
public var serverHash: String? {
switch self {
case .swarm(_, _, let serverHash, _, _): return serverHash
default: return nil
}
}
public var serverExpirationTimestamp: TimeInterval? {
switch self {
case .swarm(_, _, _, _, let expirationTimestamp): return expirationTimestamp
default: return nil
}
}
}
}