mirror of
https://github.com/lux-tel/session-ios.git
synced 2026-10-30 20:38:32 +00:00
• Cleaned up API structures to be more consistent • Moved OpenGroupAPI into SessionNetworkingKit • Moved PushNotificationAPI into SessionNetworkingKit • Renamed to OpenGroupAPI to SOGSAPI
62 lines
1.7 KiB
Swift
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
|
|
}
|
|
}
|
|
}
|
|
}
|